##// END OF EJS Templates
small formatting
marcink -
r3991:68abb78a default
parent child Browse files
Show More
@@ -1,70 +1,71
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.lib.paster_commands.make_rcextensions
3 rhodecode.lib.paster_commands.make_rcextensions
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 repo-scan paster command for RhodeCode
6 repo-scan paster command for RhodeCode
7
7
8
8
9 :created_on: Feb 9, 2013
9 :created_on: Feb 9, 2013
10 :author: marcink
10 :author: marcink
11 :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com>
11 :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com>
12 :license: GPLv3, see COPYING for more details.
12 :license: GPLv3, see COPYING for more details.
13 """
13 """
14 # This program is free software: you can redistribute it and/or modify
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
17 # (at your option) any later version.
18 #
18 #
19 # This program is distributed in the hope that it will be useful,
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
22 # GNU General Public License for more details.
23 #
23 #
24 # You should have received a copy of the GNU General Public License
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 from __future__ import with_statement
26 from __future__ import with_statement
27
27
28 import os
28 import os
29 import sys
29 import sys
30 import logging
30 import logging
31
31
32 from rhodecode.model.scm import ScmModel
32 from rhodecode.model.scm import ScmModel
33 from rhodecode.lib.utils import BasePasterCommand, repo2db_mapper
33 from rhodecode.lib.utils import BasePasterCommand, repo2db_mapper
34
34
35 # fix rhodecode import
35 # fix rhodecode import
36 from os.path import dirname as dn
36 from os.path import dirname as dn
37 rc_path = dn(dn(dn(os.path.realpath(__file__))))
37 rc_path = dn(dn(dn(os.path.realpath(__file__))))
38 sys.path.append(rc_path)
38 sys.path.append(rc_path)
39
39
40 log = logging.getLogger(__name__)
40 log = logging.getLogger(__name__)
41
41
42
42
43 class Command(BasePasterCommand):
43 class Command(BasePasterCommand):
44
44
45 max_args = 1
45 max_args = 1
46 min_args = 1
46 min_args = 1
47
47
48 usage = "CONFIG_FILE"
48 usage = "CONFIG_FILE"
49 group_name = "RhodeCode"
49 group_name = "RhodeCode"
50 takes_config_file = -1
50 takes_config_file = -1
51 parser = BasePasterCommand.standard_parser(verbose=True)
51 parser = BasePasterCommand.standard_parser(verbose=True)
52 summary = "Rescan default location for new repositories"
52 summary = "Rescan default location for new repositories"
53
53
54 def command(self):
54 def command(self):
55 #get SqlAlchemy session
55 #get SqlAlchemy session
56 self._init_session()
56 self._init_session()
57 rm_obsolete = self.options.delete_obsolete
57 rm_obsolete = self.options.delete_obsolete
58 log.info('Now scanning root location for new repos...')
58 log.info('Now scanning root location for new repos...')
59 added, removed = repo2db_mapper(ScmModel().repo_scan(),
59 added, removed = repo2db_mapper(ScmModel().repo_scan(),
60 remove_obsolete=rm_obsolete)
60 remove_obsolete=rm_obsolete)
61 added = ', '.join(added) or '-'
61 added = ', '.join(added) or '-'
62 removed = ', '.join(removed) or '-'
62 removed = ', '.join(removed) or '-'
63 log.info('Scan completed added: %s removed:%s' % (added, removed))
63 log.info('Scan completed added: %s removed: %s' % (added, removed))
64
64
65 def update_parser(self):
65 def update_parser(self):
66 self.parser.add_option('--delete-obsolete',
66 self.parser.add_option(
67 action='store_true',
67 '--delete-obsolete',
68 help="Use this flag do delete repositories that are "
68 action='store_true',
69 "present in RhodeCode database but not on the filesystem",
69 help="Use this flag do delete repositories that are "
70 )
70 "present in RhodeCode database but not on the filesystem",
71 )
General Comments 0
You need to be logged in to leave comments. Login now