def main(): """ Main function: start Flask web server """ parser = argparse.ArgumentParser(description='Mongo DB Backup Script') parser.add_argument('--mode', help='Use production (prod) or development (dev) section of config', choices=['prod', 'dev'], required=True) parser.add_argument('--config', default='config.cfg', help='Specify non standard config file name') parser.add_argument('--output', help='Specify directory where output should be put', required=True) parser.add_argument('--db', help='Database name', required=True) parser.add_argument('--collections', help='Comma separated list of collections to back-up', required=True) args = vars(parser.parse_args()) config = Config.load('../' + args.get('config'), args.get('mode')) database_auth = config['database_auth'] output_dir = args['output'] db_name = args['db'] collections = args['collections'].split(',') dump_documents(database_auth, output_dir, db_name, collections)
def main(): """ Main function: start Flask web server """ parser = argparse.ArgumentParser(description='ReReco Machine') parser.add_argument('--mode', help='Use production (prod) or development (dev) section of config', choices=['prod', 'dev'], required=True) parser.add_argument('--config', default='config.cfg', help='Specify non standard config file name') parser.add_argument('--debug', help='Run Flask in debug mode', action='store_true') args = vars(parser.parse_args()) config = Config.load(args.get('config'), args.get('mode')) database_auth = config.get('database_auth') Database.set_database_name('rereco') if database_auth: Database.set_credentials_file(database_auth) Database.add_search_rename('requests', 'runs', 'runs<int>') Database.add_search_rename('requests', 'run', 'runs<int>') Database.add_search_rename('requests', 'workflows', 'workflows.name') Database.add_search_rename('requests', 'workflow', 'workflows.name') Database.add_search_rename('requests', 'output_dataset', 'output_datasets') Database.add_search_rename('requests', 'input_dataset', 'input.dataset') Database.add_search_rename('requests', 'input_request', 'input.request') Database.add_search_rename('requests', 'created_on', 'history.0.time') Database.add_search_rename('requests', 'created_by', 'history.0.user') Database.add_search_rename('subcampaigns', 'created_on', 'history.0.time') Database.add_search_rename('subcampaigns', 'created_by', 'history.0.user') Database.add_search_rename('tickets', 'created_on', 'history.0.time') Database.add_search_rename('tickets', 'created_by', 'history.0.user') Database.add_search_rename('tickets', 'subcampaign', 'steps.subcampaign') Database.add_search_rename('tickets', 'processing_string', 'steps.processing_string') debug = args.get('debug', False) port = int(config.get('port', 8002)) host = config.get('host', '0.0.0.0') logger = setup_logging(debug) if os.environ.get('WERKZEUG_RUN_MAIN') != 'true': # Do only once, before the reloader pid = os.getpid() logger.info('PID: %s', pid) with open('rereco.pid', 'w') as pid_file: pid_file.write(str(pid)) logger.info('Starting... Debug: %s, Host: %s, Port: %s', debug, host, port) app.run(host=host, port=port, threaded=True, debug=debug)
def main(): """ Main function: start Flask web server """ parser = argparse.ArgumentParser(description='RelVal Machine Script') parser.add_argument( '--mode', help='Use production (prod) or development (dev) section of config', choices=['prod', 'dev'], required=True) parser.add_argument('--config', default='config.cfg', help='Specify non standard config file name') args = vars(parser.parse_args()) config = Config.load('../' + args.get('config'), args.get('mode')) database_auth = config['database_auth'] port = int(config['port']) move_to_done(database_auth, port)