Show More
@@ -60,39 +60,19 b' class DbManage(object):' | |||
|
60 | 60 | init_model(engine) |
|
61 | 61 | self.sa = meta.Session() |
|
62 | 62 | |
|
63 | def check_for_db(self, override): | |
|
64 | db_path = jn(self.root, self.dbname) | |
|
65 | if self.dburi.startswith('sqlite'): | |
|
66 | log.info('checking for existing db in %s', db_path) | |
|
67 | if os.path.isfile(db_path): | |
|
68 | ||
|
69 | self.db_exists = True | |
|
70 | if not override: | |
|
71 | raise Exception('database already exists') | |
|
72 | return 'sqlite' | |
|
73 | if self.dburi.startswith('postgresql'): | |
|
74 | self.db_exists = True | |
|
75 | return 'postgresql' | |
|
76 | ||
|
77 | ||
|
78 | 63 | def create_tables(self, override=False): |
|
79 | 64 | """Create a auth database |
|
80 | 65 | """ |
|
81 | 66 | |
|
82 | db_type = self.check_for_db(override) | |
|
83 |
if self. |
|
|
84 | log.info("database exist and it's going to be destroyed") | |
|
85 | if self.tests: | |
|
86 | destroy = True | |
|
87 |
|
|
|
88 | destroy = ask_ok('Are you sure to destroy old database ? [y/n]') | |
|
89 |
|
|
|
90 | sys.exit() | |
|
91 | if self.db_exists and destroy: | |
|
92 | if db_type == 'sqlite': | |
|
93 | os.remove(jn(self.root, self.dbname)) | |
|
94 | if db_type == 'postgresql': | |
|
95 | meta.Base.metadata.drop_all() | |
|
67 | log.info("Any existing database is going to be destroyed") | |
|
68 | if self.tests: | |
|
69 | destroy = True | |
|
70 | else: | |
|
71 | destroy = ask_ok('Are you sure to destroy old database ? [y/n]') | |
|
72 | if not destroy: | |
|
73 | sys.exit() | |
|
74 | if destroy: | |
|
75 | meta.Base.metadata.drop_all() | |
|
96 | 76 | |
|
97 | 77 | checkfirst = not override |
|
98 | 78 | meta.Base.metadata.create_all(checkfirst=checkfirst) |
@@ -335,13 +315,16 b' class DbManage(object):' | |||
|
335 | 315 | """Creates ldap settings""" |
|
336 | 316 | |
|
337 | 317 | try: |
|
338 |
for k in ['ldap_active', 'ldap_host', ' |
|
|
339 |
'ldap_ |
|
|
340 |
'ldap_ |
|
|
341 |
'ldap_ |
|
|
342 | 'ldap_attr_email']: | |
|
318 | for k, v in [('ldap_active', 'false'), ('ldap_host', ''), | |
|
319 | ('ldap_port', '389'), ('ldap_ldaps', 'false'), | |
|
320 | ('ldap_tls_reqcert', ''), ('ldap_dn_user', ''), | |
|
321 | ('ldap_dn_pass', ''), ('ldap_base_dn', ''), | |
|
322 | ('ldap_filter', ''), ('ldap_search_scope', ''), | |
|
323 | ('ldap_attr_login', ''), ('ldap_attr_firstname', ''), | |
|
324 | ('ldap_attr_lastname', ''), ('ldap_attr_email', '')]: | |
|
343 | 325 | |
|
344 | setting = RhodeCodeSettings(k, '') | |
|
326 | ||
|
327 | setting = RhodeCodeSettings(k, v) | |
|
345 | 328 | self.sa.add(setting) |
|
346 | 329 | self.sa.commit() |
|
347 | 330 | except: |
General Comments 0
You need to be logged in to leave comments.
Login now