changeset 40:10945dedde84

get query string working for TBPL suites
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 24 Jul 2012 22:51:40 -0700
parents ff2f0788e91b
children 4dfa9c298e3d
files talosnames/templates/index.html talosnames/web.py
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/talosnames/templates/index.html	Tue Jul 24 22:29:37 2012 -0700
+++ b/talosnames/templates/index.html	Tue Jul 24 22:51:40 2012 -0700
@@ -13,6 +13,7 @@
 table, th, td {
 border: 1px solid black;
 }
+
 dt {
 font-style: italic;
 font-weight: 550;
--- a/talosnames/web.py	Tue Jul 24 22:29:37 2012 -0700
+++ b/talosnames/web.py	Tue Jul 24 22:51:40 2012 -0700
@@ -30,8 +30,9 @@
                 tests[suite] = test
             except:
                 tests[suite] = None
+        self.suites = suites
 
-        self.data = {'suites': suites,
+        self.data = {'suites': self.suites,
                      'commands': self.api.buildbot_commands,
                      'tbpl': dict([(suite, self.api.tbpl_name(suite))
                                    for suite in suites]),
@@ -86,13 +87,25 @@
     def __call__(self, environ, start_response):
         request = Request(environ)
         response = Response(content_type='text/html',
-                            body=self.render())
+                            body=self.render(request))
         return response(environ, start_response)
 
-    def render(self):
+    def render(self, request=None):
+        data = self.data.copy()
+        if request and 'tbpl' in request.GET:
+            tbplnames = []
+            for name in request.GET.getall('tbpl'):
+                if not name.startswith('Talos'):
+                    name = 'Talos ' + name
+                tbplnames.append(name)
+            suites = []
+            for suite, value in self.data['tbpl'].items():
+                if value in tbplnames:
+                    suites.append(suite)
+            data['suites'] = sorted(suites)
         contents = file(template).read()
         _template = tempita.HTMLTemplate(contents)
-        return _template.substitute(self.data)
+        return _template.substitute(data)
 
 if __name__ == '__main__':