Show More
@@ -2,7 +2,7 b'' | |||||
2 | # encoding: utf-8 |
|
2 | # encoding: utf-8 | |
3 | # database managment for hg app |
|
3 | # database managment for hg app | |
4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | |
5 |
|
5 | # | ||
6 | # This program is free software; you can redistribute it and/or |
|
6 | # This program is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU General Public License |
|
7 | # modify it under the terms of the GNU General Public License | |
8 | # as published by the Free Software Foundation; version 2 |
|
8 | # as published by the Free Software Foundation; version 2 | |
@@ -32,18 +32,14 b' ROOT = dn(dn(dn(os.path.realpath(__file_' | |||||
32 | sys.path.append(ROOT) |
|
32 | sys.path.append(ROOT) | |
33 |
|
33 | |||
34 | from pylons_app.lib.auth import get_crypt_password |
|
34 | from pylons_app.lib.auth import get_crypt_password | |
|
35 | from pylons_app.lib.utils import ask_ok | |||
35 | from pylons_app.model import init_model |
|
36 | from pylons_app.model import init_model | |
36 | from pylons_app.model.db import User, Permission, HgAppUi, HgAppSettings |
|
37 | from pylons_app.model.db import User, Permission, HgAppUi, HgAppSettings | |
37 | from pylons_app.model import meta |
|
38 | from pylons_app.model import meta | |
38 | from sqlalchemy.engine import create_engine |
|
39 | from sqlalchemy.engine import create_engine | |
39 | import logging |
|
40 | import logging | |
40 |
|
41 | |||
41 |
log = logging.getLogger( |
|
42 | log = logging.getLogger(__name__) | |
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) |
|
|||
47 |
|
43 | |||
48 | class DbManage(object): |
|
44 | class DbManage(object): | |
49 | def __init__(self, log_sql): |
|
45 | def __init__(self, log_sql): | |
@@ -69,9 +65,13 b' class DbManage(object):' | |||||
69 | self.check_for_db(override) |
|
65 | self.check_for_db(override) | |
70 | if override: |
|
66 | if override: | |
71 | log.info("database exisist and it's going to be destroyed") |
|
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 | os.remove(jn(ROOT, self.dbname)) |
|
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 | log.info('Created tables for %s', self.dbname) |
|
75 | log.info('Created tables for %s', self.dbname) | |
76 |
|
76 | |||
77 | def admin_prompt(self): |
|
77 | def admin_prompt(self): | |
@@ -83,9 +83,8 b' class DbManage(object):' | |||||
83 | def config_prompt(self): |
|
83 | def config_prompt(self): | |
84 | log.info('Setting up repositories config') |
|
84 | log.info('Setting up repositories config') | |
85 |
|
85 | |||
86 |
|
||||
87 | path = raw_input('Specify valid full path to your repositories' |
|
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 | if not os.path.isdir(path): |
|
89 | if not os.path.isdir(path): | |
91 | log.error('You entered wrong path') |
|
90 | log.error('You entered wrong path') |
@@ -16,20 +16,21 b'' | |||||
16 | # along with this program; if not, write to the Free Software |
|
16 | # along with this program; if not, write to the Free Software | |
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
18 | # MA 02110-1301, USA. |
|
18 | # MA 02110-1301, USA. | |
19 | from beaker.cache import cache_region |
|
|||
20 |
|
19 | |||
21 | """ |
|
20 | """ | |
22 | Created on April 18, 2010 |
|
21 | Created on April 18, 2010 | |
23 | Utilities for hg app |
|
22 | Utilities for hg app | |
24 | @author: marcink |
|
23 | @author: marcink | |
25 | """ |
|
24 | """ | |
26 |
|
25 | from beaker.cache import cache_region | ||
27 | import os |
|
|||
28 | import logging |
|
|||
29 | from mercurial import ui, config, hg |
|
26 | from mercurial import ui, config, hg | |
30 | from mercurial.error import RepoError |
|
27 | from mercurial.error import RepoError | |
|
28 | from pylons_app.model import meta | |||
31 | from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings |
|
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 | log = logging.getLogger(__name__) |
|
34 | log = logging.getLogger(__name__) | |
34 |
|
35 | |||
35 |
|
36 | |||
@@ -77,7 +78,15 b' def check_repo(repo_name, base_path, ver' | |||||
77 | log.info('%s repo is free for creation', repo_name) |
|
78 | log.info('%s repo is free for creation', repo_name) | |
78 | return True |
|
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 | @cache_region('super_short_term', 'cached_hg_ui') |
|
90 | @cache_region('super_short_term', 'cached_hg_ui') | |
82 | def get_hg_ui_cached(): |
|
91 | def get_hg_ui_cached(): | |
83 | try: |
|
92 | try: | |
@@ -170,8 +179,6 b' def invalidate_cache(name, *args):' | |||||
170 | from pylons_app.model.hg_model import _full_changelog_cached |
|
179 | from pylons_app.model.hg_model import _full_changelog_cached | |
171 | region_invalidate(_full_changelog_cached, None, *args) |
|
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 | class EmptyChangeset(BaseChangeset): |
|
182 | class EmptyChangeset(BaseChangeset): | |
176 |
|
183 | |||
177 | revision = -1 |
|
184 | revision = -1 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now