14.2.30. camcops_server.camcops_server

camcops_server/camcops_server.py


Copyright (C) 2012-2019 Rudolf Cardinal (rudolf@pobox.com).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <http://www.gnu.org/licenses/>.


Command-line entry point for the CamCOPS server.

camcops_server.camcops_server.add_req_named(sp: argparse.ArgumentParser, switch: str, help: str, action: str = None, type: Type = None) → None[source]

Adds a required but named argument. This is a bit unconventional; for example, making the --config option mandatory even though -- is usually a prefix for optional arguments.

Parameters:
  • sp – the ArgumentParser to add to
  • switch – passed to add_argument()
  • help – passed to add_argument()
  • action – passed to add_argument()
  • type – passed to add_argument()
camcops_server.camcops_server.add_sub(sp: _SubParsersAction, cmd: str, config_mandatory: Union[bool, NoneType] = False, description: str = None, help: str = None) → argparse.ArgumentParser[source]

Adds (and returns) a subparser to an ArgumentParser.

Parameters:
  • sp – the _SubParsersAction object from a call to argparse.ArgumentParser.add_subparsers().
  • cmd – the command for the subparser (e.g. docs to make the command camcops docs).
  • config_mandatory – Does this subcommand require a CamCOPS config file? None = don’t ask for config. False = ask for it, but not mandatory as a command-line argument. True = mandatory as a command-line argument.
  • description – Used for the description in the detailed help, e.g. “camcops docs –help”. Defaults to the value of the help argument.
  • help – Used for this subparser’s contribution to the main help summary, i.e. camcops --help.
Returns:

the subparser

camcops_server.camcops_server.camcops_main() → None[source]

Primary command-line entry point. Parse command-line arguments and act.

Note that we can’t easily use delayed imports to speed up the help output, because the help system has function calls embedded into it.

camcops_server.camcops_server.launch_manual() → None[source]

Use the operating system “launch something” tool to show the CamCOPS documentation.

camcops_server.camcops_server.main()[source]

Command-line entry point. Calls camcops_main().

camcops_server.camcops_server.make_wsgi_app_from_config() → Router[source]

Reads the config file and creates a WSGI application.

camcops_server.camcops_server.print_demo_apache_config() → None[source]

Prints a demonstration Apache HTTPD config file segment (for CamCOPS) to stdout.

camcops_server.camcops_server.print_demo_camcops_config() → None[source]

Prints a demonstration config file to stdout.

camcops_server.camcops_server.print_demo_mysql_create_db() → None[source]

Prints a demonstration MySQL database creation script to stdout.

camcops_server.camcops_server.print_demo_mysql_dump_script() → None[source]

Prints a demonstration MySQL database dump script to stdout.

camcops_server.camcops_server.print_demo_supervisor_config() → None[source]

Prints a demonstration supervisord config file to stdout.