Changeset - 44661d2a7b61
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 15 years ago 2011-02-27 00:31:43
marcin@python-works.com
fixes #120 websetup command runs os.access on given path checking for write access
2 files changed with 27 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/db_manage.py
Show inline comments
 
@@ -327,60 +327,83 @@ class DbManage(object):
 
            self.sa.add(dotencode_disable)
 
            self.sa.commit()
 
        except:
 
            self.sa.rollback()
 
            raise
 

	
 

	
 
    def create_ldap_options(self):
 
        """Creates ldap settings"""
 

	
 
        try:
 
            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)
 
            self.sa.commit()
 
        except:
 
            self.sa.rollback()
 
            raise
 

	
 
    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:
 
            log.info('Setting up repositories config')
 

	
 
        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):
 
            path_ok = False
 

	
 
            log.error('No write permission to given path: %s [%s/3]',
 
                      path, retries)
 

	
 

	
 
        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 = '/'
 

	
rhodecode/websetup.py
Show inline comments
 
@@ -19,36 +19,36 @@
 
# 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)
 

	
 

	
 

	
 

	
 

	
0 comments (0 inline, 0 general)