From 3bfead298d5f1816bb4558ead4955b4c152ccd14 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 23 Jan 2013 21:12:36 +0100 Subject: [PATCH] Add custom management command to start the application with tornado --- openslides/main.py | 12 ++++++---- openslides/utils/management/__init__.py | 0 .../utils/management/commands/__init__.py | 0 .../utils/management/commands/run-tornado.py | 23 +++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 openslides/utils/management/__init__.py create mode 100644 openslides/utils/management/commands/__init__.py create mode 100644 openslides/utils/management/commands/run-tornado.py diff --git a/openslides/main.py b/openslides/main.py index 945cce87b..aab5ac203 100644 --- a/openslides/main.py +++ b/openslides/main.py @@ -78,7 +78,7 @@ KEY_LENGTH = 30 _portable_db_path = object() -def process_options(argv=None): +def process_options(argv=None, check_args=True): if argv is None: argv = sys.argv[1:] @@ -105,7 +105,11 @@ def process_options(argv=None): if opts.version: print get_version() exit(0) - if args: + + # Don't check for further args if we come from our custom management + # command, that always sets them + if args and not check_args: + sys.stderr.write("This command does not take arguments!\n\n") parser.print_help() sys.exit(1) @@ -113,8 +117,8 @@ def process_options(argv=None): return opts -def main(argv=None): - opts = process_options(argv) +def main(argv=None, check_args=True): + opts = process_options(argv, check_args) _main(opts) diff --git a/openslides/utils/management/__init__.py b/openslides/utils/management/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openslides/utils/management/commands/__init__.py b/openslides/utils/management/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openslides/utils/management/commands/run-tornado.py b/openslides/utils/management/commands/run-tornado.py new file mode 100644 index 000000000..39c5d6361 --- /dev/null +++ b/openslides/utils/management/commands/run-tornado.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +""" + Start script for OpenSlides. + + :copyright: 2011, 2012 by OpenSlides team, see AUTHORS. + :license: GNU GPL, see LICENSE for more details. + +""" + +from django.core.management.base import BaseCommand + +from openslides.main import main + + +class Command(BaseCommand): + ''' + Start the application using the tornado webserver + ''' + + help = 'Start the application using the tornado webserver' + + def handle(self, *args, **options): + main(check_args=False)