# HG changeset patch # User Marcin Kuzminski # Date 2018-03-01 15:42:35 # Node ID 95f21d331145b62f7ad092256f42db6432ca3e76 # Parent 3a525687644b5fa290a729e00cb64aa7798b9674 bootstrap: allow setting certain env flags for usage in CLI scripts. - we can catch that later in pyramid and skip certain heavy actions to speed-up CLI invokation diff --git a/rhodecode/apps/ssh_support/lib/ssh_wrapper.py b/rhodecode/apps/ssh_support/lib/ssh_wrapper.py --- a/rhodecode/apps/ssh_support/lib/ssh_wrapper.py +++ b/rhodecode/apps/ssh_support/lib/ssh_wrapper.py @@ -68,7 +68,7 @@ def main(ini_path, mode, user, user_id, 'of this script.') connection_info = os.environ.get('SSH_CONNECTION', '') - with bootstrap(ini_path) as env: + with bootstrap(ini_path, env={'RC_CMD_SSH_WRAPPER': '1'}) as env: try: ssh_wrapper = SshWrapper( command, connection_info, mode, diff --git a/rhodecode/lib/pyramid_utils.py b/rhodecode/lib/pyramid_utils.py --- a/rhodecode/lib/pyramid_utils.py +++ b/rhodecode/lib/pyramid_utils.py @@ -36,7 +36,9 @@ def get_app_config(ini_path): return appconfig('config:{}'.format(ini_path), relative_to=os.getcwd()) -def bootstrap(config_uri, request=None, options=None): +def bootstrap(config_uri, request=None, options=None, env=None): + if env: + os.environ.update(env) config = get_config(config_uri) base_url = 'http://rhodecode.local' diff --git a/rhodecode/lib/rc_commands/setup_rc.py b/rhodecode/lib/rc_commands/setup_rc.py --- a/rhodecode/lib/rc_commands/setup_rc.py +++ b/rhodecode/lib/rc_commands/setup_rc.py @@ -95,7 +95,7 @@ def command(ini_path, force_yes, user, e dbmanage.populate_default_permissions() Session().commit() - with bootstrap(ini_path) as env: + with bootstrap(ini_path, env={'RC_CMD_SETUP_RC': '1'}) as env: msg = 'Successfully initialized database, schema and default data.' print() print('*' * len(msg)) diff --git a/rhodecode/lib/rc_commands/upgrade_db.py b/rhodecode/lib/rc_commands/upgrade_db.py --- a/rhodecode/lib/rc_commands/upgrade_db.py +++ b/rhodecode/lib/rc_commands/upgrade_db.py @@ -40,7 +40,7 @@ def main(ini_path, force_yes): def command(ini_path, force_yes): pyramid.paster.setup_logging(ini_path) - with bootstrap(ini_path) as env: + with bootstrap(ini_path, env={'RC_CMD_UPGRADE_DB': '1'}) as env: config = env['registry'].settings db_uri = config['sqlalchemy.db1.url'] options = {}