@@ -9,25 +9,25 @@ from pylons.configuration import PylonsC
from pylons.error import handle_mako_error
# don't remove this import it does magic for celery
from rhodecode.lib import celerypylons
import rhodecode.lib.app_globals as app_globals
from rhodecode.config.routing import make_map
from rhodecode.lib import helpers
from rhodecode.lib.auth import set_available_permissions
from rhodecode.lib.utils import repo2db_mapper, make_ui, set_rhodecode_config,\
load_rcextensions
load_rcextensions, check_git_version
from rhodecode.lib.utils2 import engine_from_config, str2bool
from rhodecode.model import init_model
from rhodecode.model.scm import ScmModel
log = logging.getLogger(__name__)
def load_environment(global_conf, app_conf, initial=False):
"""
Configure the Pylons environment via the ``pylons.config``
object
@@ -77,24 +77,27 @@ def load_environment(global_conf, app_co
config['sqlalchemy.db1.url'] = os.environ.get('TEST_DB')
from rhodecode.lib.utils import create_test_env, create_test_index
from rhodecode.tests import TESTS_TMP_PATH
# set RC_NO_TMP_PATH=1 to disable re-creating the database and
# test repos
if not int(os.environ.get('RC_NO_TMP_PATH', 0)):
create_test_env(TESTS_TMP_PATH, config)
# set RC_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
if not int(os.environ.get('RC_WHOOSH_TEST_DISABLE', 0)):
create_test_index(TESTS_TMP_PATH, config, True)
#check git version
check_git_version()
# MULTIPLE DB configs
# Setup the SQLAlchemy database engine
sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
init_model(sa_engine_db1)
repos_path = make_ui('db').configitems('paths')[0][1]
repo2db_mapper(ScmModel().repo_scan(repos_path),
remove_obsolete=False, install_git_hook=False)
set_available_permissions(config)
config['base_path'] = repos_path
set_rhodecode_config(config)
# CONFIGURATION OPTIONS HERE (note: all config options will override
@@ -32,25 +32,25 @@ import platform
from sqlalchemy import func
from formencode import htmlfill
from pylons import request, session, tmpl_context as c, url, config
from pylons.controllers.util import abort, redirect
from pylons.i18n.translation import _
from rhodecode.lib import helpers as h
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
HasPermissionAnyDecorator, NotAnonymous
from rhodecode.lib.base import BaseController, render
from rhodecode.lib.celerylib import tasks, run_task
from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
set_rhodecode_config, repo_name_slug
set_rhodecode_config, repo_name_slug, check_git_version
from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \
RhodeCodeSetting, PullRequest, PullRequestReviewers
from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
ApplicationUiSettingsForm, ApplicationVisualisationForm
from rhodecode.model.user import UserModel
from rhodecode.model.db import User
from rhodecode.model.notification import EmailNotificationModel
from rhodecode.model.meta import Session
from rhodecode.lib.utils2 import str2bool
@@ -59,25 +59,26 @@ log = logging.getLogger(__name__)
class SettingsController(BaseController):
"""REST Controller styled on the Atom Publishing Protocol"""
# To properly map this controller, ensure your config/routing.py
# file has a resource setup:
# map.resource('setting', 'settings', controller='admin/settings',
# path_prefix='/admin', name_prefix='admin_')
@LoginRequired()
def __before__(self):
c.admin_user = session.get('admin_user')
c.admin_username = session.get('admin_username')
c.modules = sorted([(p.project_name, p.version)
for p in pkg_resources.working_set],
for p in pkg_resources.working_set]
+ [('git', check_git_version())],
key=lambda k: k[0].lower())
c.py_version = platform.python_version()
c.platform = platform.platform()
super(SettingsController, self).__before__()
@HasPermissionAllDecorator('hg.admin')
def index(self, format='html'):
"""GET /admin/settings: All items in the collection"""
# url('admin_settings')
defaults = RhodeCodeSetting.get_app_settings()
defaults.update(self._get_hg_ui_settings())
@@ -663,12 +663,47 @@ class BasePasterCommand(Command):
raise NotImplementedError("Abstract Method.")
def bootstrap_config(self, conf):
Loads the pylons configuration.
from pylons import config as pylonsconfig
self.path_to_ini_file = os.path.realpath(conf)
conf = paste.deploy.appconfig('config:' + self.path_to_ini_file)
pylonsconfig.init_app(conf.global_conf, conf.local_conf)
def check_git_version():
Checks what version of git is installed in system, and issues a warning
if it's to old for RhodeCode to properly work.
import subprocess
from distutils.version import StrictVersion
from rhodecode import BACKENDS
p = subprocess.Popen('git --version', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
ver = (stdout.split(' ')[-1] or '').strip() or '0.0.0'
try:
_ver = StrictVersion(ver)
except:
_ver = StrictVersion('0.0.0')
stderr = traceback.format_exc()
req_ver = '1.7.4'
to_old_git = False
if _ver <= StrictVersion(req_ver):
to_old_git = True
if 'git' in BACKENDS:
log.debug('GIT version detected: %s' % stdout)
if stderr:
log.warning('Unable to detect git version org error was:%r' % stderr)
elif to_old_git:
log.warning('RhodeCode detected git version %s, which is to old '
'for the system to function properly make sure '
'it is at least in version %s' % (ver, req_ver))
return _ver
\ No newline at end of file
Status change: