server package

server module

mindreader.server.server.post_snapshot()

Handles the post requests of the snapshots.

Raises
  • PermissionError – tried to save snapshot data to a path without a permission.

  • ConnectionError – connection to the message queue to lost.

mindreader.server.server.replace_large_data_with_metadata(snapshot: mindreader.objects.snapshot.Snapshot, context: mindreader.drivers.context.context.Context)

Saves the large parts of the snapshot to storage (i.e. images), and replaces them with metadata (path).

Parameters
  • snapshot – snapshot to process

  • context – initialized context object, to save the data

mindreader.server.server.run_server(host, port, publish=None, mq_url=None, data_dir=None)

Runs the server, waiting to receive snapshots and handles them, either by a self-made handler, or by posting them to the message queue.

To run with a self-handler, publish should be supplied (see parameter for details below). To register to queue, mq_url should be supplied. Only and exactly one should be supplied in a call, otherwise its an error.

Parameters
  • host – server host.

  • port – server port.

  • publish – handler for snapshots, a function that receive a (user, snapshot) and process them.

  • mq_url – a url to a message queue, to post snapshots on.

  • data_dir – if the message queue is used, some snapshot data may be saved to this directory. if not supplied, the default is the project root directory under ‘mindreader_internal_data’.

Raises
  • EnvironmentError – publish or mq_url were supplied in correctly.

  • ConnectionError – couldn’t connect to queue.

CLI

python -m mindreader.server

python -m mindreader.server [OPTIONS] COMMAND [ARGS]...

run-server

python -m mindreader.server run-server [OPTIONS] MQ_URL

Options

-h, --host <host>

Server host

-p, --port <port>

Server port

-d, --data-dir <data_dir>

Directory to save data generated by the server into

Arguments

MQ_URL

Required argument