Show More
@@ -0,0 +1,85 b'' | |||
|
1 | # -*- coding: utf-8 -*- | |
|
2 | """ | |
|
3 | package.rhodecode.lib.cleanup | |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
|
5 | ||
|
6 | :created_on: Jul 14, 2012 | |
|
7 | :author: marcink | |
|
8 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> | |
|
9 | :license: GPLv3, see COPYING for more details. | |
|
10 | """ | |
|
11 | # This program is free software: you can redistribute it and/or modify | |
|
12 | # it under the terms of the GNU General Public License as published by | |
|
13 | # the Free Software Foundation, either version 3 of the License, or | |
|
14 | # (at your option) any later version. | |
|
15 | # | |
|
16 | # This program is distributed in the hope that it will be useful, | |
|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
19 | # GNU General Public License for more details. | |
|
20 | # | |
|
21 | # You should have received a copy of the GNU General Public License | |
|
22 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
|
23 | from __future__ import with_statement | |
|
24 | ||
|
25 | import os | |
|
26 | import sys | |
|
27 | import re | |
|
28 | import shutil | |
|
29 | import logging | |
|
30 | import datetime | |
|
31 | import string | |
|
32 | ||
|
33 | from os.path import dirname as dn, join as jn | |
|
34 | from rhodecode.model import init_model | |
|
35 | from rhodecode.lib.utils2 import engine_from_config, safe_str | |
|
36 | from rhodecode.model.db import RhodeCodeUi, Repository | |
|
37 | ||
|
38 | ||
|
39 | #to get the rhodecode import | |
|
40 | sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) | |
|
41 | ||
|
42 | from rhodecode.lib.utils import BasePasterCommand, Command, add_cache | |
|
43 | ||
|
44 | log = logging.getLogger(__name__) | |
|
45 | ||
|
46 | ||
|
47 | class UpdateCommand(BasePasterCommand): | |
|
48 | ||
|
49 | max_args = 1 | |
|
50 | min_args = 1 | |
|
51 | ||
|
52 | usage = "CONFIG_FILE" | |
|
53 | summary = "Cleanup deleted repos" | |
|
54 | group_name = "RhodeCode" | |
|
55 | takes_config_file = -1 | |
|
56 | parser = Command.standard_parser(verbose=True) | |
|
57 | ||
|
58 | def command(self): | |
|
59 | logging.config.fileConfig(self.path_to_ini_file) | |
|
60 | from pylons import config | |
|
61 | ||
|
62 | #get to remove repos !! | |
|
63 | add_cache(config) | |
|
64 | engine = engine_from_config(config, 'sqlalchemy.db1.') | |
|
65 | init_model(engine) | |
|
66 | ||
|
67 | repo_update_list = map(string.strip, | |
|
68 | self.options.repo_update_list.split(',')) \ | |
|
69 | if self.options.repo_update_list else None | |
|
70 | ||
|
71 | if repo_update_list: | |
|
72 | repo_list = Repository.query().filter(Repository.repo_name.in_(repo_update_list)) | |
|
73 | else: | |
|
74 | repo_list = Repository.getAll() | |
|
75 | for repo in repo_list: | |
|
76 | last_change = repo.scm_instance.last_change | |
|
77 | repo.update_last_change(last_change) | |
|
78 | ||
|
79 | def update_parser(self): | |
|
80 | self.parser.add_option('--update-only', | |
|
81 | action='store', | |
|
82 | dest='repo_update_list', | |
|
83 | help="Specifies a comma separated list of repositores " | |
|
84 | "to update last commit info for. OPTIONAL", | |
|
85 | ) |
@@ -158,6 +158,7 b' setup(' | |||
|
158 | 158 | [paste.global_paster_command] |
|
159 | 159 | setup-rhodecode=rhodecode.config.setup_rhodecode:SetupCommand |
|
160 | 160 | cleanup-repos=rhodecode.lib.cleanup:CleanupCommand |
|
161 | update-repoinfo=rhodecode.lib.update_repoinfo:UpdateCommand | |
|
161 | 162 | make-index=rhodecode.lib.indexers:MakeIndex |
|
162 | 163 | make-rcext=rhodecode.config.rcextensions.make_rcextensions:MakeRcExt |
|
163 | 164 | upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb |
General Comments 0
You need to be logged in to leave comments.
Login now