Esempio n. 1
0
def get_parser():
    """
    Parses all command line arguments.
    """
    if len(sys.argv) == 1 and not is_local_installation():
        sys.argv.append('start')

    # Init parser
    description = 'Start script for OpenSlides.'
    if 'manage.py' not in sys.argv[0]:
        description += """
            If it is called without any argument, this will be treated as
            if it is called with the 'start' subcommand. That means
            OpenSlides will setup default settings and database, start the
            tornado webserver, launch the default web browser and open the
            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
    parser.add_argument('--version',
                        action='version',
                        version=openslides_version,
                        help='Show version number and exit.')

    # Init subparsers
    subparsers = parser.add_subparsers(
        dest='subcommand',
        title='Available subcommands',
        description="Type '%s <subcommand> --help' for help on a "
        "specific subcommand." % parser.prog,
        help='You can choose only one subcommand at once.',
        metavar='')

    # Subcommand start
    start_help = (
        'Setup settings and database, start tornado webserver, launch the '
        'default web browser and open the webinterface. The environment '
        'variable DJANGO_SETTINGS_MODULE is ignored.')
    subcommand_start = subparsers.add_parser('start',
                                             description=start_help,
                                             help=start_help)
    subcommand_start.add_argument(
        '--no-browser',
        action='store_true',
        help='Do not launch the default web browser.')
    subcommand_start.add_argument(
        '--host',
        action='store',
        default='0.0.0.0',
        help='IP address to listen on. Default is 0.0.0.0.')
    subcommand_start.add_argument('--port',
                                  action='store',
                                  default='8000',
                                  help='Port to listen on. Default is 8000.')
    subcommand_start.add_argument(
        '--settings_path',
        action='store',
        default=None,
        help=
        'The used settings file. The file is created, if it does not exist.')
    subcommand_start.set_defaults(callback=start)
    subcommand_start.add_argument(
        '--local-installation',
        action='store_true',
        help='Store settings and user files in a local directory.')

    # Subcommand createsettings
    createsettings_help = 'Creates the settings file.'
    subcommand_createsettings = subparsers.add_parser(
        'createsettings',
        description=createsettings_help,
        help=createsettings_help)
    subcommand_createsettings.set_defaults(callback=createsettings)
    subcommand_createsettings.add_argument(
        '--settings_path',
        action='store',
        default=None,
        help='The used settings file. The file is created, even if it exists.')
    subcommand_createsettings.add_argument(
        '--local-installation',
        action='store_true',
        help='Store settings and user files in a local directory.')

    # 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
Esempio n. 2
0
def get_parser():
    """
    Parses all command line arguments.
    """
    if len(sys.argv) == 1:
        # Use start subcommand if called by openslides console script without
        # any other arguments.
        sys.argv.append('start')

    # Init parser
    description = 'Start script for OpenSlides.'
    if 'manage.py' not in sys.argv[0]:
        description += """
            If it is called without any argument, this will be treated as
            if it is called with the 'start' subcommand. That means
            OpenSlides will setup default settings and database, start the
            webserver, launch the default web browser and open the
            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
    parser.add_argument(
        '--version',
        action='version',
        version=openslides.__version__,
        help='Show version number and exit.')

    # Init subparsers
    subparsers = parser.add_subparsers(
        dest='subcommand',
        title='Available subcommands',
        description="Type '%s <subcommand> --help' for help on a "
                    "specific subcommand." % parser.prog,  # type: ignore
        help='You can choose only one subcommand at once.',
        metavar='')

    # Subcommand start
    start_help = (
        'Setup settings and database, start webserver, launch the '
        'default web browser and open the webinterface. The environment '
        'variable DJANGO_SETTINGS_MODULE is ignored.')
    subcommand_start = subparsers.add_parser(
        'start',
        description=start_help,
        help=start_help)
    subcommand_start.set_defaults(callback=start)
    subcommand_start.add_argument(
        '--no-browser',
        action='store_true',
        help='Do not launch the default web browser.')
    subcommand_start.add_argument(
        '--debug-email',
        action='store_true',
        help='Change the email backend to console output.')
    subcommand_start.add_argument(
        '--no-template-caching',
        action='store_true',
        default=False,
        help='Disables caching of templates.')
    subcommand_start.add_argument(
        '--host',
        action='store',
        default='0.0.0.0',
        help='IP address to listen on. Default is 0.0.0.0.')
    subcommand_start.add_argument(
        '--port',
        action='store',
        default='8000',
        help='Port to listen on. Default is 8000.')
    subcommand_start.add_argument(
        '--settings_dir',
        action='store',
        default=None,
        help='The settings directory.')
    subcommand_start.add_argument(
        '--settings_filename',
        action='store',
        default='settings.py',
        help='The used settings file name. The file is created, if it does not exist.')
    subcommand_start.add_argument(
        '--local-installation',
        action='store_true',
        help='Store settings and user files in a local directory.')
    subcommand_start.add_argument(
        '--use-geiss',
        action='store_true',
        help='Use Geiss instead of Daphne as ASGI protocol server.')

    # Subcommand createsettings
    createsettings_help = 'Creates the settings file.'
    subcommand_createsettings = subparsers.add_parser(
        'createsettings',
        description=createsettings_help,
        help=createsettings_help)
    subcommand_createsettings.set_defaults(callback=createsettings)
    subcommand_createsettings.add_argument(
        '--settings_dir',
        action='store',
        default=None,
        help='The used settings file directory. All settings files are created, even if they exist.')
    subcommand_createsettings.add_argument(
        '--settings_filename',
        action='store',
        default='settings.py',
        help='The used settings file name. The file is created, if it does not exist.')
    subcommand_createsettings.add_argument(
        '--local-installation',
        action='store_true',
        help='Store settings and user files in a local directory.')

    # 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(  # type: ignore
            subparsers._ChoicesPseudoAction(  # type: ignore
                django_subcommand,
                (),
                help_text))

    return parser
Esempio n. 3
0
def get_parser():
    """
    Parses all command line arguments.
    """
    if len(sys.argv) == 1 and not is_development():
        sys.argv.append('start')

    # Init parser
    description = 'Start script for OpenSlides.'
    if 'manage.py' not in sys.argv[0]:
        description += (
            ' If it is called without any argument, this will be '
            'treated as if it is called with the "start" subcommand. '
            'That means OpenSlides will setup default settings and '
            'database, start the tornado webserver, launch the '
            'default web browser and open the webinterface.')
    parser = ExceptionArgumentParser(description=description)

    # Add version argument
    parser.add_argument('--version',
                        action='version',
                        version=get_version(),
                        help='Show version number and exit.')

    # Init subparsers
    subparsers = parser.add_subparsers(
        dest='subcommand',
        title='Available subcommands',
        description="Type '%s <subcommand> --help' for help on a "
        "specific subcommand." % parser.prog,
        help='You can choose only one subcommand at once.')

    # Subcommand start
    subcommand_start = subparsers.add_parser(
        'start',
        help='Setup settings and database, start tornado webserver, launch the '
        'default web browser and open the webinterface. The environment '
        'variable DJANGO_SETTINGS_MODULE is ignored.')
    subcommand_start.add_argument(
        '--no-browser',
        action='store_true',
        help='Do not launch the default web browser.')
    subcommand_start.add_argument(
        '--settings_path',
        action='store',
        default=None,
        help=
        'The used settings file. The file is created, if it does not exist.')
    subcommand_start.set_defaults(callback=start)
    subcommand_start.add_argument('--development',
                                  action='store_true',
                                  help='Command for development purposes.')

    # Subcommand createsettings
    subcommand_createsettings = subparsers.add_parser(
        'createsettings', help='Create the settings file.')
    subcommand_createsettings.set_defaults(callback=createsettings)
    subcommand_createsettings.add_argument(
        '--settings_path',
        action='store',
        default=None,
        help='The used settings file. The file is created, even if it exists.')
    subcommand_createsettings.add_argument(
        '--development',
        action='store_true',
        help='Command for development purposes.')

    return parser
Esempio n. 4
0
def get_parser():
    """
    Parses all command line arguments.
    """
    if len(sys.argv) == 1:
        # Use start subcommand if called by openslides console script without
        # any other arguments.
        sys.argv.append("start")

    # Init parser
    description = "Start script for OpenSlides."
    if "manage.py" not in sys.argv[0]:
        description += """
            If it is called without any argument, this will be treated as
            if it is called with the 'start' subcommand. That means
            OpenSlides will setup default settings and database, start the
            webserver, launch the default web browser and open the
            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
    parser.add_argument(
        "--version",
        action="version",
        version=openslides.__version__,
        help="Show version number and exit.",
    )

    # Init subparsers
    subparsers = parser.add_subparsers(
        dest="subcommand",
        title="Available subcommands",
        description="Type '%s <subcommand> --help' for help on a "
        "specific subcommand." % parser.prog,  # type: ignore
        help="You can choose only one subcommand at once.",
        metavar="",
    )

    # Subcommand start
    start_help = (
        "Setup settings and database, start webserver, launch the "
        "default web browser and open the webinterface. The environment "
        "variable DJANGO_SETTINGS_MODULE is ignored.")
    subcommand_start = subparsers.add_parser("start",
                                             description=start_help,
                                             help=start_help)
    subcommand_start.set_defaults(callback=start)
    subcommand_start.add_argument(
        "--no-browser",
        action="store_true",
        help="Do not launch the default web browser.",
    )
    subcommand_start.add_argument(
        "--debug-email",
        action="store_true",
        help="Change the email backend to console output.",
    )
    subcommand_start.add_argument(
        "--no-template-caching",
        action="store_true",
        default=False,
        help="Disables caching of templates.",
    )
    subcommand_start.add_argument(
        "--host",
        action="store",
        default="0.0.0.0",
        help="IP address to listen on. Default is 0.0.0.0.",
    )
    subcommand_start.add_argument(
        "--port",
        action="store",
        default="8000",
        help="Port to listen on. Default is 8000.",
    )
    subcommand_start.add_argument("--settings_dir",
                                  action="store",
                                  default=None,
                                  help="The settings directory.")
    subcommand_start.add_argument(
        "--settings_filename",
        action="store",
        default="settings.py",
        help=
        "The used settings file name. The file is created, if it does not exist.",
    )
    subcommand_start.add_argument(
        "--local-installation",
        action="store_true",
        help="Store settings and user files in a local directory.",
    )

    # Subcommand createsettings
    createsettings_help = "Creates the settings file."
    subcommand_createsettings = subparsers.add_parser(
        "createsettings",
        description=createsettings_help,
        help=createsettings_help)
    subcommand_createsettings.set_defaults(callback=createsettings)
    subcommand_createsettings.add_argument(
        "--settings_dir",
        action="store",
        default=None,
        help=
        "The used settings file directory. All settings files are created, even if they exist.",
    )
    subcommand_createsettings.add_argument(
        "--settings_filename",
        action="store",
        default="settings.py",
        help=
        "The used settings file name. The file is created, if it does not exist.",
    )
    subcommand_createsettings.add_argument(
        "--local-installation",
        action="store_true",
        help="Store settings and user files in a local directory.",
    )

    # 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 built-in webserver."),
    )
    for django_subcommand, help_text in django_subcommands:
        subparsers._choices_actions.append(  # type: ignore
            subparsers._ChoicesPseudoAction(  # type: ignore
                django_subcommand, (), help_text))

    return parser
Esempio n. 5
0
def get_parser():
    """
    Parses all command line arguments.
    """
    if len(sys.argv) == 1 and not is_development():
        sys.argv.append('start')

    # Init parser
    description = 'Start script for OpenSlides.'
    if 'manage.py' not in sys.argv[0]:
        description += (' If it is called without any argument, this will be '
                        'treated as if it is called with the "start" subcommand. '
                        'That means OpenSlides will setup default settings and '
                        'database, start the tornado webserver, launch the '
                        'default web browser and open the webinterface.')
    parser = ExceptionArgumentParser(description=description)

    # Add version argument
    parser.add_argument(
        '--version',
        action='version',
        version=openslides_version,
        help='Show version number and exit.')

    # Init subparsers
    subparsers = parser.add_subparsers(
        dest='subcommand',
        title='Available subcommands',
        description="Type '%s <subcommand> --help' for help on a "
                    "specific subcommand." % parser.prog,
        help='You can choose only one subcommand at once.')

    # Subcommand start
    subcommand_start = subparsers.add_parser(
        'start',
        help='Setup settings and database, start tornado webserver, launch the '
             'default web browser and open the webinterface. The environment '
             'variable DJANGO_SETTINGS_MODULE is ignored.')
    subcommand_start.add_argument(
        '--no-browser',
        action='store_true',
        help='Do not launch the default web browser.')
    subcommand_start.add_argument(
        '--settings_path',
        action='store',
        default=None,
        help='The used settings file. The file is created, if it does not exist.')
    subcommand_start.set_defaults(callback=start)
    subcommand_start.add_argument(
        '--development',
        action='store_true',
        help='Command for development purposes.')

    # Subcommand createsettings
    subcommand_createsettings = subparsers.add_parser(
        'createsettings',
        help='Create the settings file.')
    subcommand_createsettings.set_defaults(callback=createsettings)
    subcommand_createsettings.add_argument(
        '--settings_path',
        action='store',
        default=None,
        help='The used settings file. The file is created, even if it exists.')
    subcommand_createsettings.add_argument(
        '--development',
        action='store_true',
        help='Command for development purposes.')

    return parser
Esempio n. 6
0
def get_parser():
    """
    Parses all command line arguments.
    """
    if len(sys.argv) == 1:
        # Use start subcommand if called by openslides console script without
        # any other arguments.
        sys.argv.append("start")

    # Init parser
    description = "Start script for OpenSlides."
    if "manage.py" not in sys.argv[0]:
        description += """
            If it is called without any argument, this will be treated as
            if it is called with the 'start' subcommand. That means
            OpenSlides will setup default settings and database, start the
            webserver, launch the default web browser and open the
            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
    parser.add_argument(
        "--version",
        action="version",
        version=openslides.__version__,
        help="Show version number and exit.",
    )

    # Init subparsers
    subparsers = parser.add_subparsers(
        dest="subcommand",
        title="Available subcommands",
        description="Type '%s <subcommand> --help' for help on a "
        "specific subcommand." % parser.prog,  # type: ignore
        help="You can choose only one subcommand at once.",
        metavar="",
    )

    # Subcommand start
    start_help = (
        "Setup settings and database, start webserver, launch the "
        "default web browser and open the webinterface. The environment "
        "variable DJANGO_SETTINGS_MODULE is ignored."
    )
    subcommand_start = subparsers.add_parser(
        "start", description=start_help, help=start_help
    )
    subcommand_start.set_defaults(callback=start)
    subcommand_start.add_argument(
        "--no-browser",
        action="store_true",
        help="Do not launch the default web browser.",
    )
    subcommand_start.add_argument(
        "--debug-email",
        action="store_true",
        help="Change the email backend to console output.",
    )
    subcommand_start.add_argument(
        "--no-template-caching",
        action="store_true",
        default=False,
        help="Disables caching of templates.",
    )
    subcommand_start.add_argument(
        "--host",
        action="store",
        default="0.0.0.0",
        help="IP address to listen on. Default is 0.0.0.0.",
    )
    subcommand_start.add_argument(
        "--port",
        action="store",
        default="8000",
        help="Port to listen on. Default is 8000.",
    )
    subcommand_start.add_argument(
        "--settings_dir", action="store", default=None, help="The settings directory."
    )
    subcommand_start.add_argument(
        "--settings_filename",
        action="store",
        default="settings.py",
        help="The used settings file name. The file is created, if it does not exist.",
    )
    subcommand_start.add_argument(
        "--local-installation",
        action="store_true",
        help="Store settings and user files in a local directory.",
    )

    # Subcommand createsettings
    createsettings_help = "Creates the settings file."
    subcommand_createsettings = subparsers.add_parser(
        "createsettings", description=createsettings_help, help=createsettings_help
    )
    subcommand_createsettings.set_defaults(callback=createsettings)
    subcommand_createsettings.add_argument(
        "--settings_dir",
        action="store",
        default=None,
        help="The used settings file directory. All settings files are created, even if they exist.",
    )
    subcommand_createsettings.add_argument(
        "--settings_filename",
        action="store",
        default="settings.py",
        help="The used settings file name. The file is created, if it does not exist.",
    )
    subcommand_createsettings.add_argument(
        "--local-installation",
        action="store_true",
        help="Store settings and user files in a local directory.",
    )

    # 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 built-in webserver."),
    )
    for django_subcommand, help_text in django_subcommands:
        subparsers._choices_actions.append(  # type: ignore
            subparsers._ChoicesPseudoAction(  # type: ignore
                django_subcommand, (), help_text
            )
        )

    return parser