def dispatch(self, parent): """ sarracenia dispatcher :param parent: `sarra.sr_subscribe.sr_subscribe` :returns: `bool` of dispatch result """ from geomet_data_registry import env from geomet_data_registry.log import setup_logger setup_logger(env.LOGGING_LOGLEVEL, env.LOGGING_LOGFILE) try: from geomet_data_registry.handler.core import CoreHandler filepath = parent.msg.local_file parent.logger.debug('Filepath: {}'.format(filepath)) handler = CoreHandler(filepath) result = handler.handle() parent.logger.debug('Result: {}'.format(result)) return True except Exception as err: parent.logger.warning(err) return False
def add_data(ctx, file_, directory, verify=False): """add data to system""" if all([file_ is None, directory is None]): raise click.ClickException('Missing --file/-f or --dir/-d option') files_to_process = [] if file_ is not None: files_to_process = [file_] elif directory is not None: for root, dirs, files in os.walk(directory): for f in files: files_to_process.append(os.path.join(root, f)) for file_to_process in files_to_process: handler = CoreHandler(file_to_process) result = handler.handle() if result: click.echo('File properties: {}'.format( json_pretty_print(handler.layer_plugin.items)))