Mercurial > kallithea
comparison rhodecode/config/rcextensions/make_rcextensions.py @ 2105:926f55b038bc beta
added initial rc-extension module
- possible to store additional mappings for stats
- possible to overwrite and add to whoosh index extensions
issue #322
- post create repo hook callback
- post push/pull hooks callback
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 06 Mar 2012 23:03:10 +0200 |
parents | |
children | 8ecfed1d8f8b |
comparison
equal
deleted
inserted
replaced
2104:f21f66abb4f7 | 2105:926f55b038bc |
---|---|
1 # -*- coding: utf-8 -*- | |
2 """ | |
3 rhodecode.config.rcextensions.make_rcextensions | |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 | |
6 Whoosh indexing module for RhodeCode | |
7 | |
8 :created_on: Mar 6, 2012 | |
9 :author: marcink | |
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> | |
11 :license: GPLv3, see COPYING for more details. | |
12 """ | |
13 # This program is free software: you can redistribute it and/or modify | |
14 # it under the terms of the GNU General Public License as published by | |
15 # the Free Software Foundation, either version 3 of the License, or | |
16 # (at your option) any later version. | |
17 # | |
18 # This program is distributed in the hope that it will be useful, | |
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 # GNU General Public License for more details. | |
22 # | |
23 # You should have received a copy of the GNU General Public License | |
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 import os | |
26 import sys | |
27 import pkg_resources | |
28 import traceback | |
29 import logging | |
30 from os.path import dirname as dn, join as jn | |
31 | |
32 #to get the rhodecode import | |
33 sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) | |
34 | |
35 from rhodecode.lib.utils import BasePasterCommand, Command, ask_ok | |
36 | |
37 log = logging.getLogger(__name__) | |
38 | |
39 | |
40 class MakeRcExt(BasePasterCommand): | |
41 | |
42 max_args = 1 | |
43 min_args = 1 | |
44 | |
45 usage = "CONFIG_FILE" | |
46 summary = "Creates additional extensions for rhodecode" | |
47 group_name = "RhodeCode" | |
48 takes_config_file = -1 | |
49 parser = Command.standard_parser(verbose=True) | |
50 | |
51 def command(self): | |
52 logging.config.fileConfig(self.path_to_ini_file) | |
53 from pylons import config | |
54 | |
55 def _make_file(ext_file): | |
56 bdir = os.path.split(ext_file)[0] | |
57 if not os.path.isdir(bdir): | |
58 os.makedirs(bdir) | |
59 with open(ext_file, 'wb') as f: | |
60 f.write(tmpl) | |
61 log.info('Writen new extensions file to %s' % ext_file) | |
62 | |
63 here = config['here'] | |
64 tmpl = pkg_resources.resource_string( | |
65 'rhodecode', jn('config', 'rcextensions', '__init__.py') | |
66 ) | |
67 ext_file = jn(here, 'rcextensions', '__init__.py') | |
68 if os.path.exists(ext_file): | |
69 msg = ('Extension file already exists, do you want ' | |
70 'to overwrite it ? [y/n]') | |
71 if ask_ok(msg): | |
72 _make_file(ext_file) | |
73 else: | |
74 log.info('nothing done...') | |
75 else: | |
76 _make_file(ext_file) | |
77 | |
78 def update_parser(self): | |
79 pass | |
80 | |
81 |