##// END OF EJS Templates
Implements #648 write Script for updating last modification time for lightweight dashboard
marcink -
r3006:9b95dc7c beta
parent child Browse files
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 )
@@ -1,166 +1,167 b''
1 1 import os
2 2 import sys
3 3 import platform
4 4
5 5 if sys.version_info < (2, 5):
6 6 raise Exception('RhodeCode requires python 2.5 or later')
7 7
8 8
9 9 here = os.path.abspath(os.path.dirname(__file__))
10 10
11 11
12 12 def _get_meta_var(name, data, callback_handler=None):
13 13 import re
14 14 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
15 15 if matches:
16 16 if not callable(callback_handler):
17 17 callback_handler = lambda v: v
18 18
19 19 return callback_handler(eval(matches.groups()[0]))
20 20
21 21 _meta = open(os.path.join(here, 'rhodecode', '__init__.py'), 'rb')
22 22 _metadata = _meta.read()
23 23 _meta.close()
24 24
25 25 callback = lambda V: ('.'.join(map(str, V[:3])) + '.'.join(V[3:]))
26 26 __version__ = _get_meta_var('VERSION', _metadata, callback)
27 27 __license__ = _get_meta_var('__license__', _metadata)
28 28 __author__ = _get_meta_var('__author__', _metadata)
29 29 __url__ = _get_meta_var('__url__', _metadata)
30 30 # defines current platform
31 31 __platform__ = platform.system()
32 32
33 33 is_windows = __platform__ in _get_meta_var('PLATFORM_WIN', _metadata)
34 34
35 35 requirements = [
36 36 "waitress==0.8.1",
37 37 "webob==1.0.8",
38 38 "Pylons==1.0.0",
39 39 "Beaker==1.6.4",
40 40 "WebHelpers==1.3",
41 41 "formencode==1.2.4",
42 42 "SQLAlchemy==0.7.9",
43 43 "Mako==0.7.3",
44 44 "pygments>=1.5",
45 45 "whoosh>=2.4.0,<2.5",
46 46 "celery>=2.2.5,<2.3",
47 47 "babel",
48 48 "python-dateutil>=1.5.0,<2.0.0",
49 49 "dulwich>=0.8.6,<0.9.0",
50 50 "markdown==2.2.1",
51 51 "docutils==0.8.1",
52 52 "simplejson==2.5.2",
53 53 "mock",
54 54 ]
55 55
56 56 if sys.version_info < (2, 6):
57 57 requirements.append("pysqlite")
58 58
59 59 if sys.version_info < (2, 7):
60 60 requirements.append("unittest2")
61 61
62 62 if is_windows:
63 63 requirements.append("mercurial==2.4.0")
64 64 else:
65 65 requirements.append("py-bcrypt")
66 66 requirements.append("mercurial==2.4.0")
67 67
68 68
69 69 dependency_links = [
70 70 ]
71 71
72 72 classifiers = [
73 73 'Development Status :: 4 - Beta',
74 74 'Environment :: Web Environment',
75 75 'Framework :: Pylons',
76 76 'Intended Audience :: Developers',
77 77 'License :: OSI Approved :: GNU General Public License (GPL)',
78 78 'Operating System :: OS Independent',
79 79 'Programming Language :: Python',
80 80 'Programming Language :: Python :: 2.5',
81 81 'Programming Language :: Python :: 2.6',
82 82 'Programming Language :: Python :: 2.7',
83 83 ]
84 84
85 85
86 86 # additional files from project that goes somewhere in the filesystem
87 87 # relative to sys.prefix
88 88 data_files = []
89 89
90 90 # additional files that goes into package itself
91 91 package_data = {'rhodecode': ['i18n/*/LC_MESSAGES/*.mo', ], }
92 92
93 93 description = ('Mercurial repository browser/management with '
94 94 'build in push/pull server and full text search')
95 95 keywords = ' '.join(['rhodecode', 'rhodiumcode', 'mercurial', 'git',
96 96 'code review', 'repo groups', 'ldap'
97 97 'repository management', 'hgweb replacement'
98 98 'hgwebdir', 'gitweb replacement', 'serving hgweb', ])
99 99 # long description
100 100 try:
101 101 readme_file = 'README.rst'
102 102 changelog_file = 'docs/changelog.rst'
103 103 long_description = open(readme_file).read() + '\n\n' + \
104 104 open(changelog_file).read()
105 105
106 106 except IOError, err:
107 107 sys.stderr.write("[WARNING] Cannot find file specified as "
108 108 "long_description (%s)\n or changelog (%s) skipping that file" \
109 109 % (readme_file, changelog_file))
110 110 long_description = description
111 111
112 112
113 113 try:
114 114 from setuptools import setup, find_packages
115 115 except ImportError:
116 116 from ez_setup import use_setuptools
117 117 use_setuptools()
118 118 from setuptools import setup, find_packages
119 119 # packages
120 120 packages = find_packages(exclude=['ez_setup'])
121 121
122 122 setup(
123 123 name='RhodeCode',
124 124 version=__version__,
125 125 description=description,
126 126 long_description=long_description,
127 127 keywords=keywords,
128 128 license=__license__,
129 129 author=__author__,
130 130 author_email='marcin@python-works.com',
131 131 dependency_links=dependency_links,
132 132 url=__url__,
133 133 install_requires=requirements,
134 134 classifiers=classifiers,
135 135 setup_requires=["PasteScript>=1.6.3"],
136 136 data_files=data_files,
137 137 packages=packages,
138 138 include_package_data=True,
139 139 test_suite='nose.collector',
140 140 package_data=package_data,
141 141 message_extractors={'rhodecode': [
142 142 ('**.py', 'python', None),
143 143 ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
144 144 ('templates/**.html', 'mako', {'input_encoding': 'utf-8'}),
145 145 ('public/**', 'ignore', None)]},
146 146 zip_safe=False,
147 147 paster_plugins=['PasteScript', 'Pylons'],
148 148 entry_points="""
149 149 [console_scripts]
150 150 rhodecode-api = rhodecode.bin.rhodecode_api:main
151 151
152 152 [paste.app_factory]
153 153 main = rhodecode.config.middleware:make_app
154 154
155 155 [paste.app_install]
156 156 main = pylons.util:PylonsInstaller
157 157
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
164 165 celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand
165 166 """,
166 167 )
General Comments 0
You need to be logged in to leave comments. Login now