Mercurial > kallithea
comparison rhodecode/lib/db_manage.py @ 2285:393c53cbd0d8 codereview
merge with beta
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 16 May 2012 23:17:13 +0200 |
parents | 2fd474e63177 e285aa097a81 |
children | 388843a3a3c0 |
comparison
equal
deleted
inserted
replaced
2283:d932229a3b22 | 2285:393c53cbd0d8 |
---|---|
238 self.sa.commit() | 238 self.sa.commit() |
239 except: | 239 except: |
240 self.sa.rollback() | 240 self.sa.rollback() |
241 raise | 241 raise |
242 | 242 |
243 def admin_prompt(self, second=False): | 243 def admin_prompt(self, second=False, defaults={}): |
244 if not self.tests: | 244 if not self.tests: |
245 import getpass | 245 import getpass |
246 | |
247 # defaults | |
248 username = defaults.get('username') | |
249 password = defaults.get('password') | |
250 email = defaults.get('email') | |
246 | 251 |
247 def get_password(): | 252 def get_password(): |
248 password = getpass.getpass('Specify admin password ' | 253 password = getpass.getpass('Specify admin password ' |
249 '(min 6 chars):') | 254 '(min 6 chars):') |
250 confirm = getpass.getpass('Confirm password:') | 255 confirm = getpass.getpass('Confirm password:') |
255 if len(password) < 6: | 260 if len(password) < 6: |
256 log.error('password is to short use at least 6 characters') | 261 log.error('password is to short use at least 6 characters') |
257 return False | 262 return False |
258 | 263 |
259 return password | 264 return password |
260 | 265 if username is None: |
261 username = raw_input('Specify admin username:') | 266 username = raw_input('Specify admin username:') |
262 | 267 if password is None: |
263 password = get_password() | |
264 if not password: | |
265 #second try | |
266 password = get_password() | 268 password = get_password() |
267 if not password: | 269 if not password: |
268 sys.exit() | 270 #second try |
269 | 271 password = get_password() |
270 email = raw_input('Specify admin email:') | 272 if not password: |
273 sys.exit() | |
274 if email is None: | |
275 email = raw_input('Specify admin email:') | |
271 self.create_user(username, password, email, True) | 276 self.create_user(username, password, email, True) |
272 else: | 277 else: |
273 log.info('creating admin and regular test users') | 278 log.info('creating admin and regular test users') |
274 from rhodecode.tests import TEST_USER_ADMIN_LOGIN,\ | 279 from rhodecode.tests import TEST_USER_ADMIN_LOGIN,\ |
275 TEST_USER_ADMIN_PASS, TEST_USER_ADMIN_EMAIL,\ | 280 TEST_USER_ADMIN_PASS, TEST_USER_ADMIN_EMAIL,\ |
370 | 375 |
371 if default is None: | 376 if default is None: |
372 log.debug('missing default permission for group %s adding' % g) | 377 log.debug('missing default permission for group %s adding' % g) |
373 ReposGroupModel()._create_default_perms(g) | 378 ReposGroupModel()._create_default_perms(g) |
374 | 379 |
375 def config_prompt(self, test_repo_path='', retries=3): | 380 def config_prompt(self, test_repo_path='', retries=3, defaults={}): |
381 _path = defaults.get('repos_location') | |
376 if retries == 3: | 382 if retries == 3: |
377 log.info('Setting up repositories config') | 383 log.info('Setting up repositories config') |
378 | 384 |
379 if not self.tests and not test_repo_path: | 385 if _path is not None: |
386 path = _path | |
387 elif not self.tests and not test_repo_path: | |
380 path = raw_input( | 388 path = raw_input( |
381 'Enter a valid absolute path to store repositories. ' | 389 'Enter a valid absolute path to store repositories. ' |
382 'All repositories in that path will be added automatically:' | 390 'All repositories in that path will be added automatically:' |
383 ) | 391 ) |
384 else: | 392 else: |