DataFileDownloadDirectory

class openmsistream.DataFileDownloadDirectory(dirpath, config_path, topic_name, datafile_type=<class 'openmsistream.data_file_io.entity.download_data_file.DownloadDataFileToDisk'>, filepath_regex=None, **kwargs)

Bases: DataFileDirectory, DataFileChunkProcessor, Runnable

Class representing a directory into which files are being reconstructed.

Parameters:
  • dirpath (pathlib.Path) – Path to the directory where reconstructed files should be saved

  • config_path (pathlib.Path) – Path to the config file to use in defining the Broker connection and Consumers

  • topic_name (str) – Name of the topic to which the Consumers should be subscribed

  • datafile_type (DownloadDataFileToDisk, optional) – the type of data file that recognized files should be reconstructed as (must be a subclass of DownloadDataFileToDisk)

  • filepath_regex – If given, only messages associated with files whose paths match this regex will be consumed

Raises:

ValueError – if datafile_type is not a subclass of DownloadDataFileToDisk

ARGUMENT_PARSER_TYPE

alias of OpenMSIStreamArgumentParser

reconstruct()

Consumes messages and writes their data to disk using several parallel threads to reconstruct the files to which they correspond. Runs until the user inputs a command to shut it down.

Returns:

the total number of messages consumed

Return type:

int

Returns:

the total number of message processed (written to disk)

Return type:

int

Returns:

the total number of completely reconstructed files

Return type:

int

Returns:

paths of up to 50 most recently reconstructed files

Return type:

list

classmethod get_command_line_arguments()

Anything extending this class should be able to access the “treat_undecryptable_as_plaintext” flag

classmethod get_init_args_kwargs(parsed_args)

Get the list of init arguments and the dictionary of init keyword arguments for this class given a namespace of, for example, parsed arguments.

Parameters:

parsed_args (argparse.Namespace) – A namespace containing entries needed to determine the init args and kwargs for this class

Returns:

A list of init args

Returns:

A dictionary of init kwargs

classmethod run_from_command_line(args=None)

Run a DataFileDownloadDirectory directly from the command line

Calls reconstruct() on a DataFileDownloadDirectory defined by command line (or given) arguments

Parameters:

args (list, optional) – the list of arguments to send to the parser instead of getting them from sys.argv