def main(): mappings = db_mappings.get_mappings() parse_config(mapping_choices=mappings.keys()) config.setup_logging() if not CONF.db: CONF.print_help() sys.exit(0) try: elk = ElasticSearchManager(mappings=mappings) if CONF.db.options.lower() == 'sync': elk.db_sync() elif CONF.db.options.lower() == 'update': elk.update_mappings() elif CONF.db.options.lower() == 'remove': elk.remove_mappings() elif CONF.db.options.lower() == 'show': elk.show_mappings() elif CONF.db.options.lower() == 'update-settings': elk.update_settings() else: raise Exception('Option {0} not found !'.format(CONF.db.options)) except Exception as e: LOG.error(e) print(e)
def main(): parse_config() config.setup_logging() if not CONF.db: CONF.print_help() sys.exit(0) try: db_driver = manager.get_db_driver(CONF.storage.driver, backend=CONF.storage.backend) if CONF.db.options.lower() == 'sync': db_driver.db_sync() elif CONF.db.options.lower() == 'update': db_driver.db_sync() elif CONF.db.options.lower() == 'remove': db_driver.db_remove() elif CONF.db.options.lower() == 'show': db_tables = db_driver.db_show() if db_tables: print(json.dumps(db_tables)) else: print("No Tables/Mappings found!") else: raise Exception('Option {0} not found !'.format(CONF.db.options)) except Exception as e: LOG.error(e) print(e)
def initialize_app(conf=None, name='main'): try: config.parse_args() config.setup_logging() except Exception as e: pass conf = config.find_paste_config() app = deploy.loadapp('config:%s' % conf, name=name) return app
def initialize_app(conf=None, name='main'): """ initializing app for paste to deploy it """ # register and parse arguments config.parse_args(args=sys.argv[1:]) # register logging opts config.setup_logging() # locate and load paste file conf = config.find_paste_config() app = deploy.loadapp('config:%s' % conf, name=name) return app
def main(): # setup opts config.parse_args() config.setup_logging() paste_conf = config.find_paste_config() # quick simple server for testing purposes or simple scenarios ip = CONF.get('bind_host', '0.0.0.0') port = CONF.get('bind_port', 9090) try: httpserver.serve( application=deploy.loadapp('config:%s' % paste_conf, name='main'), host=ip, port=port) message = _i18n._('Server listening on %(ip)s:%(port)s' % {'ip': ip, 'port': port}) _LOG.info(message) print(message) except KeyboardInterrupt: print(_i18n._("Thank You ! \nBye.")) sys.exit(0)
def main(): # setup opts config.parse_args(args=sys.argv[1:]) config.setup_logging() paste_conf = config.find_paste_config() # quick simple server for testing purposes or simple scenarios ip = CONF.get('bind_host', '0.0.0.0') port = CONF.get('bind_port', 9090) try: httpserver.serve(application=deploy.loadapp('config:%s' % paste_conf, name='main'), host=ip, port=port) message = (_i18n._('Server listening on %(ip)s:%(port)s') % { 'ip': ip, 'port': port }) _LOG.info(message) print(message) except KeyboardInterrupt: print(_i18n._("Thank You ! \nBye.")) sys.exit(0)