dquality.monitor

Please make sure the installation Pre-requisites are met.

The application monitors given directory for new/modified files of the given pattern. Each of the detected file is verified according to schema configuration and for each of the file several new processes are started, each process performing specific quality calculations.

The results will be sent to an EPICS PV (printed on screen for now).

Functions:

init(config) This function initializes global variables.
verify(conf, folder, num_files) This is the main function called when the verifier application starts.
directory(directory, patterns) This method monitors a directory given by the “directory” parameter.
dquality.monitor.init(config)[source]

This function initializes global variables. It gets values from the configuration file, evaluates and processes the values. If mandatory file or directory is missing, the script logs an error and exits.

Parameters:config (str) – configuration file name, including path
Returns:
  • logger (Logger) – logger instance
  • data_tags (dict) – a dictionary od data_type/hdf tag
  • limits (dictionary) – a dictionary containing limit values read from the configured ‘limit’ file
  • report_file (str) – a report file configured in a given configuration file
  • extensions (list) – a list containing extensions of files to be monitored read from the configuration file
dquality.monitor.verify(conf, folder, num_files)[source]

This is the main function called when the verifier application starts. The configuration and the directory to monitor are passed as parameters, as well as number of files that will be accepted. If the files to monitor for should have certain extension, a list of acceptable file extensions can be defined in a configuration file.

The function calls directory function that sets up the monitoring and returns notifier. After the monitoring is initialized, it starts a loop that reads the global “files” queue. If there is any new file, the file is removed and validate with data.verify function.

The loop is interrupted when all expected files produced results.

Parameters:
  • conf (str) – configuration file name including path
  • folder (str) – folder name to monitor
  • num_files (int) – expected number of files. This script will exit after detecting and processing given number of files.
Returns:

None

dquality.monitor.directory(directory, patterns)[source]

This method monitors a directory given by the “directory” parameter. It creates a notifier object. The notifier is registered to await the “CLOSE_WRITE” event on a new file that matches the “pattern” parameter. If there is no such event, it yields control on timeout, defaulted to 1 second. It returns the created notifier.

Parameters:
  • directory (str) – Directory to monitor
  • patterns (list) – A list of strings representing file extension. Closing matching files will generate event.
Returns:

None