Exceptions handler documentation

  • Created on: 16.07.2019
  • Author: Ayoub Malek
class src.ExceptionsHandler.ExceptionsHandler(args, data)[source]

Bases: object

Handle all exceptions caused by incorrect commands.

args

dict – dictionray of command arguments.

data

pandas.DataFrame – loaded data from csv.

supported_actions

list – list of supported actions.

exception

dict – dictionary of the exception descriptions.

check_action()[source]

Check parsed action argument and raise exception if the action is not supported or if no action is provided.

check_args()[source]

Check parsed command arguments based on agent’s wave file and username.

check_device_id()[source]

Check parsed device id argument and raise exception if there is no such id in data.

check_measurement_name()[source]

Check parsed measurement name argument and raise error if no such measurement name in data.

check_timestamp()[source]

Check parsed timestamp arguments and raise exception in case of wrong format or wrong chronological order.

raise_exception(exception_key)[source]

Raise exception by printing the exception description and exiting.

Parameters:exception_key (str) – exception key associated with the exception’s description in the eceptions dictionary.
validate_timestamp(timestamp)[source]

Validate the timestamp format otherwise raise in exception.

Parameters:timestamp (str) – timestamp argument as a string.
Returns:parsed datetime object using the datetime library.
Return type:(datetime.datetime)