15.2.87. camcops_server.camcops_server

camcops_server/camcops_server.py


Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

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 <https://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: Optional[str] = None, type: Optional[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: Optional[bool] = 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() int[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.display_top(snapshot: tracemalloc.Snapshot, key_type: str = 'lineno', limit: int = 10, short_filename: bool = False) None[source]

Display e.g. lines of code allocating the most memory.

Parameters
  • snapshot – a tracemalloc.Snapshot object

  • key_type – thing to group by

  • limit – show the top n

  • short_filename – make source code filenames shorter?

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() None[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(rootpath: str) None[source]

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

camcops_server.camcops_server.print_demo_camcops_config(docker: bool = False) None[source]

Prints a demonstration config file to stdout.

camcops_server.camcops_server.print_demo_supervisor_config() None[source]

Prints a demonstration supervisord config file to stdout.