# HG changeset patch # User Marcin Kuzminski # Date 1337203033 -7200 # Node ID 393c53cbd0d841616f719c6e39eaf66e3483f0fd # Parent d932229a3b22cc76f27919651914b0d8a12d3e9d# Parent e285aa097a816925c5030f41250ed72760aa2a7c merge with beta diff -r d932229a3b22 -r 393c53cbd0d8 docs/changelog.rst --- a/docs/changelog.rst Wed May 16 19:01:55 2012 +0200 +++ b/docs/changelog.rst Wed May 16 23:17:13 2012 +0200 @@ -12,7 +12,10 @@ news ++++ - + + - new codereview system + - changed setup-app into setup-rhodecode and added default options to it. + fixes +++++ diff -r d932229a3b22 -r 393c53cbd0d8 docs/setup.rst --- a/docs/setup.rst Wed May 16 19:01:55 2012 +0200 +++ b/docs/setup.rst Wed May 16 23:17:13 2012 +0200 @@ -26,19 +26,20 @@ postgresql, sqlite and mysql databases. Create the database by running the following command:: - paster setup-app production.ini + paster setup-rhodecode production.ini This will prompt you for a "root" path. This "root" path is the location where RhodeCode will store all of its repositories on the current machine. After -entering this "root" path ``setup-app`` will also prompt you for a username -and password for the initial admin account which ``setup-app`` sets up for you. +entering this "root" path ``setup-rhodecode`` will also prompt you for a username +and password for the initial admin account which ``setup-rhodecode`` sets +up for you. -- The ``setup-app`` command will create all of the needed tables and an admin - account. When choosing a root path you can either use a new empty location, - or a location which already contains existing repositories. If you choose a - location which contains existing repositories RhodeCode will simply add all - of the repositories at the chosen location to it's database. (Note: make - sure you specify the correct path to the root). +- The ``setup-rhodecode`` command will create all of the needed tables and an + admin account. When choosing a root path you can either use a new empty + location, or a location which already contains existing repositories. If you + choose a location which contains existing repositories RhodeCode will simply + add all of the repositories at the chosen location to it's database. + (Note: make sure you specify the correct path to the root). - Note: the given path for mercurial_ repositories **must** be write accessible for the application. It's very important since the RhodeCode web interface will work without write access, but when trying to do a push it will @@ -51,8 +52,8 @@ - This command runs the RhodeCode server. The web app should be available at the 127.0.0.1:5000. This ip and port is configurable via the production.ini file created in previous step -- Use the admin account you created above when running ``setup-app`` to login - to the web app. +- Use the admin account you created above when running ``setup-rhodecode`` + to login to the web app. - The default permissions on each repository is read, and the owner is admin. Remember to update these if needed. - In the admin panel you can toggle ldap, anonymous, permissions settings. As diff -r d932229a3b22 -r 393c53cbd0d8 rhodecode/config/setup/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rhodecode/config/setup/__init__.py Wed May 16 23:17:13 2012 +0200 @@ -0,0 +1,87 @@ +import os +from paste.script.appinstall import AbstractInstallCommand +from paste.script.command import BadCommand +from paste.deploy import appconfig + + +class SetupCommand(AbstractInstallCommand): + + default_verbosity = 1 + max_args = 1 + min_args = 1 + summary = "Setup an application, given a config file" + usage = "CONFIG_FILE" + + description = """\ + Note: this is an experimental command, and it will probably change + in several ways by the next release. + + Setup an application according to its configuration file. This is + the second part of a two-phase web application installation + process (the first phase is prepare-app). The setup process may + consist of things like creating directories and setting up + databases. + """ + + parser = AbstractInstallCommand.standard_parser( + simulate=True, quiet=True, interactive=True) + parser.add_option('--user', + action='store', + dest='username', + default=None, + help='Admin Username') + parser.add_option('--email', + action='store', + dest='email', + default=None, + help='Admin Email') + parser.add_option('--password', + action='store', + dest='password', + default=None, + help='Admin password min 6 chars') + parser.add_option('--repos', + action='store', + dest='repos_location', + default=None, + help='Absolute path to repositories location') + parser.add_option('--name', + action='store', + dest='section_name', + default=None, + help='The name of the section to set up (default: app:main)') + + def command(self): + config_spec = self.args[0] + section = self.options.section_name + if section is None: + if '#' in config_spec: + config_spec, section = config_spec.split('#', 1) + else: + section = 'main' + if not ':' in section: + plain_section = section + section = 'app:'+section + else: + plain_section = section.split(':', 1)[0] + if not config_spec.startswith('config:'): + config_spec = 'config:' + config_spec + if plain_section != 'main': + config_spec += '#' + plain_section + config_file = config_spec[len('config:'):].split('#', 1)[0] + config_file = os.path.join(os.getcwd(), config_file) + self.logging_file_config(config_file) + conf = appconfig(config_spec, relative_to=os.getcwd()) + ep_name = conf.context.entry_point_name + ep_group = conf.context.protocol + dist = conf.context.distribution + if dist is None: + raise BadCommand( + "The section %r is not the application (probably a filter). " + "You should add #section_name, where section_name is the " + "section that configures your application" % plain_section) + installer = self.get_installer(dist, ep_group, ep_name) + installer.setup_config( + self, config_file, section, self.sysconfig_install_vars(installer)) + self.call_sysconfig_functions( + 'post_setup_hook', installer, config_file) \ No newline at end of file diff -r d932229a3b22 -r 393c53cbd0d8 rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py Wed May 16 19:01:55 2012 +0200 +++ b/rhodecode/lib/db_manage.py Wed May 16 23:17:13 2012 +0200 @@ -240,10 +240,15 @@ self.sa.rollback() raise - def admin_prompt(self, second=False): + def admin_prompt(self, second=False, defaults={}): if not self.tests: import getpass + # defaults + username = defaults.get('username') + password = defaults.get('password') + email = defaults.get('email') + def get_password(): password = getpass.getpass('Specify admin password ' '(min 6 chars):') @@ -257,17 +262,17 @@ return False return password - - username = raw_input('Specify admin username:') - - password = get_password() - if not password: - #second try + if username is None: + username = raw_input('Specify admin username:') + if password is None: password = get_password() if not password: - sys.exit() - - email = raw_input('Specify admin email:') + #second try + password = get_password() + if not password: + sys.exit() + if email is None: + email = raw_input('Specify admin email:') self.create_user(username, password, email, True) else: log.info('creating admin and regular test users') @@ -372,11 +377,14 @@ log.debug('missing default permission for group %s adding' % g) ReposGroupModel()._create_default_perms(g) - def config_prompt(self, test_repo_path='', retries=3): + def config_prompt(self, test_repo_path='', retries=3, defaults={}): + _path = defaults.get('repos_location') if retries == 3: log.info('Setting up repositories config') - if not self.tests and not test_repo_path: + if _path is not None: + path = _path + elif not self.tests and not test_repo_path: path = raw_input( 'Enter a valid absolute path to store repositories. ' 'All repositories in that path will be added automatically:' diff -r d932229a3b22 -r 393c53cbd0d8 rhodecode/websetup.py --- a/rhodecode/websetup.py Wed May 16 19:01:55 2012 +0200 +++ b/rhodecode/websetup.py Wed May 16 23:17:13 2012 +0200 @@ -40,9 +40,10 @@ tests=False) dbmanage.create_tables(override=True) dbmanage.set_db_version() - dbmanage.create_settings(dbmanage.config_prompt(None)) + opts = dbmanage.config_prompt(None, defaults=command.options.__dict__) + dbmanage.create_settings(opts) dbmanage.create_default_user() - dbmanage.admin_prompt() + dbmanage.admin_prompt(defaults=command.options.__dict__) dbmanage.create_permissions() dbmanage.populate_default_permissions() Session.commit() diff -r d932229a3b22 -r 393c53cbd0d8 setup.py --- a/setup.py Wed May 16 19:01:55 2012 +0200 +++ b/setup.py Wed May 16 23:17:13 2012 +0200 @@ -94,6 +94,7 @@ main = pylons.util:PylonsInstaller [paste.global_paster_command] + setup-rhodecode=rhodecode.config.setup:SetupCommand make-index=rhodecode.lib.indexers:MakeIndex make-rcext=rhodecode.config.rcextensions.make_rcextensions:MakeRcExt upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb