Mercurial > mozilla > hg > talosnames
comparison talosnames/web.py @ 46:fcd98303a90d
provide CLI handler for web
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 13 Aug 2012 15:14:53 -0700 |
parents | 10e59c3ae847 |
children | 11249e75ced6 |
comparison
equal
deleted
inserted
replaced
45:c1cbb79a6aaf | 46:fcd98303a90d |
---|---|
5 """ | 5 """ |
6 | 6 |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import pprint | 9 import pprint |
10 import sys | |
10 import talos.test | 11 import talos.test |
11 import tempita | 12 import tempita |
12 from api import TalosNames | 13 from api import TalosNames |
13 from subprocess import list2cmdline | 14 from subprocess import list2cmdline |
14 from webob import Request, Response, exc | 15 from webob import Request, Response, exc |
36 'enabled': self.api.buildbot_enabled, # whether the suite is enabled by default | 37 'enabled': self.api.buildbot_enabled, # whether the suite is enabled by default |
37 'commands': self.api.buildbot_commands, | 38 'commands': self.api.buildbot_commands, |
38 'tbpl': dict([(suite, self.api.tbpl_name(suite)) | 39 'tbpl': dict([(suite, self.api.tbpl_name(suite)) |
39 for suite in suites]), | 40 for suite in suites]), |
40 'tests': tests, | 41 'tests': tests, |
41 'pprint': pprint.pformat, | |
42 'list2cmdline': list2cmdline | 42 'list2cmdline': list2cmdline |
43 } | 43 } |
44 | 44 |
45 paint = {} | 45 paint = {} |
46 chrome = {} | 46 chrome = {} |
123 | 123 |
124 contents = file(template).read() | 124 contents = file(template).read() |
125 _template = tempita.HTMLTemplate(contents) | 125 _template = tempita.HTMLTemplate(contents) |
126 return _template.substitute(data) | 126 return _template.substitute(data) |
127 | 127 |
128 if __name__ == '__main__': | 128 def main(args=sys.argv[1:]): |
129 | |
130 parser = optparse.OptionParser() | 129 parser = optparse.OptionParser() |
131 parser.add_option('-o', '--output', dest='output', | 130 parser.add_option('-o', '--output', dest='output', |
132 help="file to output to") | 131 help="file to output to") |
133 parser.add_option('-p', '--port', dest='port', | 132 parser.add_option('-p', '--port', dest='port', |
134 default=8080, type='int', | 133 default=8080, type='int', |
135 help="port to serve on") | 134 help="port to serve on") |
136 options, args = parser.parse_args() | 135 options, args = parser.parse_args() |
137 | 136 |
138 app = Handler() | 137 app = Handler() |
138 print "Done creating handler." | |
139 | 139 |
140 if options.output: | 140 if options.output: |
141 f = file(options.output, 'w') | 141 f = file(options.output, 'w') |
142 f.write(app.render()) | 142 f.write(app.render()) |
143 f.close() | 143 f.close() |
145 from wsgiref import simple_server | 145 from wsgiref import simple_server |
146 server = simple_server.make_server(host='0.0.0.0', port=options.port, app=app) | 146 server = simple_server.make_server(host='0.0.0.0', port=options.port, app=app) |
147 server.serve_forever() | 147 server.serve_forever() |
148 | 148 |
149 | 149 |
150 if __name__ == '__main__': | |
151 main() | |
152 | |
153 | |
154 |