annotate rhodecode/lib/update_repoinfo.py @ 3334:968b28545f93 beta

fixed description of update-repoinfo command
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 08 Feb 2013 19:08:52 +0100
parents b3cf4539d1bd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 package.rhodecode.lib.cleanup
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 :created_on: Jul 14, 2012
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 :author: marcink
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :license: GPLv3, see COPYING for more details.
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 """
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 # This program is free software: you can redistribute it and/or modify
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # it under the terms of the GNU General Public License as published by
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # the Free Software Foundation, either version 3 of the License, or
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # (at your option) any later version.
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 #
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # This program is distributed in the hope that it will be useful,
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # GNU General Public License for more details.
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 #
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 from __future__ import with_statement
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 import os
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 import sys
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 import re
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import shutil
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 import logging
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 import datetime
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 import string
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 from os.path import dirname as dn, join as jn
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 from rhodecode.model import init_model
3309
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
35 from rhodecode.lib.utils2 import engine_from_config
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
36 from rhodecode.model.db import Repository
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
37 from rhodecode.model.repo import RepoModel
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
38 from rhodecode.model.meta import Session
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 #to get the rhodecode import
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 sys.path.append(dn(dn(dn(os.path.realpath(__file__)))))
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 from rhodecode.lib.utils import BasePasterCommand, Command, add_cache
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 log = logging.getLogger(__name__)
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 class UpdateCommand(BasePasterCommand):
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 max_args = 1
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 min_args = 1
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 usage = "CONFIG_FILE"
3334
968b28545f93 fixed description of update-repoinfo command
Marcin Kuzminski <marcin@python-works.com>
parents: 3309
diff changeset
55 summary = "Updates repositories caches for last changeset"
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 group_name = "RhodeCode"
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 takes_config_file = -1
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 parser = Command.standard_parser(verbose=True)
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 def command(self):
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 logging.config.fileConfig(self.path_to_ini_file)
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 from pylons import config
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 #get to remove repos !!
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 add_cache(config)
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 engine = engine_from_config(config, 'sqlalchemy.db1.')
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 init_model(engine)
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 repo_update_list = map(string.strip,
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 self.options.repo_update_list.split(',')) \
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 if self.options.repo_update_list else None
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 if repo_update_list:
3309
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
74 repo_list = Repository.query()\
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
75 .filter(Repository.repo_name.in_(repo_update_list))
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 else:
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 repo_list = Repository.getAll()
3309
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
78 RepoModel.update_repoinfo(repositories=repo_list)
b3cf4539d1bd Added missing migrations, and move update_repoinfo to RepoModel
Marcin Kuzminski <marcin@python-works.com>
parents: 3147
diff changeset
79 Session().commit()
3006
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 def update_parser(self):
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 self.parser.add_option('--update-only',
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 action='store',
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 dest='repo_update_list',
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 help="Specifies a comma separated list of repositores "
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 "to update last commit info for. OPTIONAL",
9b95dc7c4570 Implements #648 write Script for updating last modification time for lightweight dashboard
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 )