8.4. Manage the CRATE web server

The CRATE web front end uses Django, which comes with a number of built-in management comments; to these, CRATE adds some more. All are available as subcommands of

crate_django_manage

The available commands are:

Loading local settings from: /home/rudolf/Documents/code/crate/secret_local_settings/crateweb_rudolf_config.py

Type 'crate_django_manage help <subcommand>' for help on a specific subcommand.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[consent]
    email_rdbm
    fetch_optouts
    lookup_consent
    lookup_patient
    populate
    resubmit_unprocessed_tasks
    test_email

[contenttypes]
    remove_stale_contenttypes

[core]
    runcpserver

[debug_toolbar]
    debugsqlshell

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    inspectdb
    loaddata
    makemessages
    makemigrations
    migrate
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[django_extensions]
    admin_generator
    clean_pyc
    clear_cache
    compile_pyc
    create_app
    create_command
    create_jobs
    create_template_tags
    delete_squashed_migrations
    describe_form
    drop_test_database
    dumpscript
    export_emails
    find_template
    generate_password
    generate_secret_key
    graph_models
    mail_debug
    merge_model_instances
    notes
    passwd
    pipchecker
    print_settings
    print_user_for_session
    reset_db
    reset_schema
    runjob
    runjobs
    runprofileserver
    runscript
    runserver_plus
    set_default_site
    set_fake_emails
    set_fake_passwords
    shell_plus
    show_template_tags
    show_templatetags
    show_urls
    sqlcreate
    sqldiff
    sqldsn
    sync_s3
    syncdata
    unreferenced_files
    update_permissions
    validate_templates

[sessions]
    clearsessions

[sslserver]
    runsslserver

[staticfiles]
    collectstatic
    findstatic
    runserver

# Generated at 2019-10-10 10:23:48

Particularly relevant functions are as follows.

8.4.1. [auth]

8.4.1.1. changepassword

Change a user’s password from the command line.

Loading local settings from: /home/rudolf/Documents/code/crate/secret_local_settings/crateweb_rudolf_config.py
usage: crate_django_manage changepassword [-h] [--database DATABASE]
                                          [--version] [-v {0,1,2,3}]
                                          [--settings SETTINGS]
                                          [--pythonpath PYTHONPATH]
                                          [--traceback] [--no-color]
                                          [username]

Change a user's password for django.contrib.auth.

positional arguments:
  username              Username to change password for; by default, it's the
                        current username.

optional arguments:
  -h, --help            show this help message and exit
  --database DATABASE   Specifies the database to use. Default is "default".
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.

# Generated at 2019-10-10 10:23:51

8.4.1.2. createsuperuser

Create a superuser from the command line.

Loading local settings from: /home/rudolf/Documents/code/crate/secret_local_settings/crateweb_rudolf_config.py
usage: crate_django_manage createsuperuser [-h] [--username USERNAME]
                                           [--noinput] [--database DATABASE]
                                           [--email EMAIL] [--version]
                                           [-v {0,1,2,3}]
                                           [--settings SETTINGS]
                                           [--pythonpath PYTHONPATH]
                                           [--traceback] [--no-color]

Used to create a superuser.

optional arguments:
  -h, --help            show this help message and exit
  --username USERNAME   Specifies the login for the superuser.
  --noinput, --no-input
                        Tells Django to NOT prompt the user for input of any
                        kind. You must use --username with --noinput, along
                        with an option for any other required field.
                        Superusers created with --noinput will not be able to
                        log in until they're given a valid password.
  --database DATABASE   Specifies the database to use. Default is "default".
  --email EMAIL         Specifies the email for the superuser.
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.

# Generated at 2019-10-10 10:23:56

8.4.3. [core]

8.4.3.1. runcpserver

Launches the CherryPy web server.

Loading local settings from: /home/rudolf/Documents/code/crate/secret_local_settings/crateweb_rudolf_config.py
usage: crate_django_manage runcpserver [-h] [--host HOST] [--port PORT]
                                       [--server_name SERVER_NAME]
                                       [--threads THREADS]
                                       [--ssl_certificate SSL_CERTIFICATE]
                                       [--ssl_private_key SSL_PRIVATE_KEY]
                                       [--log_screen] [--no_log_screen]
                                       [--debug_static]
                                       [--root_path ROOT_PATH] [--version]
                                       [-v {0,1,2,3}] [--settings SETTINGS]
                                       [--pythonpath PYTHONPATH] [--traceback]
                                       [--no-color]

Run this project in a CherryPy webserver. To do this, CherryPy is required
(pip install cherrypy).

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           hostname to listen on (default: 127.0.0.1)
  --port PORT           port to listen on (default: 8088)
  --server_name SERVER_NAME
                        CherryPy's SERVER_NAME environ entry (default:
                        localhost)
  --threads THREADS     Number of threads for server to use (default: 10)
  --ssl_certificate SSL_CERTIFICATE
                        SSL certificate file (e.g. /etc/ssl/certs/ssl-cert-
                        snakeoil.pem)
  --ssl_private_key SSL_PRIVATE_KEY
                        SSL private key file (e.g. /etc/ssl/private/ssl-cert-
                        snakeoil.key)
  --log_screen          log access requests etc. to terminal (default)
  --no_log_screen       don't log access requests etc. to terminal
  --debug_static        show debug info for static file requests
  --root_path ROOT_PATH
                        Root path to serve CRATE at. Default: /crate
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.

# Generated at 2019-10-10 10:24:14

8.4.4. [staticfiles]

8.4.4.1. collectstatic

Copy relevant static files from their source location to the place that CRATE will serve them to users (or another front-end server, like Apache, will on its behalf). Needs to be run as part of site setup.

Loading local settings from: /home/rudolf/Documents/code/crate/secret_local_settings/crateweb_rudolf_config.py
usage: crate_django_manage collectstatic [-h] [--noinput] [--no-post-process]
                                         [-i PATTERN] [-n] [-c] [-l]
                                         [--no-default-ignore] [--version]
                                         [-v {0,1,2,3}] [--settings SETTINGS]
                                         [--pythonpath PYTHONPATH]
                                         [--traceback] [--no-color]

Collect static files in a single location.

optional arguments:
  -h, --help            show this help message and exit
  --noinput, --no-input
                        Do NOT prompt the user for input of any kind.
  --no-post-process     Do NOT post process collected files.
  -i PATTERN, --ignore PATTERN
                        Ignore files or directories matching this glob-style
                        pattern. Use multiple times to ignore more.
  -n, --dry-run         Do everything except modify the filesystem.
  -c, --clear           Clear the existing files using the storage before
                        trying to copy or link the original file.
  -l, --link            Create a symbolic link to each file instead of
                        copying.
  --no-default-ignore   Don't ignore the common private glob-style patterns
                        (defaults to 'CVS', '.*' and '*~').
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.

# Generated at 2019-10-10 10:23:53

8.4.4.2. runserver

Launches the Django test web server.

Loading local settings from: /home/rudolf/Documents/code/crate/secret_local_settings/crateweb_rudolf_config.py
usage: crate_django_manage runserver [-h] [--ipv6] [--nothreading]
                                     [--noreload] [--nostatic] [--insecure]
                                     [--version] [-v {0,1,2,3}]
                                     [--settings SETTINGS]
                                     [--pythonpath PYTHONPATH] [--traceback]
                                     [--no-color]
                                     [addrport]

Starts a lightweight Web server for development and also serves static files.

positional arguments:
  addrport              Optional port number, or ipaddr:port

optional arguments:
  -h, --help            show this help message and exit
  --ipv6, -6            Tells Django to use an IPv6 address.
  --nothreading         Tells Django to NOT use threading.
  --noreload            Tells Django to NOT use the auto-reloader.
  --nostatic            Tells Django to NOT automatically serve static files
                        at STATIC_URL.
  --insecure            Allows serving static files even if DEBUG is False.
  --version             show program's version number and exit
  -v {0,1,2,3}, --verbosity {0,1,2,3}
                        Verbosity level; 0=minimal output, 1=normal output,
                        2=verbose output, 3=very verbose output
  --settings SETTINGS   The Python path to a settings module, e.g.
                        "myproject.settings.main". If this isn't provided, the
                        DJANGO_SETTINGS_MODULE environment variable will be
                        used.
  --pythonpath PYTHONPATH
                        A directory to add to the Python path, e.g.
                        "/home/djangoprojects/myproject".
  --traceback           Raise on CommandError exceptions
  --no-color            Don't colorize the command output.

# Generated at 2019-10-10 10:24:16