@@ -303,108 +303,131 @@ class DbManage(object):
hooks2.ui_key = hooks2_key
hooks2.ui_value = 'python:rhodecode.lib.hooks.repo_size'
hooks3 = RhodeCodeUi()
hooks3.ui_section = 'hooks'
hooks3.ui_key = 'pretxnchangegroup.push_logger'
hooks3.ui_value = 'python:rhodecode.lib.hooks.log_push_action'
hooks4 = RhodeCodeUi()
hooks4.ui_section = 'hooks'
hooks4.ui_key = 'preoutgoing.pull_logger'
hooks4.ui_value = 'python:rhodecode.lib.hooks.log_pull_action'
#For mercurial 1.7 set backward comapatibility with format
dotencode_disable = RhodeCodeUi()
dotencode_disable.ui_section = 'format'
dotencode_disable.ui_key = 'dotencode'
dotencode_disable.ui_value = 'false'
try:
self.sa.add(hooks1)
self.sa.add(hooks2)
self.sa.add(hooks3)
self.sa.add(hooks4)
self.sa.add(dotencode_disable)
self.sa.commit()
except:
self.sa.rollback()
raise
def create_ldap_options(self):
"""Creates ldap settings"""
for k in ['ldap_active', 'ldap_host', 'ldap_port', 'ldap_ldaps',
'ldap_tls_reqcert', 'ldap_dn_user', 'ldap_dn_pass',
'ldap_base_dn', 'ldap_filter', 'ldap_search_scope',
'ldap_attr_login', 'ldap_attr_firstname', 'ldap_attr_lastname',
'ldap_attr_email']:
setting = RhodeCodeSettings(k, '')
self.sa.add(setting)
def config_prompt(self, test_repo_path=''):
log.info('Setting up repositories config')
def config_prompt(self, test_repo_path='', retries=3):
if retries == 3:
if not self.tests and not test_repo_path:
path = raw_input('Specify valid full path to your repositories'
' you can change this later in application settings:')
else:
path = test_repo_path
path_ok = True
#check proper dir
if not os.path.isdir(path):
log.error('You entered wrong path: %s', path)
path_ok = False
log.error('Entered path is not a valid directory: %s [%s/3]',
path, retries)
#check write access
if not os.access(path, os.W_OK):
log.error('No write permission to given path: %s [%s/3]',
if retries == 0:
sys.exit()
if path_ok is False:
retries -= 1
return self.config_prompt(test_repo_path, retries)
return path
def create_settings(self, path):
self.create_ui_settings()
#HG UI OPTIONS
web1 = RhodeCodeUi()
web1.ui_section = 'web'
web1.ui_key = 'push_ssl'
web1.ui_value = 'false'
web2 = RhodeCodeUi()
web2.ui_section = 'web'
web2.ui_key = 'allow_archive'
web2.ui_value = 'gz zip bz2'
web3 = RhodeCodeUi()
web3.ui_section = 'web'
web3.ui_key = 'allow_push'
web3.ui_value = '*'
web4 = RhodeCodeUi()
web4.ui_section = 'web'
web4.ui_key = 'baseurl'
web4.ui_value = '/'
paths = RhodeCodeUi()
paths.ui_section = 'paths'
paths.ui_key = '/'
paths.ui_value = path
hgsettings1 = RhodeCodeSettings('realm', 'RhodeCode authentication')
hgsettings2 = RhodeCodeSettings('title', 'RhodeCode')
hgsettings3 = RhodeCodeSettings('ga_code', '')
self.sa.add(web1)
self.sa.add(web2)
self.sa.add(web3)
self.sa.add(web4)
self.sa.add(paths)
self.sa.add(hgsettings1)
self.sa.add(hgsettings2)
self.sa.add(hgsettings3)
# -*- coding: utf-8 -*-
"""
rhodecode.websetup
~~~~~~~~~~~~~~~~~~
Weboperations and setup for rhodecode
:created_on: Dec 11, 2010
:author: marcink
:copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
:license: GPLv3, see COPYING for more details.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# of the License or (at your opinion) any later version of the license.
#
# 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 General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import os
import logging
from rhodecode.config.environment import load_environment
from rhodecode.lib.db_manage import DbManage
log = logging.getLogger(__name__)
def setup_app(command, conf, vars):
"""Place any commands to setup rhodecode here"""
dbconf = conf['sqlalchemy.db1.url']
dbmanage = DbManage(log_sql=True, dbconf=dbconf, root=conf['here'], tests=False)
dbmanage.create_tables(override=True)
dbmanage.set_db_version()
dbmanage.config_prompt(None)
dbmanage.create_settings(dbmanage.config_prompt(None))
dbmanage.create_default_user()
dbmanage.admin_prompt()
dbmanage.create_permissions()
dbmanage.populate_default_permissions()
load_environment(conf.global_conf, conf.local_conf, initial=True)
Status change: