##// END OF EJS Templates
updated db manage script, and remove broken test
marcink -
r351:d0938159 default
parent child Browse files
Show More
@@ -2,7 +2,7 b''
2 2 # encoding: utf-8
3 3 # database managment for hg app
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5
5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; version 2
@@ -32,18 +32,14 b' ROOT = dn(dn(dn(os.path.realpath(__file_'
32 32 sys.path.append(ROOT)
33 33
34 34 from pylons_app.lib.auth import get_crypt_password
35 from pylons_app.lib.utils import ask_ok
35 36 from pylons_app.model import init_model
36 37 from pylons_app.model.db import User, Permission, HgAppUi, HgAppSettings
37 38 from pylons_app.model import meta
38 39 from sqlalchemy.engine import create_engine
39 40 import logging
40 41
41 log = logging.getLogger('db manage')
42 log.setLevel(logging.DEBUG)
43 console_handler = logging.StreamHandler()
44 console_handler.setFormatter(logging.Formatter("%(asctime)s.%(msecs)03d"
45 " %(levelname)-5.5s [%(name)s] %(message)s"))
46 log.addHandler(console_handler)
42 log = logging.getLogger(__name__)
47 43
48 44 class DbManage(object):
49 45 def __init__(self, log_sql):
@@ -69,9 +65,13 b' class DbManage(object):'
69 65 self.check_for_db(override)
70 66 if override:
71 67 log.info("database exisist and it's going to be destroyed")
72 if self.db_exists:
68 destroy = ask_ok('Are you sure to destroy old database ? [y/n]')
69 if not destroy:
70 sys.exit()
71 if self.db_exists and destroy:
73 72 os.remove(jn(ROOT, self.dbname))
74 meta.Base.metadata.create_all(checkfirst=override)
73 checkfirst = not override
74 meta.Base.metadata.create_all(checkfirst=checkfirst)
75 75 log.info('Created tables for %s', self.dbname)
76 76
77 77 def admin_prompt(self):
@@ -83,9 +83,8 b' class DbManage(object):'
83 83 def config_prompt(self):
84 84 log.info('Setting up repositories config')
85 85
86
87 86 path = raw_input('Specify valid full path to your repositories'
88 ' you can change this later application settings:')
87 ' you can change this later in application settings:')
89 88
90 89 if not os.path.isdir(path):
91 90 log.error('You entered wrong path')
@@ -16,20 +16,21 b''
16 16 # along with this program; if not, write to the Free Software
17 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 18 # MA 02110-1301, USA.
19 from beaker.cache import cache_region
20 19
21 20 """
22 21 Created on April 18, 2010
23 22 Utilities for hg app
24 23 @author: marcink
25 24 """
26
27 import os
28 import logging
25 from beaker.cache import cache_region
29 26 from mercurial import ui, config, hg
30 27 from mercurial.error import RepoError
28 from pylons_app.model import meta
31 29 from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings
32 from pylons_app.model import meta
30 from vcs.backends.base import BaseChangeset
31 from vcs.utils.lazy import LazyProperty
32 import logging
33 import os
33 34 log = logging.getLogger(__name__)
34 35
35 36
@@ -77,7 +78,15 b' def check_repo(repo_name, base_path, ver'
77 78 log.info('%s repo is free for creation', repo_name)
78 79 return True
79 80
80
81 def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
82 while True:
83 ok = raw_input(prompt)
84 if ok in ('y', 'ye', 'yes'): return True
85 if ok in ('n', 'no', 'nop', 'nope'): return False
86 retries = retries - 1
87 if retries < 0: raise IOError
88 print complaint
89
81 90 @cache_region('super_short_term', 'cached_hg_ui')
82 91 def get_hg_ui_cached():
83 92 try:
@@ -170,8 +179,6 b' def invalidate_cache(name, *args):'
170 179 from pylons_app.model.hg_model import _full_changelog_cached
171 180 region_invalidate(_full_changelog_cached, None, *args)
172 181
173 from vcs.backends.base import BaseChangeset
174 from vcs.utils.lazy import LazyProperty
175 182 class EmptyChangeset(BaseChangeset):
176 183
177 184 revision = -1
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now