comparison talosnames/web.py @ 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 ef8590b55605
children 4dfa9c298e3d
comparison
equal deleted inserted replaced
39:ff2f0788e91b 40:10945dedde84
28 try: 28 try:
29 test = self.api.test_config(suite) 29 test = self.api.test_config(suite)
30 tests[suite] = test 30 tests[suite] = test
31 except: 31 except:
32 tests[suite] = None 32 tests[suite] = None
33 self.suites = suites
33 34
34 self.data = {'suites': suites, 35 self.data = {'suites': self.suites,
35 'commands': self.api.buildbot_commands, 36 'commands': self.api.buildbot_commands,
36 'tbpl': dict([(suite, self.api.tbpl_name(suite)) 37 'tbpl': dict([(suite, self.api.tbpl_name(suite))
37 for suite in suites]), 38 for suite in suites]),
38 'tests': tests, 39 'tests': tests,
39 'pprint': pprint.pformat, 40 'pprint': pprint.pformat,
84 self.data['test_type'] = test_type 85 self.data['test_type'] = test_type
85 86
86 def __call__(self, environ, start_response): 87 def __call__(self, environ, start_response):
87 request = Request(environ) 88 request = Request(environ)
88 response = Response(content_type='text/html', 89 response = Response(content_type='text/html',
89 body=self.render()) 90 body=self.render(request))
90 return response(environ, start_response) 91 return response(environ, start_response)
91 92
92 def render(self): 93 def render(self, request=None):
94 data = self.data.copy()
95 if request and 'tbpl' in request.GET:
96 tbplnames = []
97 for name in request.GET.getall('tbpl'):
98 if not name.startswith('Talos'):
99 name = 'Talos ' + name
100 tbplnames.append(name)
101 suites = []
102 for suite, value in self.data['tbpl'].items():
103 if value in tbplnames:
104 suites.append(suite)
105 data['suites'] = sorted(suites)
93 contents = file(template).read() 106 contents = file(template).read()
94 _template = tempita.HTMLTemplate(contents) 107 _template = tempita.HTMLTemplate(contents)
95 return _template.substitute(self.data) 108 return _template.substitute(data)
96 109
97 if __name__ == '__main__': 110 if __name__ == '__main__':
98 111
99 parser = optparse.OptionParser() 112 parser = optparse.OptionParser()
100 parser.add_option('-o', '--output', dest='output', 113 parser.add_option('-o', '--output', dest='output',