Error handling for unknown clients.
authorMark Cote <mcote@mozilla.com>
Wed, 04 Jul 2012 12:22:54 -0400
changeset 93 7a28989794d7271232ff231c35e75bc348962a23
parent 92 7e36b96247a097044575347f99fb6428014afed2
child 94 704b1d2d36b94f92c52a46757a4164ae9a98f882
push id91
push usermcote@mozilla.com
push dateWed, 04 Jul 2012 16:22:57 +0000
Error handling for unknown clients.
server/handlers.py
--- a/server/handlers.py
+++ b/server/handlers.py
@@ -230,18 +230,24 @@ class TestResults(object):
                 # we want it to be *inclusive*, i.e., returning all results
                 # on that date.
                 if re.match('\d{4}-\d{2}-\d{2}$', vars['end']):
                     wheres.append('date(teststart) <= $end')
                 else:
                     wheres.append('teststart <= $end')
             if client:
                 client_wheres = []
-                for i, ip in enumerate([x.strip() for x in
-                                        cfg.get('clients',client[0]).split(',')]):
+                try:
+                    ips = [x.strip() for x in
+                           cfg.get('clients',client[0]).split(',')]
+                except ConfigParser.NoOptionError:
+                    response['results'] = {}
+                    return response
+                    
+                for i, ip in enumerate(ips):
                     vars['ip%d' % i] = ip
                     client_wheres.append('ip like $ip%d' % i)
                 wheres.append('(' + ' OR '.join(client_wheres) + ')')
             for row in db.select(t, vars, where=' AND '.join(wheres), order='teststart ASC'):
                 record = dict(row)
                 for k, v in record.iteritems():
                     if isinstance(v, datetime.datetime):
                         record[k] = v.isoformat()