Overwatch Receiver Package (overwatch.receiver package)

General information from the README is available immediately below. Further module specific documentation is available further below in the package reference, with the modules listed below.

Package reference

overwatch.receiver.dqmReceiver module

WSGI Server for handling POST requests containing DQM data.

This module defines a REST API for receiving files via POST request. It is a relatively simple module.

exception overwatch.receiver.dqmReceiver.InvalidUsage(message, status_code=None, payload=None)[source]

Bases: exceptions.Exception

Provide an expressive error message for invalid REST API usage.

This allows us to raise an exception which contains a message, as well as a possible payload, returning that information to inform them about the issue.

Parameters:
  • message (str) – Message to accompany the error.
  • status_code (int) – HTTP status code which should be returned. Default: 400.
  • payload (dict) – Additional information relevant to the error that should be provided.
status_code

The HTTP status code to return. We send 400, as this class corresponds to an error.

Type:int
status_code = 400
to_dict()[source]
overwatch.receiver.dqmReceiver.checkForToken(func)[source]

Check for a special token in the request header to identify it as a known request.

This basically serves as a rudimentary identification function. However, it doesn’t need to be sophisticated for our purposes.

Parameters:func (function) – Routing function to be wrapped.
Returns:Wrapped function.
Return type:Any
overwatch.receiver.dqmReceiver.dqm(*args, **kwargs)[source]

Receive files from the DQM system.

For further information on the REST API (which is partially defined here), see the DQM receiver README. It contains a comprehensive description of the APIs described here.

Parameters:A complex set of header is required, as is the file. For more information on these requirements, (None.) – see the API reference.
Returns:
JSON based response which contains information about the file received, or the error messages.
See the API reference for a comprehensive description of the possible responses.
Return type:Response
overwatch.receiver.dqmReceiver.handleInvalidUsage(error)[source]

Error handler which converts the InvalidUsage exception into a response.

The idea here is that an exception is not meaningful for flask - it doesn’t know how to return it to the user. To address this issue, this function converts the InvalidUsage into something that is understandable and can be returned to the user.

Parameters:error (InvalidUsage) – The exception which we want to raise.
Returns:Response containing information about the error.
Return type:Response
overwatch.receiver.dqmReceiver.index(*args, **kwargs)[source]

General redirect if a request is sent to the root route.

It is an invalid request, so we just notify the user. Note that a token is still required to get to the invalid usage redirect. This means it can be a useful way to check if the token is being passed properly.

Parameters:None.
Returns:None.
Raises:InvalidUsage – Any request here is invalid, so it is always raised.
overwatch.receiver.dqmReceiver.receivedObjectInfo(outputPath)[source]

Print the ROOT objects in a received file.

Helper function to confirm that the file was transferred successfully by reading the objects contained within.

Parameters:outputPath (str) – Name of the file.
Returns:
(bool, dict). The bool is True if we were successful in opening the file. The dict contains
information on the objects available in the file. The keys (str) are the object names, while the values (str) are descriptions of the objects in the file, including the filename and the type of object.
Return type:tuple
overwatch.receiver.dqmReceiver.returnFile(*args, **kwargs)[source]

Return the ROOT file which was previously sent to the receiver.

For further information on the REST API (which is partially defined here), see the DQM receiver README. It contains a comprehensive description of the APIs described here.

Parameters:filename (str) – Name of desired file.
Returns:The requested file.
Return type:Response

overwatch.receiver.run module

overwatch.receiver.run.runDevelopment()[source]

Main entry point for running the DQM receiver development server.

Parameters:None.
Returns:None.