Mercurial > kallithea
comparison rhodecode/lib/db_manage.py @ 597:53128b6b9a4d rhodecode-0.0.1.0.0rc4
added password validation, second try on paster setup-app,
docs update, and fixed beaker cache settings in ini files.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 12 Oct 2010 23:17:25 +0200 |
parents | 000b675e7c1d |
children | 7e536d1af60d |
comparison
equal
deleted
inserted
replaced
596:ae5e3dafc02c | 597:53128b6b9a4d |
---|---|
54 def check_for_db(self, override): | 54 def check_for_db(self, override): |
55 db_path = jn(self.root, self.dbname) | 55 db_path = jn(self.root, self.dbname) |
56 log.info('checking for existing db in %s', db_path) | 56 log.info('checking for existing db in %s', db_path) |
57 if os.path.isfile(db_path): | 57 if os.path.isfile(db_path): |
58 self.db_exists = True | 58 self.db_exists = True |
59 log.info('database exist') | |
60 if not override: | 59 if not override: |
61 raise Exception('database already exists') | 60 raise Exception('database already exists') |
62 | 61 |
63 def create_tables(self, override=False): | 62 def create_tables(self, override=False): |
64 """ | 63 """ |
65 Create a auth database | 64 Create a auth database |
66 """ | 65 """ |
67 self.check_for_db(override) | 66 self.check_for_db(override) |
68 if override: | 67 if self.db_exists: |
69 log.info("database exist and it's going to be destroyed") | 68 log.info("database exist and it's going to be destroyed") |
70 if self.tests: | 69 if self.tests: |
71 destroy = True | 70 destroy = True |
72 else: | 71 else: |
73 destroy = ask_ok('Are you sure to destroy old database ? [y/n]') | 72 destroy = ask_ok('Are you sure to destroy old database ? [y/n]') |
77 os.remove(jn(self.root, self.dbname)) | 76 os.remove(jn(self.root, self.dbname)) |
78 checkfirst = not override | 77 checkfirst = not override |
79 meta.Base.metadata.create_all(checkfirst=checkfirst) | 78 meta.Base.metadata.create_all(checkfirst=checkfirst) |
80 log.info('Created tables for %s', self.dbname) | 79 log.info('Created tables for %s', self.dbname) |
81 | 80 |
82 def admin_prompt(self): | 81 def admin_prompt(self, second=False): |
83 if not self.tests: | 82 if not self.tests: |
84 import getpass | 83 import getpass |
84 | |
85 | |
86 def get_password(): | |
87 password = getpass.getpass('Specify admin password (min 6 chars):') | |
88 confirm = getpass.getpass('Confirm password:') | |
89 | |
90 if password != confirm: | |
91 log.error('passwords mismatch') | |
92 return False | |
93 if len(password) < 6: | |
94 log.error('password is to short use at least 6 characters') | |
95 return False | |
96 | |
97 return password | |
98 | |
85 username = raw_input('Specify admin username:') | 99 username = raw_input('Specify admin username:') |
86 password = getpass.getpass('Specify admin password:') | 100 |
87 confirm = getpass.getpass('Confirm password:') | 101 password = get_password() |
88 if password != confirm: | 102 if not password: |
89 log.error('passwords mismatch') | 103 #second try |
90 sys.exit() | 104 password = get_password() |
105 if not password: | |
106 sys.exit() | |
107 | |
91 email = raw_input('Specify admin email:') | 108 email = raw_input('Specify admin email:') |
92 self.create_user(username, password, email, True) | 109 self.create_user(username, password, email, True) |
93 else: | 110 else: |
94 log.info('creating admin and regular test users') | 111 log.info('creating admin and regular test users') |
95 self.create_user('test_admin', 'test12', 'test_admin@mail.com', True) | 112 self.create_user('test_admin', 'test12', 'test_admin@mail.com', True) |