Download:
child 225:ada00fa1bf8b
parent 223:273b56088235
224:ce4f062fce9d
Anton Shestakov <av6@dwimlabs.net>, Wed, 24 Aug 2016 21:22:05 +0800
viewer: move option creation to main() to help with tests

1 файлов изменено, 9 вставок(+), 10 удалений(-) [+]
viewer.py file | annotate | diff | comparison | revisions
--- a/viewer.py Wed Aug 24 19:46:24 2016 +0800
+++ b/viewer.py Wed Aug 24 21:22:05 2016 +0800
@@ -13,14 +13,8 @@
from candolint.utils import rel
-define('listen', metavar='IP', default='127.0.0.1')
-define('port', metavar='PORT', default=8033, type=int)
-define('xheaders', metavar='True|False', default=False, type=bool)
-define('debug', metavar='True|False', default=False, type=bool)
-
-
class CandolintViewer(Application):
- def __init__(self):
+ def __init__(self, debug=False):
project_re = r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)'
handlers = [
(r'/', IndexHandler),
@@ -33,10 +27,10 @@
static_path=rel('static'),
template_path=rel('templates'),
ui_modules=uimodules,
- debug=options.debug
+ debug=debug
)
super(CandolintViewer, self).__init__(handlers, **settings)
- if options.debug:
+ if debug:
logging.getLogger('peewee').setLevel(logging.DEBUG)
database.init(rel('database.sqlite'))
@@ -47,9 +41,14 @@
def main():
+ define('listen', metavar='IP', default='127.0.0.1')
+ define('port', metavar='PORT', default=8033, type=int)
+ define('xheaders', metavar='True|False', default=False, type=bool)
+ define('debug', metavar='True|False', default=False, type=bool)
+
options.parse_command_line()
- application = CandolintViewer()
+ application = CandolintViewer(options.debug)
application.listen(options.port, options.listen, xheaders=options.xheaders)
IOLoop.current().start()