Пример #1
0
    def __init__(self, **args):
        logdebug(LOGGER, 'Constructor for Publication assistant for dataset "%s", version "%s" at host "%s".',
            args['drs_id'],
            args['version_number'],
            args['data_node']
        )

        # Check args
        mandatory_args = ['drs_id', 'version_number', 'data_node', 'prefix',
                          'thredds_service_path', 'is_replica', 'coupler',
                          'consumer_solr_url']
        optional_args = []
        utils.check_presence_of_mandatory_args(args, mandatory_args)
        utils.add_missing_optional_args_with_value_none(args, optional_args)
        self.__enforce_integer_version_number(args)
        self.__enforce_boolean_replica_flag(args)

        # Init methods...
        self.__store_args_in_attributes(args)
        self.__define_other_attributes()
        self.__create_and_store_dataset_handle()
        self.__init_state_machine()

        logdebug(LOGGER, 'Done: Constructor for Publication assistant for dataset "%s", version "%i" at host "%s".',
            args['drs_id'],
            args['version_number'],
            args['data_node']
        )
Пример #2
0
    def add_file(self, **args):
        '''
        Adds a file's information to the set of files to be
        published in this dataset.

        :param file_name: Mandatory. The file name (string).
            This information will simply be included in the
            PID record, but not used for anything.

        :param file_handle: Mandatory. The handle (PID) of
            this file (string). It is included in the file's netcdf
            header. It must bear the prefix that this library 
            (or rather, the consuming servlet that will consume
            this library's requests), has write access to.

        :param file_size: Mandatory. The file size (as string or
            integer. Will be transformed to integer). This
            information will be included in the handle record
            and used for consistency checks during republications
            of files with the same handle.

        :param checksum: Mandatory. The file's checksum. This
            information will be included in the handle record
            and used for consistency checks during republications
            of files with the same handle.

        :param checksum_type: Mandatory. The checksum type/method
            (string), e.g. "MD5" or "SHA256". This information will
            be included in the handle record and used for consistency
            checks during republications of files with the same handle.

        :param publish_path: Mandatory. The THREDDS publish path as
            a string. This is part of the URL for accessing the file,
            which will be part of the handle record. It will not be
            accessed, neither by the library nor by the consumer.
            The URL consists of the dataset's "data_node", the dataset's 
            "thredds_service_path", and this "publish_path". Redundant
            slashes are removed. If the URL does not start with "http",
            "http://" is added.

        :param file_version: Mandatory. Any string. File versions
            are not managed in the PID. This information will simply be
            included in the PID record, but not used for any reasoning.
        '''

        # Check if allowed:
        self.__check_if_adding_files_allowed_right_now()

        # Check if args ok:
        mandatory_args = ['file_name', 'file_handle', 'file_size',
                          'checksum', 'publish_path', 'checksum_type',
                          'file_version']
        utils.check_presence_of_mandatory_args(args, mandatory_args)
        self.__enforce_integer_file_size(args)
        self.__enforce_string_file_version(args)

        # Add file:
        self.__check_and_correct_handle_syntax(args)
        self.__add_file(**args)
Пример #3
0
 def __init__(self, **args):
     mandatory_args = ['connector']
     optional_args = ['print_to_console', 'print_success_to_console']
     check_presence_of_mandatory_args(args, mandatory_args)
     add_missing_optional_args_with_value_none(args, optional_args)
     self.__define_all_attributes()
     self.__fill_all_attributes(args)
     self.connection = None
     self.channel = None
     self.channel_ok = False