Mercurial > mozilla > hg > talosnames
annotate 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 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/env python |
2 | |
3 """ | |
4 web handler for talosnames | |
5 """ | |
6 | |
19
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
7 import os |
22 | 8 import pprint |
19
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
9 import tempita |
18 | 10 from api import TalosNames |
0 | 11 from webob import Request, Response, exc |
12 | |
19
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
13 here = os.path.dirname(os.path.abspath(__file__)) |
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
14 template = os.path.join(here, 'templates', 'index.html') |
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
15 |
0 | 16 class Handler(object): |
17 | |
18 def __init__(self, **kw): | |
18 | 19 self.api = TalosNames() |
19
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
20 self.template = file(template).read() |
0 | 21 |
25 | 22 # get data |
21 | 23 suites = sorted(self.api.suites.keys()) |
24 tests = {} | |
25 for suite in suites: | |
26 try: | |
27 test = self.api.test_config(suite) | |
28 tests[suite] = test | |
29 except: | |
30 tests[suite] = None | |
31 | |
25 | 32 self.data = {'suites': suites, |
33 'commands': self.api.buildbot_commands, | |
34 'tbpl': dict([(suite, self.api.tbpl_name(suite)) | |
35 for suite in suites]), | |
36 'tests': tests, | |
37 'pprint': pprint.pformat, | |
38 'api': self.api | |
39 } | |
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) | |
19
aae0a420c4f7
should now actually do something
Jeff Hammel <jhammel@mozilla.com>
parents:
18
diff
changeset
|
51 |
0 | 52 if __name__ == '__main__': |
53 from wsgiref import simple_server | |
54 app = Handler() | |
55 server = simple_server.make_server(host='0.0.0.0', port=8080, app=app) | |
56 server.serve_forever() | |
57 | |
18 | 58 |