Updated start script help text and custom commands. Fixed #1987.
This commit is contained in:
parent
2b239f2214
commit
9fbb12944c
@ -51,12 +51,22 @@ def get_parser():
|
|||||||
# Init parser
|
# Init parser
|
||||||
description = 'Start script for OpenSlides.'
|
description = 'Start script for OpenSlides.'
|
||||||
if 'manage.py' not in sys.argv[0]:
|
if 'manage.py' not in sys.argv[0]:
|
||||||
description += (' If it is called without any argument, this will be '
|
description += """
|
||||||
'treated as if it is called with the "start" subcommand. '
|
If it is called without any argument, this will be treated as
|
||||||
'That means OpenSlides will setup default settings and '
|
if it is called with the 'start' subcommand. That means
|
||||||
'database, start the tornado webserver, launch the '
|
OpenSlides will setup default settings and database, start the
|
||||||
'default web browser and open the webinterface.')
|
tornado webserver, launch the default web browser and open the
|
||||||
parser = ExceptionArgumentParser(description=description)
|
webinterface.
|
||||||
|
"""
|
||||||
|
epilog = """
|
||||||
|
There are some more subcommands available. They belong to Django's
|
||||||
|
command-line utility for administrative tasks. Type '%(prog)s help'
|
||||||
|
(without the two hyphen-minus characters) to list them all. Type
|
||||||
|
'%(prog)s help <subcommand>' for help on a specific subcommand.
|
||||||
|
"""
|
||||||
|
parser = ExceptionArgumentParser(
|
||||||
|
description=description,
|
||||||
|
epilog=epilog)
|
||||||
|
|
||||||
# Add version argument
|
# Add version argument
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -71,14 +81,18 @@ def get_parser():
|
|||||||
title='Available subcommands',
|
title='Available subcommands',
|
||||||
description="Type '%s <subcommand> --help' for help on a "
|
description="Type '%s <subcommand> --help' for help on a "
|
||||||
"specific subcommand." % parser.prog,
|
"specific subcommand." % parser.prog,
|
||||||
help='You can choose only one subcommand at once.')
|
help='You can choose only one subcommand at once.',
|
||||||
|
metavar='')
|
||||||
|
|
||||||
# Subcommand start
|
# Subcommand start
|
||||||
subcommand_start = subparsers.add_parser(
|
start_help = (
|
||||||
'start',
|
'Setup settings and database, start tornado webserver, launch the '
|
||||||
help='Setup settings and database, start tornado webserver, launch the '
|
|
||||||
'default web browser and open the webinterface. The environment '
|
'default web browser and open the webinterface. The environment '
|
||||||
'variable DJANGO_SETTINGS_MODULE is ignored.')
|
'variable DJANGO_SETTINGS_MODULE is ignored.')
|
||||||
|
subcommand_start = subparsers.add_parser(
|
||||||
|
'start',
|
||||||
|
description=start_help,
|
||||||
|
help=start_help)
|
||||||
subcommand_start.add_argument(
|
subcommand_start.add_argument(
|
||||||
'--no-browser',
|
'--no-browser',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -92,12 +106,14 @@ def get_parser():
|
|||||||
subcommand_start.add_argument(
|
subcommand_start.add_argument(
|
||||||
'--development',
|
'--development',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Command for development purposes.')
|
help='Option for development purposes.')
|
||||||
|
|
||||||
# Subcommand createsettings
|
# Subcommand createsettings
|
||||||
|
createsettings_help = 'Creates the settings file.'
|
||||||
subcommand_createsettings = subparsers.add_parser(
|
subcommand_createsettings = subparsers.add_parser(
|
||||||
'createsettings',
|
'createsettings',
|
||||||
help='Create the settings file.')
|
description=createsettings_help,
|
||||||
|
help=createsettings_help)
|
||||||
subcommand_createsettings.set_defaults(callback=createsettings)
|
subcommand_createsettings.set_defaults(callback=createsettings)
|
||||||
subcommand_createsettings.add_argument(
|
subcommand_createsettings.add_argument(
|
||||||
'--settings_path',
|
'--settings_path',
|
||||||
@ -107,7 +123,21 @@ def get_parser():
|
|||||||
subcommand_createsettings.add_argument(
|
subcommand_createsettings.add_argument(
|
||||||
'--development',
|
'--development',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Command for development purposes.')
|
help='Option for development purposes.')
|
||||||
|
|
||||||
|
# Help text for several Django subcommands
|
||||||
|
django_subcommands = (
|
||||||
|
('backupdb', 'Backups the SQLite3 database.'),
|
||||||
|
('createsuperuser', 'Creates or resets the admin user.'),
|
||||||
|
('migrate', 'Updates database schema.'),
|
||||||
|
('runserver', 'Starts the Tornado webserver.'),
|
||||||
|
)
|
||||||
|
for django_subcommand, help_text in django_subcommands:
|
||||||
|
subparsers._choices_actions.append(
|
||||||
|
subparsers._ChoicesPseudoAction(
|
||||||
|
django_subcommand,
|
||||||
|
(),
|
||||||
|
help_text))
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -1,21 +1,25 @@
|
|||||||
import shutil
|
import shutil
|
||||||
from optparse import make_option # TODO: Use argpase in Django 1.8
|
|
||||||
|
|
||||||
from django.core.management.base import CommandError, NoArgsCommand
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.db import connection, transaction
|
from django.db import connection, transaction
|
||||||
|
|
||||||
from openslides.utils.main import get_database_path_from_settings
|
from openslides.utils.main import get_database_path_from_settings
|
||||||
|
|
||||||
|
|
||||||
class Command(NoArgsCommand):
|
class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
Commands to create or reset the adminuser
|
Command to backup the SQLite3 database.
|
||||||
"""
|
"""
|
||||||
option_list = NoArgsCommand.option_list + (
|
help = 'Backups the SQLite3 database.'
|
||||||
make_option('--path', dest='path'),
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--path',
|
||||||
|
default='database_backup.sqlite',
|
||||||
|
help='Path for the backup file (Default: database_backup.sqlite).'
|
||||||
)
|
)
|
||||||
|
|
||||||
def handle_noargs(self, **options):
|
def handle(self, *args, **options):
|
||||||
path = options.get('path')
|
path = options.get('path')
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
@ -21,6 +21,8 @@ class Command(_Command):
|
|||||||
|
|
||||||
The Code is from django 1.9
|
The Code is from django 1.9
|
||||||
"""
|
"""
|
||||||
|
help = 'Starts the Tornado webserver.'
|
||||||
|
|
||||||
# TODO: do not start tornado when the settings says so
|
# TODO: do not start tornado when the settings says so
|
||||||
|
|
||||||
def inner_run(self, *args, **options):
|
def inner_run(self, *args, **options):
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
from django.core.management.base import NoArgsCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from ...models import User
|
from ...models import User
|
||||||
|
|
||||||
|
|
||||||
class Command(NoArgsCommand):
|
class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
Command to create or reset the admin user.
|
Command to create or reset the admin user.
|
||||||
"""
|
"""
|
||||||
def handle_noargs(self, **options):
|
help = 'Creates or resets the admin user.'
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
created = User.objects.create_or_reset_admin_user()
|
created = User.objects.create_or_reset_admin_user()
|
||||||
if created:
|
if created:
|
||||||
self.stdout.write('Admin user successfully created.')
|
self.stdout.write('Admin user successfully created.')
|
||||||
|
Loading…
Reference in New Issue
Block a user