Mercurial > kallithea
annotate rhodecode/lib/db_manage.py @ 4099:43b54436d459
update issue tracker and official site
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 01 Sep 2013 19:56:08 +0200 |
parents | c3245a0452a3 |
children | ffd45b185016 |
rev | line source |
---|---|
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
1 # -*- coding: utf-8 -*- |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
2 """ |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
3 rhodecode.lib.db_manage |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
5 |
838 | 6 Database creation, and setup module for RhodeCode. Used for creation |
7 of database as well as for migration operations | |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
8 |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
9 :created_on: Apr 10, 2010 |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
10 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1783
diff
changeset
|
11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
12 :license: GPLv3, see COPYING for more details. |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
13 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
17 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
18 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
19 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
22 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
23 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
24 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
25 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
249
diff
changeset
|
26 |
249
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
27 import os |
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
28 import sys |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
29 import time |
327
0e87466a117e
updated installation instruction, made more user friendly way of creating all needed configs. All is done now from paster setup-app
Marcin Kuzminski <marcin@python-works.com>
parents:
307
diff
changeset
|
30 import uuid |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
31 import logging |
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
32 from os.path import dirname as dn, join as jn |
3972
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
33 import datetime |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
34 |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
35 from rhodecode import __dbversion__, __py_version__ |
249
bad9ccac26b7
fixed import errors on db_manage
Marcin Kuzminski <marcin@python-works.com>
parents:
243
diff
changeset
|
36 |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
37 from rhodecode.model.user import UserModel |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
38 from rhodecode.lib.utils import ask_ok |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
39 from rhodecode.model import init_model |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
40 from rhodecode.model.db import User, Permission, RhodeCodeUi, \ |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
41 RhodeCodeSetting, UserToPerm, DbMigrateVersion, RepoGroup, \ |
3758
d5c684052ea4
fixed migration of empty usergroups created pre-usergroup delegation permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3757
diff
changeset
|
42 UserRepoGroupToPerm, CacheInvalidation, UserGroup |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
43 |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
44 from sqlalchemy.engine import create_engine |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
45 from rhodecode.model.repos_group import ReposGroupModel |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
46 #from rhodecode.model import meta |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
47 from rhodecode.model.meta import Session, Base |
3309
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
48 from rhodecode.model.repo import RepoModel |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
49 from rhodecode.model.permission import PermissionModel |
3758
d5c684052ea4
fixed migration of empty usergroups created pre-usergroup delegation permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
3757
diff
changeset
|
50 from rhodecode.model.users_group import UserGroupModel |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
51 |
835
08d2dcd71666
fixed imports on migrate, added getting current version from database
Marcin Kuzminski <marcin@python-works.com>
parents:
834
diff
changeset
|
52 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
53 log = logging.getLogger(__name__) |
66
163464441e0d
updated db manage script for creating interactive admin account and db
Marcin Kuzminski <marcin@python-blog.com>
parents:
59
diff
changeset
|
54 |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
55 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
56 def notify(msg): |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
57 """ |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
58 Notification for migrations messages |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
59 """ |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
60 ml = len(msg) + (4 * 2) |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
61 print('\n%s\n*** %s ***\n%s' % ('*' * ml, msg, '*' * ml)).upper() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
62 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
63 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
64 class UpgradeSteps(object): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
65 """ |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
66 Those steps follow schema versions so for example schema |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
67 for example schema with seq 002 == step_2 and so on. |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
68 """ |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
69 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
70 def __init__(self, klass): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
71 self.klass = klass |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
72 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
73 def step_1(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
74 pass |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
75 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
76 def step_2(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
77 notify('Patching repo paths for newer version of RhodeCode') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
78 self.klass.fix_repo_paths() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
79 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
80 notify('Patching default user of RhodeCode') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
81 self.klass.fix_default_user() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
82 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
83 log.info('Changing ui settings') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
84 self.klass.create_ui_settings() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
85 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
86 def step_3(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
87 notify('Adding additional settings into RhodeCode db') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
88 self.klass.fix_settings() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
89 notify('Adding ldap defaults') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
90 self.klass.create_ldap_options(skip_existing=True) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
91 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
92 def step_4(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
93 notify('create permissions and fix groups') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
94 self.klass.create_permissions() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
95 self.klass.fixup_groups() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
96 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
97 def step_5(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
98 pass |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
99 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
100 def step_6(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
101 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
102 notify('re-checking permissions') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
103 self.klass.create_permissions() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
104 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
105 notify('installing new UI options') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
106 sett4 = RhodeCodeSetting('show_public_icon', True) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
107 Session().add(sett4) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
108 sett5 = RhodeCodeSetting('show_private_icon', True) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
109 Session().add(sett5) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
110 sett6 = RhodeCodeSetting('stylify_metatags', False) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
111 Session().add(sett6) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
112 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
113 notify('fixing old PULL hook') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
114 _pull = RhodeCodeUi.get_by_key('preoutgoing.pull_logger') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
115 if _pull: |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
116 _pull.ui_key = RhodeCodeUi.HOOK_PULL |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
117 Session().add(_pull) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
118 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
119 notify('fixing old PUSH hook') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
120 _push = RhodeCodeUi.get_by_key('pretxnchangegroup.push_logger') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
121 if _push: |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
122 _push.ui_key = RhodeCodeUi.HOOK_PUSH |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
123 Session().add(_push) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
124 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
125 notify('installing new pre-push hook') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
126 hooks4 = RhodeCodeUi() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
127 hooks4.ui_section = 'hooks' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
128 hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
129 hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
130 Session().add(hooks4) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
131 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
132 notify('installing new pre-pull hook') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
133 hooks6 = RhodeCodeUi() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
134 hooks6.ui_section = 'hooks' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
135 hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
136 hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
137 Session().add(hooks6) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
138 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
139 notify('installing hgsubversion option') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
140 # enable hgsubversion disabled by default |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
141 hgsubversion = RhodeCodeUi() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
142 hgsubversion.ui_section = 'extensions' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
143 hgsubversion.ui_key = 'hgsubversion' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
144 hgsubversion.ui_value = '' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
145 hgsubversion.ui_active = False |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
146 Session().add(hgsubversion) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
147 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
148 notify('installing hg git option') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
149 # enable hggit disabled by default |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
150 hggit = RhodeCodeUi() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
151 hggit.ui_section = 'extensions' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
152 hggit.ui_key = 'hggit' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
153 hggit.ui_value = '' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
154 hggit.ui_active = False |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
155 Session().add(hggit) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
156 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
157 notify('re-check default permissions') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
158 default_user = User.get_by_username(User.DEFAULT_USER) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
159 perm = Permission.get_by_key('hg.fork.repository') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
160 reg_perm = UserToPerm() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
161 reg_perm.user = default_user |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
162 reg_perm.permission = perm |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
163 Session().add(reg_perm) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
164 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
165 def step_7(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
166 perm_fixes = self.klass.reset_permissions(User.DEFAULT_USER) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
167 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
168 if perm_fixes: |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
169 notify('There was an inconsistent state of permissions ' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
170 'detected for default user. Permissions are now ' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
171 'reset to the default value for default user. ' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
172 'Please validate and check default permissions ' |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
173 'in admin panel') |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
174 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
175 def step_8(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
176 self.klass.create_permissions() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
177 self.klass.populate_default_permissions() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
178 self.klass.create_default_options(skip_existing=True) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
179 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
180 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
181 def step_9(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
182 pass |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
183 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
184 def step_10(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
185 pass |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
186 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
187 def step_11(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
188 self.klass.update_repo_info() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
189 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
190 def step_12(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
191 self.klass.create_permissions() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
192 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
193 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
194 self.klass.populate_default_permissions() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
195 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
196 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
197 #fix all usergroups |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
198 ug_model = UserGroupModel() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
199 for ug in UserGroup.get_all(): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
200 perm_obj = ug_model._create_default_perms(ug) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
201 Session().add(perm_obj) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
202 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
203 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
204 adm = User.get_first_admin() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
205 # fix owners of UserGroup |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
206 for ug in Session().query(UserGroup).all(): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
207 ug.user_id = adm.user_id |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
208 Session().add(ug) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
209 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
210 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
211 # fix owners of RepoGroup |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
212 for ug in Session().query(RepoGroup).all(): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
213 ug.user_id = adm.user_id |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
214 Session().add(ug) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
215 Session().commit() |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
216 |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
217 def step_13(self): |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
218 pass |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
219 |
3972
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
220 def step_14(self): |
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
221 # fix nullable columns on last_update |
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
222 for r in RepoModel().get_all(): |
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
223 if r.updated_on is None: |
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
224 r.updated_on = datetime.datetime.fromtimestamp(0) |
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
225 Session().add(r) |
3cb5a35a319d
added migrations for column change for gists expiration date
Marcin Kuzminski <marcin@python-works.com>
parents:
3960
diff
changeset
|
226 Session().commit() |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
227 |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
88
diff
changeset
|
228 class DbManage(object): |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
229 def __init__(self, log_sql, dbconf, root, tests=False, cli_args={}): |
781
7ae66bddf48d
fixed db manage, to work on other databases than sqlite
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
230 self.dbname = dbconf.split('/')[-1] |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
231 self.tests = tests |
552
2642f128ad46
removed egg info, update files for distutils build
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
232 self.root = root |
781
7ae66bddf48d
fixed db manage, to work on other databases than sqlite
Marcin Kuzminski <marcin@python-works.com>
parents:
773
diff
changeset
|
233 self.dburi = dbconf |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
234 self.log_sql = log_sql |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
235 self.db_exists = False |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
236 self.cli_args = cli_args |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
237 self.init_db() |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
238 |
3671
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
239 force_ask = self.cli_args.get('force_ask') |
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
240 if force_ask is not None: |
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
241 global ask_ok |
658ccf9727ef
setup_rhodecode: fix --force-no - force_ask is tri-state
Mads Kiilerich <madski@unity3d.com>
parents:
3631
diff
changeset
|
242 ask_ok = lambda *args, **kwargs: force_ask |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
243 |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
244 def init_db(self): |
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
245 engine = create_engine(self.dburi, echo=self.log_sql) |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
88
diff
changeset
|
246 init_model(engine) |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
247 self.sa = Session() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
248 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
249 def create_tables(self, override=False): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
250 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
251 Create a auth database |
226
c6526b7531e9
rewritten db manage script to use sqlalchemy. Fixed sqlalchemy models to more generic.
Marcin Kuzminski <marcin@python-works.com>
parents:
88
diff
changeset
|
252 """ |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
253 |
1138
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
254 log.info("Any existing database is going to be destroyed") |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
255 if self.tests: |
1138
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
256 destroy = True |
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
257 else: |
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
258 destroy = ask_ok('Are you sure to destroy old database ? [y/n]') |
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
259 if not destroy: |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3671
diff
changeset
|
260 sys.exit('Nothing tables created') |
1138
9c45e11493fb
fixed ldap settings creation, we need to fill in some bool defaults properly to make it work fine
Marcin Kuzminski <marcin@python-works.com>
parents:
1116
diff
changeset
|
261 if destroy: |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
262 Base.metadata.drop_all() |
964
84bb5b8b498d
changed dev and tests to postgressql for more error proof setup.
Marcin Kuzminski <marcin@python-works.com>
parents:
907
diff
changeset
|
263 |
351
d09381593b12
updated db manage script, and remove broken test
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
264 checkfirst = not override |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
265 Base.metadata.create_all(checkfirst=checkfirst) |
1976 | 266 log.info('Created tables for %s' % self.dbname) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
267 |
834
8924ed0e4f36
added current db version into rhodecode,
Marcin Kuzminski <marcin@python-works.com>
parents:
781
diff
changeset
|
268 def set_db_version(self): |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
269 ver = DbMigrateVersion() |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
270 ver.version = __dbversion__ |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
271 ver.repository_id = 'rhodecode_db_migrations' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
272 ver.repository_path = 'versions' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
273 self.sa.add(ver) |
1976 | 274 log.info('db version set to: %s' % __dbversion__) |
834
8924ed0e4f36
added current db version into rhodecode,
Marcin Kuzminski <marcin@python-works.com>
parents:
781
diff
changeset
|
275 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
276 def upgrade(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
277 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
278 Upgrades given database schema to given revision following |
900
07f248329a3b
updated migration for version 1.2
Marcin Kuzminski <marcin@python-works.com>
parents:
890
diff
changeset
|
279 all needed steps, to perform the upgrade |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
280 |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
281 """ |
841
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
282 |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
283 from rhodecode.lib.dbmigrate.migrate.versioning import api |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
284 from rhodecode.lib.dbmigrate.migrate.exceptions import \ |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
285 DatabaseNotControlledError |
78b3d2d730f2
fixed import problems
Marcin Kuzminski <marcin@python-works.com>
parents:
839
diff
changeset
|
286 |
1835
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
287 if 'sqlite' in self.dburi: |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
288 print ( |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
289 '********************** WARNING **********************\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
290 'Make sure your version of sqlite is at least 3.7.X. \n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
291 'Earlier versions are known to fail on some migrations\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
292 '*****************************************************\n' |
971ce5e20856
added warning on sqlite when using migration.
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
293 ) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
294 upgrade = ask_ok('You are about to perform database upgrade, make ' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
295 'sure You backed up your database before. ' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
296 'Continue ? [y/n]') |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
297 if not upgrade: |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3671
diff
changeset
|
298 sys.exit('No upgrade performed') |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
299 |
843
3b21ba5f7cb0
fixed path issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
841
diff
changeset
|
300 repository_path = jn(dn(dn(dn(os.path.realpath(__file__)))), |
3b21ba5f7cb0
fixed path issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
841
diff
changeset
|
301 'rhodecode/lib/dbmigrate') |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
302 db_uri = self.dburi |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
303 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
304 try: |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
305 curr_version = api.db_version(db_uri, repository_path) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
306 msg = ('Found current database under version' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
307 ' control with version %s' % curr_version) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
308 |
1299
8eda822931c9
small fixes for interactive prompt in setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
309 except (RuntimeError, DatabaseNotControlledError): |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
310 curr_version = 1 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
311 msg = ('Current database is not under version control. Setting' |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
312 ' as version %s' % curr_version) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
313 api.version_control(db_uri, repository_path, curr_version) |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
314 |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
315 notify(msg) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
316 |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
317 if curr_version == __dbversion__: |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
318 sys.exit('This database is already at the newest version') |
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
319 |
3757
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
320 # clear cache keys |
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
321 log.info("Clearing cache keys now...") |
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
322 CacheInvalidation.clear_cache() |
f08881dcc9eb
invalidate: clear CacheInvalidation when upgrading
Mads Kiilerich <madski@unity3d.com>
parents:
3734
diff
changeset
|
323 |
3906
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
324 upgrade_steps = range(curr_version + 1, __dbversion__ + 1) |
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
325 notify('attempting to do database upgrade from ' |
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
326 'version %s to version %s' % (curr_version, __dbversion__)) |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
327 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
328 # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
329 _step = None |
839
ad66bd0e5601
moved db migration do db manage script, added my cycles for upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
838
diff
changeset
|
330 for step in upgrade_steps: |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
331 notify('performing upgrade step %s' % step) |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
332 time.sleep(2) |
3906
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
333 |
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
334 api.upgrade(db_uri, repository_path, step) |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
335 notify('schema upgrade for step %s completed' % (step,)) |
3906
a2de0de0a4a9
migration to 1.7.0
Marcin Kuzminski <marcin@python-works.com>
parents:
3889
diff
changeset
|
336 |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
337 fixture = 'step_%s' % step |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
338 notify('performing fixture step %s' % fixture) |
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
339 getattr(UpgradeSteps(self), fixture)() |
1987
77b5c24f1887
fixed found issues in upgrade script
Marcin Kuzminski <marcin@python-works.com>
parents:
1986
diff
changeset
|
340 self.sa.commit() |
3907
c7b919b2d90d
Changed default behaviour of dbmanage to fix issues with continues
Marcin Kuzminski <marcin@python-works.com>
parents:
3906
diff
changeset
|
341 notify('fixture %s completed' % (fixture,)) |
2779
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
342 _step = step |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
343 |
d0d3158850d4
migrations: fix old hook values
Marcin Kuzminski <marcin@python-works.com>
parents:
2767
diff
changeset
|
344 notify('upgrade to version %s successful' % _step) |
2000
72c525a7e7ad
added migrations from 1.2.X to 1.3
Marcin Kuzminski <marcin@python-works.com>
parents:
1987
diff
changeset
|
345 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
346 def fix_repo_paths(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
347 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
348 Fixes a old rhodecode version path into new one without a '*' |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
349 """ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
350 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
351 paths = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
352 .filter(RhodeCodeUi.ui_key == '/')\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
353 .scalar() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
354 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
355 paths.ui_value = paths.ui_value.replace('*', '') |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
356 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
357 try: |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
358 self.sa.add(paths) |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
359 self.sa.commit() |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3625
diff
changeset
|
360 except Exception: |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
361 self.sa.rollback() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
362 raise |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
363 |
838 | 364 def fix_default_user(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
365 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
366 Fixes a old default user with some 'nicer' default values, |
838 | 367 used mostly for anonymous access |
368 """ | |
369 def_user = self.sa.query(User)\ | |
370 .filter(User.username == 'default')\ | |
371 .one() | |
372 | |
373 def_user.name = 'Anonymous' | |
374 def_user.lastname = 'User' | |
375 def_user.email = 'anonymous@rhodecode.org' | |
376 | |
377 try: | |
378 self.sa.add(def_user) | |
379 self.sa.commit() | |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3625
diff
changeset
|
380 except Exception: |
838 | 381 self.sa.rollback() |
382 raise | |
383 | |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
384 def fix_settings(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
385 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
386 Fixes rhodecode settings adds ga_code key for google analytics |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
387 """ |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
388 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1510
diff
changeset
|
389 hgsettings3 = RhodeCodeSetting('ga_code', '') |
907
2f83756f3041
Fixed dbmigrate issues.
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
390 |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
391 try: |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
392 self.sa.add(hgsettings3) |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
393 self.sa.commit() |
3631
10b4e34841a4
Don't catch all exceptions
Marcin Kuzminski <marcin@python-works.com>
parents:
3625
diff
changeset
|
394 except Exception: |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
395 self.sa.rollback() |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
843
diff
changeset
|
396 raise |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
397 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
398 def admin_prompt(self, second=False): |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
399 if not self.tests: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
400 import getpass |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
401 |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
402 # defaults |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
403 defaults = self.cli_args |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
404 username = defaults.get('username') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
405 password = defaults.get('password') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
406 email = defaults.get('email') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
407 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
408 def get_password(): |
1266
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
409 password = getpass.getpass('Specify admin password ' |
a1bcfe58a1ab
Fixed #161 form saves the create repository permission.
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
410 '(min 6 chars):') |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
411 confirm = getpass.getpass('Confirm password:') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
412 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
413 if password != confirm: |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
414 log.error('passwords mismatch') |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
415 return False |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
416 if len(password) < 6: |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
417 log.error('password is to short use at least 6 characters') |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
418 return False |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
419 |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
420 return password |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
421 if username is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
422 username = raw_input('Specify admin username:') |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
423 if password is None: |
597
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
424 password = get_password() |
53128b6b9a4d
added password validation, second try on paster setup-app,
Marcin Kuzminski <marcin@python-works.com>
parents:
569
diff
changeset
|
425 if not password: |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
426 #second try |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
427 password = get_password() |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
428 if not password: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
429 sys.exit() |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
430 if email is None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
431 email = raw_input('Specify admin email:') |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
471
diff
changeset
|
432 self.create_user(username, password, email, True) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
433 else: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
434 log.info('creating admin and regular test users') |
2765
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
435 from rhodecode.tests import TEST_USER_ADMIN_LOGIN, \ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
436 TEST_USER_ADMIN_PASS, TEST_USER_ADMIN_EMAIL, \ |
186b1cf7f759
Step6a for migrations from 1.3.6
Marcin Kuzminski <marcin@python-works.com>
parents:
2726
diff
changeset
|
437 TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, \ |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
438 TEST_USER_REGULAR_EMAIL, TEST_USER_REGULAR2_LOGIN, \ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
439 TEST_USER_REGULAR2_PASS, TEST_USER_REGULAR2_EMAIL |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
440 |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
441 self.create_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
442 TEST_USER_ADMIN_EMAIL, True) |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
443 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
444 self.create_user(TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
445 TEST_USER_REGULAR_EMAIL, False) |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
446 |
1758
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
447 self.create_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS, |
a87aa385f21c
fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
448 TEST_USER_REGULAR2_EMAIL, False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
449 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
450 def create_ui_settings(self): |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
451 """ |
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
452 Creates ui settings, fills out hooks |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
453 and disables dotencode |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
454 """ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1138
diff
changeset
|
455 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
456 #HOOKS |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
457 hooks1_key = RhodeCodeUi.HOOK_UPDATE |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
458 hooks1_ = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
459 .filter(RhodeCodeUi.ui_key == hooks1_key).scalar() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
460 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
461 hooks1 = RhodeCodeUi() if hooks1_ is None else hooks1_ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
462 hooks1.ui_section = 'hooks' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
463 hooks1.ui_key = hooks1_key |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
464 hooks1.ui_value = 'hg update >&2' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
465 hooks1.ui_active = False |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
466 self.sa.add(hooks1) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
467 |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
468 hooks2_key = RhodeCodeUi.HOOK_REPO_SIZE |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
469 hooks2_ = self.sa.query(RhodeCodeUi)\ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
470 .filter(RhodeCodeUi.ui_key == hooks2_key).scalar() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
471 hooks2 = RhodeCodeUi() if hooks2_ is None else hooks2_ |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
472 hooks2.ui_section = 'hooks' |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
473 hooks2.ui_key = hooks2_key |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
474 hooks2.ui_value = 'python:rhodecode.lib.hooks.repo_size' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
475 self.sa.add(hooks2) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
476 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
477 hooks3 = RhodeCodeUi() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
478 hooks3.ui_section = 'hooks' |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1399
diff
changeset
|
479 hooks3.ui_key = RhodeCodeUi.HOOK_PUSH |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
480 hooks3.ui_value = 'python:rhodecode.lib.hooks.log_push_action' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
481 self.sa.add(hooks3) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
482 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
483 hooks4 = RhodeCodeUi() |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
484 hooks4.ui_section = 'hooks' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
485 hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
486 hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
487 self.sa.add(hooks4) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
488 |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
489 hooks5 = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
490 hooks5.ui_section = 'hooks' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
491 hooks5.ui_key = RhodeCodeUi.HOOK_PULL |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
492 hooks5.ui_value = 'python:rhodecode.lib.hooks.log_pull_action' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
493 self.sa.add(hooks5) |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
494 |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
495 hooks6 = RhodeCodeUi() |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
496 hooks6.ui_section = 'hooks' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
497 hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
498 hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull' |
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
499 self.sa.add(hooks6) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
500 |
1694
1450ceb36aa6
enabled largefiles extension by default in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1634
diff
changeset
|
501 # enable largefiles |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
502 largefiles = RhodeCodeUi() |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
503 largefiles.ui_section = 'extensions' |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
504 largefiles.ui_key = 'largefiles' |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
505 largefiles.ui_value = '' |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
506 self.sa.add(largefiles) |
1694
1450ceb36aa6
enabled largefiles extension by default in rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
1634
diff
changeset
|
507 |
2705
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
508 # enable hgsubversion disabled by default |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
509 hgsubversion = RhodeCodeUi() |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
510 hgsubversion.ui_section = 'extensions' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
511 hgsubversion.ui_key = 'hgsubversion' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
512 hgsubversion.ui_value = '' |
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
513 hgsubversion.ui_active = False |
2726
aa17c7a1b8a5
Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
514 self.sa.add(hgsubversion) |
2705
bf177b4981c3
Add hgsubversion entry for RhodeCode UI (disabled by default)
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
515 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
516 # enable hggit disabled by default |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
517 hggit = RhodeCodeUi() |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
518 hggit.ui_section = 'extensions' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
519 hggit.ui_key = 'hggit' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
520 hggit.ui_value = '' |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
521 hggit.ui_active = False |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2705
diff
changeset
|
522 self.sa.add(hggit) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
523 |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
524 def create_ldap_options(self, skip_existing=False): |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
525 """Creates ldap settings""" |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
526 |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
527 for k, v in [('ldap_active', 'false'), ('ldap_host', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
528 ('ldap_port', '389'), ('ldap_tls_kind', 'PLAIN'), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
529 ('ldap_tls_reqcert', ''), ('ldap_dn_user', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
530 ('ldap_dn_pass', ''), ('ldap_base_dn', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
531 ('ldap_filter', ''), ('ldap_search_scope', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
532 ('ldap_attr_login', ''), ('ldap_attr_firstname', ''), |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
533 ('ldap_attr_lastname', ''), ('ldap_attr_email', '')]: |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
534 |
3889
b84c83b651de
replace equality comparision to None
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
535 if skip_existing and RhodeCodeSetting.get_by_name(k) is not None: |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
536 log.debug('Skipping option %s' % k) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
537 continue |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
538 setting = RhodeCodeSetting(k, v) |
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
539 self.sa.add(setting) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
540 |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
541 def create_default_options(self, skip_existing=False): |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
542 """Creates default settings""" |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
543 |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
544 for k, v in [ |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
545 ('default_repo_enable_locking', False), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
546 ('default_repo_enable_downloads', False), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
547 ('default_repo_enable_statistics', False), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
548 ('default_repo_private', False), |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
549 ('default_repo_type', 'hg')]: |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
550 |
3889
b84c83b651de
replace equality comparision to None
Marcin Kuzminski <marcin@python-works.com>
parents:
3840
diff
changeset
|
551 if skip_existing and RhodeCodeSetting.get_by_name(k) is not None: |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
552 log.debug('Skipping option %s' % k) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
553 continue |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
554 setting = RhodeCodeSetting(k, v) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
555 self.sa.add(setting) |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
556 |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
557 def fixup_groups(self): |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3733
diff
changeset
|
558 def_usr = User.get_default_user() |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
559 for g in RepoGroup.query().all(): |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
560 g.group_name = g.get_new_name(g.name) |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
561 self.sa.add(g) |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
562 # get default perm |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
563 default = UserRepoGroupToPerm.query()\ |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
564 .filter(UserRepoGroupToPerm.group == g)\ |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
565 .filter(UserRepoGroupToPerm.user == def_usr)\ |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
566 .scalar() |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
567 |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
568 if default is None: |
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
569 log.debug('missing default permission for group %s adding' % g) |
3714
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3671
diff
changeset
|
570 perm_obj = ReposGroupModel()._create_default_perms(g) |
7e3d89d9d3a2
- Manage User’s Groups: create, delete, rename, add/remove users inside.
Marcin Kuzminski <marcin@python-works.com>
parents:
3671
diff
changeset
|
571 self.sa.add(perm_obj) |
1985
40f04021fa61
Added group permission autofix for older version of rhodecode which didn't have default permissions for repos groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
572 |
2798
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
573 def reset_permissions(self, username): |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
574 """ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
575 Resets permissions to default state, usefull when old systems had |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
576 bad permissions, we must clean them up |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
577 |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
578 :param username: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
579 """ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
580 default_user = User.get_by_username(username) |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
581 if not default_user: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
582 return |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
583 |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
584 u2p = UserToPerm.query()\ |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
585 .filter(UserToPerm.user == default_user).all() |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
586 fixed = False |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
587 if len(u2p) != len(Permission.DEFAULT_USER_PERMISSIONS): |
2798
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
588 for p in u2p: |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
589 Session().delete(p) |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
590 fixed = True |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
591 self.populate_default_permissions() |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
592 return fixed |
091e99b29fd4
auto-healing of permissions for default user after upgrading from some old versions.
Marcin Kuzminski <marcin@python-works.com>
parents:
2797
diff
changeset
|
593 |
3309
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
594 def update_repo_info(self): |
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
595 RepoModel.update_repoinfo() |
b3cf4539d1bd
Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents:
3232
diff
changeset
|
596 |
2919
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
597 def config_prompt(self, test_repo_path='', retries=3): |
29630805893d
Implemented proposed changes from pull request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2918
diff
changeset
|
598 defaults = self.cli_args |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
599 _path = defaults.get('repos_location') |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
600 if retries == 3: |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
601 log.info('Setting up repositories config') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
602 |
2284
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
603 if _path is not None: |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
604 path = _path |
e285aa097a81
new setup-rhodecode command with optional defaults
Marcin Kuzminski <marcin@python-works.com>
parents:
2112
diff
changeset
|
605 elif not self.tests and not test_repo_path: |
1896
12135cff4c77
more user friendly message for repo path on setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1835
diff
changeset
|
606 path = raw_input( |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
607 'Enter a valid absolute path to store repositories. ' |
1896
12135cff4c77
more user friendly message for repo path on setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1835
diff
changeset
|
608 'All repositories in that path will be added automatically:' |
12135cff4c77
more user friendly message for repo path on setup
Marcin Kuzminski <marcin@python-works.com>
parents:
1835
diff
changeset
|
609 ) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
610 else: |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
611 path = test_repo_path |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
612 path_ok = True |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
613 |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
614 # check proper dir |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
327
diff
changeset
|
615 if not os.path.isdir(path): |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
616 path_ok = False |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
617 log.error('Given path %s is not a valid directory' % (path,)) |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
618 |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
619 elif not os.path.isabs(path): |
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
620 path_ok = False |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
621 log.error('Given path %s is not an absolute path' % (path,)) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
622 |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
623 # check if path is at least readable. |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
624 if not os.access(path, os.R_OK): |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
625 path_ok = False |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
626 log.error('Given path %s is not readable' % (path,)) |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
627 |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
628 # check write access, warn user about non writeable paths |
2112
1477e048292e
force and check for absolute path on rhodecode setup
Marcin Kuzminski <marcin@python-works.com>
parents:
2006
diff
changeset
|
629 elif not os.access(path, os.W_OK) and path_ok: |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
630 log.warn('No write permission to given path %s' % (path,)) |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
631 if not ask_ok('Given path %s is not writeable, do you want to ' |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
632 'continue with read only mode ? [y/n]' % (path,)): |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
633 log.error('Canceled by user') |
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
634 sys.exit(-1) |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
635 |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
636 if retries == 0: |
1399
4134af931e91
Added info about sys.exit cause
Marcin Kuzminski <marcin@python-works.com>
parents:
1299
diff
changeset
|
637 sys.exit('max retries reached') |
3625
260a7a01b054
follow Python conventions for boolean values
Mads Kiilerich <madski@unity3d.com>
parents:
3309
diff
changeset
|
638 if not path_ok: |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
639 retries -= 1 |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
640 return self.config_prompt(test_repo_path, retries) |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
641 |
2918
ce8572f45c85
use normpath when comparing paths used to determine if directory is a symlink, it's a part of pull-request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2907
diff
changeset
|
642 real_path = os.path.normpath(os.path.realpath(path)) |
2819
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
643 |
2918
ce8572f45c85
use normpath when comparing paths used to determine if directory is a symlink, it's a part of pull-request #77
Marcin Kuzminski <marcin@python-works.com>
parents:
2907
diff
changeset
|
644 if real_path != os.path.normpath(path): |
2819
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
645 if not ask_ok(('Path looks like a symlink, Rhodecode will store ' |
3980
3648a2b2e17a
accept that repos are read-only - very convenient for testing.
Marcin Kuzminski <marcin@python-works.com>
parents:
3972
diff
changeset
|
646 'given path as %s ? [y/n]') % (real_path,)): |
2819
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
647 log.error('Canceled by user') |
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
648 sys.exit(-1) |
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
649 |
bbaf0b86a1fe
Detect symlink in given repository path, and ask user if stored path should be were the symlink points
Marcin Kuzminski <marcin@python-works.com>
parents:
2798
diff
changeset
|
650 return real_path |
1094
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
651 |
44661d2a7b61
fixes #120 websetup command runs os.access on given path checking for write access
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
652 def create_settings(self, path): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
653 |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
654 self.create_ui_settings() |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
657
diff
changeset
|
655 |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
656 ui_config = [ |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
657 ('web', 'push_ssl', 'false'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
658 ('web', 'allow_archive', 'gz zip bz2'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
659 ('web', 'allow_push', '*'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
660 ('web', 'baseurl', '/'), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
661 ('paths', '/', path), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
662 #('phases', 'publish', 'false') |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
663 ] |
3911
7cca0d07c12b
fix: add UI settings to session
Marcin Kuzminski <marcin@python-works.com>
parents:
3910
diff
changeset
|
664 for section, key, value in ui_config: |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
665 ui_conf = RhodeCodeUi() |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
666 setattr(ui_conf, 'ui_section', section) |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
667 setattr(ui_conf, 'ui_key', key) |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
668 setattr(ui_conf, 'ui_value', value) |
3911
7cca0d07c12b
fix: add UI settings to session
Marcin Kuzminski <marcin@python-works.com>
parents:
3910
diff
changeset
|
669 self.sa.add(ui_conf) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
670 |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
671 settings = [ |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
672 ('realm', 'RhodeCode authentication', unicode), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
673 ('title', 'RhodeCode', unicode), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
674 ('ga_code', '', unicode), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
675 ('show_public_icon', True, bool), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
676 ('show_private_icon', True, bool), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
677 ('stylify_metatags', False, bool), |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
678 ('dashboard_items', 100, int), |
3910
36f7562a5919
Implements #842 RhodeCode version disclosure.
Marcin Kuzminski <marcin@python-works.com>
parents:
3909
diff
changeset
|
679 ('show_version', True, bool) |
3909
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
680 ] |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
681 for key, val, type_ in settings: |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
682 sett = RhodeCodeSetting(key, val) |
e87298ccdfdb
Add default for dashbord items and create default
Marcin Kuzminski <marcin@python-works.com>
parents:
3907
diff
changeset
|
683 self.sa.add(sett) |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
684 |
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
685 self.create_ldap_options() |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3052
diff
changeset
|
686 self.create_default_options() |
837
60cbde084047
fixed wrong migration schema
Marcin Kuzminski <marcin@python-works.com>
parents:
835
diff
changeset
|
687 |
341
1ef52a70f3b7
Made config file free configuration based on database and capable of beeing manage via application settings + some code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
327
diff
changeset
|
688 log.info('created ui config') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
597
diff
changeset
|
689 |
491
fefffd6fd5f4
Added some more tests, rewrite testing schema, to autogenerate fresh db, new index.
Marcin Kuzminski <marcin@python-works.com>
parents:
471
diff
changeset
|
690 def create_user(self, username, password, email='', admin=False): |
1976 | 691 log.info('creating user %s' % username) |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
692 UserModel().create_or_update(username, password, email, |
2513
388843a3a3c0
Updated create_or_update method to not change API key when password is not updated
Marcin Kuzminski <marcin@python-works.com>
parents:
2285
diff
changeset
|
693 firstname='RhodeCode', lastname='Admin', |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
694 active=True, admin=admin) |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
695 |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
696 def create_default_user(self): |
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
417
diff
changeset
|
697 log.info('creating default user') |
1634
1d904d972c47
User usermodel instead of db model to manage accounts
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
698 # create default user for handling default permissions. |
4028
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
699 user = UserModel().create_or_update(username=User.DEFAULT_USER, |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
700 password=str(uuid.uuid1())[:20], |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
701 email='anonymous@rhodecode.org', |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
702 firstname='Anonymous', |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
703 lastname='User') |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
704 # based on configuration options activate/deactive this user which |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
705 # controlls anonymous access |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
706 if self.cli_args.get('public_access') is False: |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
707 log.info('Public access disabled') |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
708 user.active = False |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
709 Session().add(user) |
c3245a0452a3
Added --no-public-access / --public-access flags into setup-rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
3980
diff
changeset
|
710 Session().commit() |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1716
diff
changeset
|
711 |
239
b18f89d6d17f
Adde draft for permissions systems, made all needed decorators, and checks. For future usage in the system.
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
712 def create_permissions(self): |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
713 """ |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
714 Creates all permissions defined in the system |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
715 """ |
1783
dde0ef0d886f
fixes #324 proper largefiles extension enable
Marcin Kuzminski <marcin@python-works.com>
parents:
1758
diff
changeset
|
716 # module.(access|create|change|delete)_[name] |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
717 # module.(none|read|write|admin) |
3734
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3733
diff
changeset
|
718 log.info('creating permissions') |
a8f520540ab0
New default permissions definition for user group create
Marcin Kuzminski <marcin@python-works.com>
parents:
3733
diff
changeset
|
719 PermissionModel(self.sa).create_permissions() |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
720 |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
721 def populate_default_permissions(self): |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
722 """ |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
723 Populate default permissions. It will create only the default |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
724 permissions that are missing, and not alter already defined ones |
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
725 """ |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
392
diff
changeset
|
726 log.info('creating default user permissions') |
3733
af049a957506
fixed default permissions population during upgrades
Marcin Kuzminski <marcin@python-works.com>
parents:
3714
diff
changeset
|
727 PermissionModel(self.sa).create_default_permissions(user=User.DEFAULT_USER) |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
728 |
3232
99c093d1a142
run waitress check on startup
Marcin Kuzminski <marcin@python-works.com>
parents:
3148
diff
changeset
|
729 @staticmethod |
99c093d1a142
run waitress check on startup
Marcin Kuzminski <marcin@python-works.com>
parents:
3148
diff
changeset
|
730 def check_waitress(): |
2827
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
731 """ |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
732 Function executed at the end of setup |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
733 """ |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
734 if not __py_version__ >= (2, 6): |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
735 notify('Python2.5 detected, please switch ' |
d30c0a9867c4
warn user about not using waitress on python2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
2819
diff
changeset
|
736 'egg:waitress#main -> egg:Paste#http ' |
2907
0b86972de820
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2827
diff
changeset
|
737 'in your .ini file') |