Mercurial > mozilla > hg > talosnames
comparison talosnames/web.py @ 25:6ec941f8704a
css improvements
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 10 Jul 2012 23:19:29 -0700 |
parents | 56d267d847e1 |
children | c6a042aad739 |
comparison
equal
deleted
inserted
replaced
24:56d267d847e1 | 25:6ec941f8704a |
---|---|
17 | 17 |
18 def __init__(self, **kw): | 18 def __init__(self, **kw): |
19 self.api = TalosNames() | 19 self.api = TalosNames() |
20 self.template = file(template).read() | 20 self.template = file(template).read() |
21 | 21 |
22 def __call__(self, environ, start_response): | 22 # get data |
23 request = Request(environ) | |
24 response = Response(content_type='text/html', | |
25 body=self.render()) | |
26 return response(environ, start_response) | |
27 | |
28 def render(self): | |
29 template = tempita.HTMLTemplate(self.template) | |
30 suites = sorted(self.api.suites.keys()) | 23 suites = sorted(self.api.suites.keys()) |
31 tests = {} | 24 tests = {} |
32 for suite in suites: | 25 for suite in suites: |
33 try: | 26 try: |
34 test = self.api.test_config(suite) | 27 test = self.api.test_config(suite) |
35 tests[suite] = test | 28 tests[suite] = test |
36 except: | 29 except: |
37 tests[suite] = None | 30 tests[suite] = None |
38 | 31 |
39 data = {'suites': suites, | 32 self.data = {'suites': suites, |
40 'commands': self.api.buildbot_commands, | 33 'commands': self.api.buildbot_commands, |
41 'tbpl': dict([(suite, self.api.tbpl_name(suite)) | 34 'tbpl': dict([(suite, self.api.tbpl_name(suite)) |
42 for suite in suites]), | 35 for suite in suites]), |
43 'tests': tests, | 36 'tests': tests, |
44 'pprint': pprint.pformat, | 37 'pprint': pprint.pformat, |
45 'api': self.api | 38 'api': self.api |
46 } | 39 } |
47 return template.substitute(data) | 40 |
41 | |
42 def __call__(self, environ, start_response): | |
43 request = Request(environ) | |
44 response = Response(content_type='text/html', | |
45 body=self.render()) | |
46 return response(environ, start_response) | |
47 | |
48 def render(self): | |
49 template = tempita.HTMLTemplate(self.template) | |
50 return template.substitute(self.data) | |
48 | 51 |
49 if __name__ == '__main__': | 52 if __name__ == '__main__': |
50 from wsgiref import simple_server | 53 from wsgiref import simple_server |
51 app = Handler() | 54 app = Handler() |
52 server = simple_server.make_server(host='0.0.0.0', port=8080, app=app) | 55 server = simple_server.make_server(host='0.0.0.0', port=8080, app=app) |