def main(args): if platform.system() == 'Windows': _windows_fixes() handler = StoqServerCmdHandler() if not args: handler.cmd_help() return 1 cmd = args[0] args = args[1:] parser = get_option_parser() handler.add_options(cmd, parser) options, args = parser.parse_args(args) config = StoqConfig() filename = (options.filename if options.load_config and options.filename else APP_CONF_FILE) config.load(filename) # FIXME: This is called only when register_station=True. Without # this, db_settings would not be updated. We should fix it on Stoq config.get_settings() register_config(config) global SENTRY_URL, raven_client SENTRY_URL = config.get('Sentry', 'url') or SENTRY_URL raven_client = raven.Client(SENTRY_URL, release=stoqserver.version_str) setup_excepthook(SENTRY_URL) return handler.run_cmd(cmd, options, *args)
def setUp(self): super().setUp() register_config(StoqConfig()) app = bootstrap_app() app.testing = True self.client = app.test_client()
def main(args): handler = StoqServerCmdHandler() if not args: handler.cmd_help() return 1 cmd = args[0] args = args[1:] parser = get_option_parser() handler.add_options(cmd, parser) options, args = parser.parse_args(args) config = StoqConfig() filename = (options.filename if options.load_config and options.filename else APP_CONF_FILE) config.load(filename) # FIXME: This is called only when register_station=True. Without # this, db_settings would not be updated. We should fix it on Stoq config.get_settings() register_config(config) # FIXME: Maybe we should check_schema and load plugins here? setup(config=config, options=options, register_station=False, check_schema=False, load_plugins=True) handler.run_cmd(cmd, options, *args)
def main(args): # Do this as soon as possible so we can log any early traceback setup_excepthook() if platform.system() == 'Windows': _windows_fixes() handler = StoqServerCmdHandler() if not args: handler.cmd_help() return 1 cmd = args[0] args = args[1:] parser = get_option_parser() handler.add_options(cmd, parser) options, args = parser.parse_args(args) config = StoqConfig() filename = (options.filename if options.load_config and options.filename else APP_CONF_FILE) config.load(filename) # FIXME: This is called only when register_station=True. Without # this, db_settings would not be updated. We should fix it on Stoq config.get_settings() register_config(config) return handler.run_cmd(cmd, options, *args)
def _setup_test_environment(request): plugin_config = _get_plugin_configs(request.config) if plugin_config['skip_env_setup']: return stoq_config = StoqConfig() stoq_config.load_default() register_config(stoq_config) quick = plugin_config['quick_mode'] or _to_falsy( os.environ.get("STOQLIB_TEST_QUICK", None)) bootstrap_suite( address=os.environ.get("STOQLIB_TEST_HOSTNAME"), dbname=os.environ.get("STOQLIB_TEST_DBNAME"), port=int(os.environ.get("STOQLIB_TEST_PORT") or 0), username=os.environ.get("STOQLIB_TEST_USERNAME"), password=os.environ.get("STOQLIB_TEST_PASSWORD"), quick=quick, ) manager = get_plugin_manager() for plugin_name in plugin_config['extra_plugins']: _register_plugin(plugin_name) with stoqlib.api.new_store() as store: manager.install_plugin(store, plugin_name) manager.activate_plugin(plugin_name) plugin_cls = plugin_config['plugin_cls'] if plugin_cls: _install_plugin(plugin_cls)
def setUp(self): super().setUp() from stoqntk.ntkui import NtkUI register_config(StoqConfig()) self.plugin = NtkUI() app = bootstrap_app() app.testing = True self.client = app.test_client()
def setup_sentry(options): config = StoqConfig() filename = (options.filename if options.load_config and options.filename else APP_CONF_FILE) config.load(filename) # FIXME: This is called only when register_station=True. Without # this, db_settings would not be updated. We should fix it on Stoq config.get_settings() register_config(config) global SENTRY_URL, raven_client SENTRY_URL = config.get('Sentry', 'url') or SENTRY_URL raven_client = raven.Client(SENTRY_URL, release=stoqserver.version_str, transport=SilentTransport) setup_excepthook()
def setup(config=None, options=None, register_station=True, check_schema=True, load_plugins=True): """ Loads the configuration from arguments and configuration file. @param config: a StoqConfig instance @param options: a Optionparser instance @param register_station: if we should register the branch station. @param check_schema: if we should check the schema @param load_plugins: if we should load plugins for the system """ # NOTE: No GUI calls are allowed in here # If you change anything here, you need to verify that all # callsites are still working properly. # bin/stoq # bin/stoqdbadmin # python stoq/tests/runtest.py if options is None: parser = get_option_parser() options, args = parser.parse_args(sys.argv) if options.verbose: from kiwi.log import set_log_level set_log_level('stoq*', 0) setup_path() if config is None: config = StoqConfig() if options.filename: config.load(options.filename) else: config.load_default() config.set_from_options(options) register_config(config) if options and options.sqldebug: enable_debugging() from stoq.lib.applist import ApplicationDescriptions provide_utility(IApplicationDescriptions, ApplicationDescriptions(), replace=True) if register_station: try: default_store = get_default_store() except DatabaseError as e: error(e.short, str(e.msg)) config.get_settings().check_version(default_store) if check_schema: migration = StoqlibSchemaMigration() migration.check() if options and options.sqldebug: enable_debugging() set_current_branch_station(default_store, station_name=None) if load_plugins: from stoqlib.lib.pluginmanager import get_plugin_manager manager = get_plugin_manager() manager.activate_installed_plugins() if check_schema: default_store = get_default_store() if not default_store.table_exists('system_table'): error( _("Database schema error"), _("Table 'system_table' does not exist.\n" "Consult your database administrator to solve this problem.")) if check_schema: migration = StoqlibSchemaMigration() migration.check()
def setup(config=None, options=None, register_station=True, check_schema=True, load_plugins=True): """ Loads the configuration from arguments and configuration file. @param config: a StoqConfig instance @param options: a Optionparser instance @param register_station: if we should register the branch station. @param check_schema: if we should check the schema @param load_plugins: if we should load plugins for the system """ # NOTE: No GUI calls are allowed in here # If you change anything here, you need to verify that all # callsites are still working properly. # bin/stoq # bin/stoqdbadmin # python stoq/tests/runtest.py if options is None: parser = get_option_parser() options, args = parser.parse_args(sys.argv) if options.verbose: from kiwi.log import set_log_level set_log_level('stoq*', 0) setup_path() if config is None: config = StoqConfig() if options.filename: config.load(options.filename) else: config.load_default() config.set_from_options(options) register_config(config) if options and options.sqldebug: enable_debugging() from stoq.lib.applist import ApplicationDescriptions provide_utility(IApplicationDescriptions, ApplicationDescriptions(), replace=True) db_settings = config.get_settings() try: default_store = get_default_store() except DatabaseError as e: # Only raise an error if a database is actually required if register_station or load_plugins or check_schema: error(e.short, str(e.msg)) else: default_store = None if register_station: db_settings.check_version(default_store) if check_schema: migration = StoqlibSchemaMigration() migration.check() if options and options.sqldebug: enable_debugging() set_current_branch_station(default_store, station_name=None) if load_plugins: from stoqlib.lib.pluginmanager import get_plugin_manager manager = get_plugin_manager() manager.activate_installed_plugins() if check_schema: if not default_store.table_exists('system_table'): error( _("Database schema error"), _("Table 'system_table' does not exist.\n" "Consult your database administrator to solve this problem.")) if check_schema: migration = StoqlibSchemaMigration() migration.check()