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
This commit is contained in:
Marcin Kuzminski 2018-03-01 16:42:35 +01:00
parent caa4a8a15d
commit 0d8040e6fa
4 changed files with 6 additions and 4 deletions

View file

@ -68,7 +68,7 @@ def main(ini_path, mode, user, user_id, key_id, shell, debug):
'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,

View file

@ -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'

View file

@ -95,7 +95,7 @@ def command(ini_path, force_yes, user, email, password, api_key, repos,
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))

View file

@ -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 = {}