def main(): # init conf and logging conf = cfg.CONF conf.register_cli_opts(config.OPTS) conf.register_cli_opts(OPTS) conf.register_opts(config.OPTS) conf.register_opts(OPTS) conf() logging.setup('spectrometer') LOG.info('Logging enabled') runtime_storage_inst = runtime_storage.get_runtime_storage( cfg.CONF.runtime_storage_uri) filename = cfg.CONF.file if cfg.CONF.reverse: if filename: fd = open(filename, 'r') else: fd = sys.stdin import_data(runtime_storage_inst, fd) else: if filename: fd = open(filename, 'w') else: fd = sys.stdout export_data(runtime_storage_inst, fd)
def get_vault(): vault = getattr(flask.current_app, 'spectrometer_vault', None) if not vault: try: vault = {} runtime_storage_inst = runtime_storage.get_runtime_storage( cfg.CONF.runtime_storage_uri) vault['runtime_storage'] = runtime_storage_inst vault['memory_storage'] = memory_storage.get_memory_storage( memory_storage.MEMORY_STORAGE_CACHED) flask.current_app.spectrometer_vault = vault except Exception as e: LOG.critical('Failed to initialize application: %s', e) LOG.exception(e) flask.abort(500) time_now = utils.date_to_timestamp('now') may_update_by_time = (time_now > vault.get('vault_update_time', 0) + cfg.CONF.dashboard_update_interval) if (may_update_by_time and not getattr(flask.request, 'spectrometer_updated', None)): flask.request.spectrometer_updated = True vault['vault_update_time'] = time_now memory_storage_inst = vault['memory_storage'] have_updates = memory_storage_inst.update( compact_records(vault['runtime_storage'].get_update(os.getpid()))) vault['runtime_storage_update_time'] = ( vault['runtime_storage'].get_by_key('runtime_storage_update_time')) if have_updates: vault['cache'] = {} vault['cache_size'] = 0 _init_releases(vault) _init_module_groups(vault) _init_project_types(vault) _init_user_index(vault) return vault
def main(): # init conf and logging conf = cfg.CONF conf.register_cli_opts(config.OPTS) conf.register_opts(config.OPTS) conf() logging.setup('spectrometer') LOG.info('Logging enabled') runtime_storage_inst = runtime_storage.get_runtime_storage( cfg.CONF.runtime_storage_uri) default_data = utils.read_json_from_uri(cfg.CONF.default_data_uri) if not default_data: LOG.critical('Unable to load default data') return not 0 default_data_processor.process(runtime_storage_inst, default_data, cfg.CONF.sources_root, cfg.CONF.force_update) process_program_list(runtime_storage_inst, cfg.CONF.program_list_uri) update_pids(runtime_storage_inst) record_processor_inst = record_processor.RecordProcessor( runtime_storage_inst) update_records(runtime_storage_inst, record_processor_inst) apply_corrections(cfg.CONF.corrections_uri, runtime_storage_inst) # long operation should be the last update_members(runtime_storage_inst, record_processor_inst) runtime_storage_inst.set_by_key('runtime_storage_update_time', utils.date_to_timestamp('now'))