##// END OF EJS Templates
docs: added newline
docs: added newline

File last commit:

r5647:8333bc7b default
r5656:629f48be default
Show More
utils.py
106 lines | 3.6 KiB | text/x-python | PythonLexer
core: updated copyright to 2024
r5608 # Copyright (C) 2010-2024 RhodeCode GmbH
project: added all source files and assets
r1 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import os
import platform
tests: fixed test suite for celery adoption
r5607 from rhodecode.lib.type_utils import str2bool
fix(bootstrap): fixed issues that lead to leaving rhodecode.local as a default setting which is now explicitly read from .ini config
r5430 DEFAULT_USER = 'default'
project: added all source files and assets
r1
def configure_vcs(config):
"""
Patch VCS config with some RhodeCode specific stuff
"""
from rhodecode.lib.vcs import conf
hooks: made the callback host configurable....
r2833 import rhodecode.lib.vcs.conf.settings
project: added all source files and assets
r1 conf.settings.BACKENDS = {
'hg': 'rhodecode.lib.vcs.backends.hg.MercurialRepository',
'git': 'rhodecode.lib.vcs.backends.git.GitRepository',
'svn': 'rhodecode.lib.vcs.backends.svn.SubversionRepository',
}
feat(configs): deprecared old hooks protocol and ssh wrapper....
r5496 conf.settings.HOOKS_PROTOCOL = config['vcs.hooks.protocol.v2']
hooks: made the callback host configurable....
r2833 conf.settings.HOOKS_HOST = config['vcs.hooks.host']
Martin Bornhold
config: Move vcs hooks protocol and direct call setting to vcs configure mehod.
r588 conf.settings.ALIASES[:] = config['vcs.backends']
conf.settings.SVN_COMPATIBLE_VERSION = config['vcs.svn.compatible_version']
project: added all source files and assets
r1
def initialize_database(config):
encryption: use common method to fetch encryption key for encrypted fields.
r261 from rhodecode.lib.utils2 import engine_from_config, get_encryption_key
feat(ssh-wrapper-speedup): major rewrite of code to address imports problem with ssh-wrapper-v2...
r5325 from rhodecode.model import init_model
project: added all source files and assets
r1 engine = engine_from_config(config, 'sqlalchemy.db1.')
encryption: use common method to fetch encryption key for encrypted fields.
r261 init_model(engine, encryption_key=get_encryption_key(config))
project: added all source files and assets
r1
tests: fixed test suite for celery adoption
r5607 def initialize_test_environment(settings):
skip_test_env = str2bool(os.environ.get('RC_NO_TEST_ENV'))
if skip_test_env:
return
project: added all source files and assets
r1
tests: fixed test suite for celery adoption
r5607 repo_store_path = os.environ.get('RC_TEST_ENV_REPO_STORE') or settings['repo_store.path']
db: Move initialization of test environment up to pyramid layer.
r116
Martin Bornhold
pytest: Unify create_test_* functions.
r215 from rhodecode.lib.utils import (
create_test_directory, create_test_database, create_test_repositories,
create_test_index)
git-lfs: create default LFS storage on new installation...
r1564
tests: fixed test suite for celery adoption
r5607 create_test_directory(repo_store_path)
create_test_database(repo_store_path, settings)
db: Move initialization of test environment up to pyramid layer.
r116 # test repos
tests: fixed test suite for celery adoption
r5607 create_test_repositories(repo_store_path, settings)
create_test_index(repo_store_path, settings)
db: Move initialization of test environment up to pyramid layer.
r116
project: added all source files and assets
r1 def get_vcs_server_protocol(config):
Martin Bornhold
config: Move vcs hooks protocol and direct call setting to vcs configure mehod.
r588 return config['vcs.server.protocol']
project: added all source files and assets
r1
def set_instance_id(config):
core: added option to prefix cache keys for usage in cluster.
r3006 """
Sets a dynamic generated config['instance_id'] if missing or '*'
E.g instance_id = *cluster-1 or instance_id = *
"""
project: added all source files and assets
r1
config['instance_id'] = config.get('instance_id') or ''
core: added option to prefix cache keys for usage in cluster.
r3006 instance_id = config['instance_id']
if instance_id.startswith('*') or not instance_id:
prefix = instance_id.lstrip('*')
project: added all source files and assets
r1 _platform_id = platform.uname()[1] or 'instance'
ops: make ping view return orderedDict, and make the platform-id expose variables
r4851 config['instance_id'] = '{prefix}uname:{platform}-pid:{pid}'.format(
prefix=prefix,
platform=_platform_id,
pid=os.getpid())
app: use simpler way to extract default_user_id, this will be now registered at server...
r4332
def get_default_user_id():
configs: refactor and updated for python3 migrations
r5060 from sqlalchemy import text
from rhodecode.model import meta
engine = meta.get_engine()
with meta.SA_Session(engine) as session:
fix(bootstrap): fixed issues that lead to leaving rhodecode.local as a default setting which is now explicitly read from .ini config
r5430 result = session.execute(text(
"SELECT user_id from users where username = :uname"
), {'uname': DEFAULT_USER})
fix: startup, report nicer error in case DB is damaged or empty when starting services
r5462 user = result.first()
if not user:
raise ValueError('Unable to retrieve default user data from DB')
user_id = user[0]
configs: refactor and updated for python3 migrations
r5060
app: use simpler way to extract default_user_id, this will be now registered at server...
r4332 return user_id