annotate rhodecode/lib/cleanup.py @ 2602:17083006a33d beta

Added cleanup repos script that allows to cleanup removed repos from rhodecode older than given amount of time units.
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 14 Jul 2012 18:53:39 +0200
parents
children d5e42c00f3c1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 package.rhodecode.lib.cleanup
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 :created_on: Jul 14, 2012
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 :author: marcink
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :license: GPLv3, see COPYING for more details.
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 # This program is free software: you can redistribute it and/or modify
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # it under the terms of the GNU General Public License as published by
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # the Free Software Foundation, either version 3 of the License, or
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # (at your option) any later version.
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 #
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # This program is distributed in the hope that it will be useful,
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # GNU General Public License for more details.
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 #
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 from __future__ import with_statement
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 import os
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 import sys
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 import re
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import shutil
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 import logging
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 import datetime
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 from os.path import dirname as dn, join as jn
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 from rhodecode.model import init_model
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 from rhodecode.lib.utils2 import engine_from_config
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 from rhodecode.model.db import RhodeCodeUi
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 #to get the rhodecode import
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 from rhodecode.lib.utils import BasePasterCommand, Command, ask_ok,\
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 REMOVED_REPO_PAT, add_cache
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 log = logging.getLogger(__name__)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 class CleanupCommand(BasePasterCommand):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 max_args = 1
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 min_args = 1
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 usage = "CONFIG_FILE"
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 summary = "Cleanup deleted repos"
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 group_name = "RhodeCode"
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 takes_config_file = -1
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 parser = Command.standard_parser(verbose=True)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 def _parse_older_than(self, val):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 regex = re.compile(r'((?P<days>\d+?)d)?((?P<hours>\d+?)h)?((?P<minutes>\d+?)m)?((?P<seconds>\d+?)s)?')
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 parts = regex.match(val)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 if not parts:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 return
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 parts = parts.groupdict()
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 time_params = {}
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 for (name, param) in parts.iteritems():
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 if param:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 time_params[name] = int(param)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 return datetime.timedelta(**time_params)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 def _extract_date(self, name):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 Extract the date part from rm__<date> pattern of removed repos,
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 and convert it to datetime object
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 :param name:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 date_part = name[4:19] # 4:19 since we don't parse milisecods
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 return datetime.datetime.strptime(date_part, '%Y%m%d_%H%M%S')
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 def command(self):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 logging.config.fileConfig(self.path_to_ini_file)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 from pylons import config
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 #get to remove repos !!
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 add_cache(config)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 engine = engine_from_config(config, 'sqlalchemy.db1.')
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 init_model(engine)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 repos_location = RhodeCodeUi.get_repos_location()
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 to_remove = []
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 for loc in os.listdir(repos_location):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 if REMOVED_REPO_PAT.match(loc):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 to_remove.append([loc, self._extract_date(loc)])
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 #filter older than (if present)!
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 now = datetime.datetime.now()
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 older_than = self.options.older_than
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98 if older_than:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 to_remove_filtered = []
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 older_than_date = self._parse_older_than(older_than)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 for name, date_ in to_remove:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102 repo_age = now - date_
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103 if repo_age > older_than_date:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 to_remove_filtered.append([name, date_])
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106 to_remove = to_remove_filtered
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 print >> sys.stdout, 'removing [%s] deleted repos older than %s[%s]' \
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 % (len(to_remove), older_than, older_than_date)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 else:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 print >> sys.stdout, 'removing all [%s] deleted repos' \
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
111 % len(to_remove)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 if self.options.dont_ask or not to_remove:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 # don't ask just remove !
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 remove = True
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115 else:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 remove = ask_ok('are you sure to remove listed repos \n%s [y/n]?'
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 % ', \n'.join(['%s removed on %s' % (x[0], x[1])
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118 for x in to_remove]))
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 if remove:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121 for name, date_ in to_remove:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122 print >> sys.stdout, 'removing repository %s' % name
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 shutil.rmtree(os.path.join(repos_location, name))
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 else:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125 print 'nothing done exiting...'
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126 sys.exit(0)
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 def update_parser(self):
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 self.parser.add_option('--older-than',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130 action='store',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 dest='older_than',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132 help=(
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133 "only remove repos that have been removed "
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134 "at least given time ago "
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 "ex. --older-than=30d deletes repositores "
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 "removed more than 30days ago. Possible options "
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 "d[ays]/h[ours]/m[inutes]/s[seconds]. OPTIONAL"),
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 )
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 self.parser.add_option('--dont-ask',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140 action='store_true',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
141 dest='dont_ask',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
142 help=("Don't ask to remove repos"))
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143