annotate rhodecode/lib/paster_commands/cleanup.py @ 3340:f1491bad8339 beta

unified RhodeCode paster commands - moved them to commont paster_commands package - re-use sqlalchemy session initializaiton - some docs updates
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 09 Feb 2013 22:21:31 +0100
parents rhodecode/lib/cleanup.py@f62d805544a4
children c8fd8cca71f2
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 """
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
3 rhodecode.lib.paster_commands.make_rcextensions
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
5
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
6 cleanup-repos paster command for RhodeCode
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
7
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :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
10 :author: marcink
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 :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
12 :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
13 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # 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
15 # 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
16 # 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
17 # (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
18 #
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # 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
20 # 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
21 # 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
22 # 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
23 #
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 # 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
25 # 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
26 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
27
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import os
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 import sys
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 import re
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 import shutil
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 import logging
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 import datetime
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 from os.path import dirname as dn, join as jn
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
36 #to get the rhodecode import
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
37 rc_path = dn(dn(dn(os.path.realpath(__file__))))
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
38 sys.path.append(rc_path)
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
39 from rhodecode.lib.utils import BasePasterCommand, ask_ok, REMOVED_REPO_PAT
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
40
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
41 from rhodecode.lib.utils2 import safe_str
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 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
43
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 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
46
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
48 class Command(BasePasterCommand):
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 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
51 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
52
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 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
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
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
56 parser = BasePasterCommand.standard_parser(verbose=True)
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
57 summary = "Cleanup deleted repos"
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 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
60 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
61 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
62 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
63 return
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 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
65 time_params = {}
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 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
67 if param:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 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
69 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
70
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 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
72 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 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
74 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
75
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 :param name:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 """
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 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
79 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
80
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 def command(self):
3340
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
82 #get SqlAlchemy session
f1491bad8339 unified RhodeCode paster commands
Marcin Kuzminski <marcin@python-works.com>
parents: 3336
diff changeset
83 self._init_session()
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 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
86 to_remove = []
2963
742d1b8ca263 use str() on os.walk passing unicode can lead to UnicodeDecode errors when iterating
Marcin Kuzminski <marcin@python-works.com>
parents: 2962
diff changeset
87 for dn, dirs, f in os.walk(safe_str(repos_location)):
2962
c400f2fbf131 cleanup script walks recursive on dirs to find repos to cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2925
diff changeset
88 for loc in dirs:
c400f2fbf131 cleanup script walks recursive on dirs to find repos to cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2925
diff changeset
89 if REMOVED_REPO_PAT.match(loc):
3336
f62d805544a4 fixes issue #756 cleanup repos didn't properly compose paths of repos to be cleaned up.
Marcin Kuzminski <marcin@python-works.com>
parents: 2963
diff changeset
90 to_remove.append([os.path.join(dn, loc),
f62d805544a4 fixes issue #756 cleanup repos didn't properly compose paths of repos to be cleaned up.
Marcin Kuzminski <marcin@python-works.com>
parents: 2963
diff changeset
91 self._extract_date(loc)])
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 #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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103
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 = 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
105 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
106 % (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
107 else:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 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
109 % 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
110 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
111 # 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
112 remove = True
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 else:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 remove = ask_ok('are you sure to remove listed repos \n%s [y/n]?'
2925
381eea235ae7 fix unicode issues on cleanup-repos script
Marcin Kuzminski <marcin@python-works.com>
parents: 2673
diff changeset
115 % ', \n'.join(['%s removed on %s'
381eea235ae7 fix unicode issues on cleanup-repos script
Marcin Kuzminski <marcin@python-works.com>
parents: 2673
diff changeset
116 % (safe_str(x[0]), safe_str(x[1])) for x in to_remove]))
2602
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118 if remove:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 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
120 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
121 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
122 else:
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 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
124 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
125
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126 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
127 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
128 action='store',
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 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
130 help=(
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 "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
132 "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
133 "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
134 "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
135 "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
136 )
17083006a33d Added cleanup repos script that allows to cleanup removed repos from rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 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
138 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
139 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
140 help=("Don't ask to remove repos"))