Show More
@@ -68,16 +68,21 b' You are now ready to use Kallithea. To r' | |||||
68 | settings, as well as edit more advanced options on users and |
|
68 | settings, as well as edit more advanced options on users and | |
69 | repositories |
|
69 | repositories | |
70 |
|
70 | |||
|
71 | ||||
|
72 | Extensions | |||
|
73 | ---------- | |||
|
74 | ||||
71 | Optionally users can create an ``rcextensions`` package that extends Kallithea |
|
75 | Optionally users can create an ``rcextensions`` package that extends Kallithea | |
72 | functionality. To do this simply execute:: |
|
76 | functionality. To do this simply execute:: | |
73 |
|
77 | |||
74 | paster make-rcext my.ini |
|
78 | paster make-rcext my.ini | |
75 |
|
79 | |||
76 |
This will create an ``rcextensions`` package |
|
80 | This will create an ``rcextensions`` package next to the specified ``ini`` file. | |
77 |
|
|
81 | With ``rcextensions`` it's possible to add additional mapping for whoosh, | |
78 | stats and add additional code into the push/pull/create/delete repo hooks, |
|
82 | stats and add additional code into the push/pull/create/delete repo hooks, | |
79 |
for example |
|
83 | for example for sending signals to build-bots such as Jenkins. | |
80 | Please see the ``__init__.py`` file inside ``rcextensions`` package |
|
84 | ||
|
85 | See the ``__init__.py`` file inside the generated ``rcextensions`` package | |||
81 | for more details. |
|
86 | for more details. | |
82 |
|
87 | |||
83 |
|
88 |
@@ -30,7 +30,6 b' from __future__ import with_statement' | |||||
30 |
|
30 | |||
31 | import os |
|
31 | import os | |
32 | import sys |
|
32 | import sys | |
33 | import logging |
|
|||
34 | import pkg_resources |
|
33 | import pkg_resources | |
35 |
|
34 | |||
36 | from kallithea.lib.utils import BasePasterCommand, ask_ok |
|
35 | from kallithea.lib.utils import BasePasterCommand, ask_ok | |
@@ -40,46 +39,44 b' from os.path import dirname as dn' | |||||
40 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
39 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
41 | sys.path.append(rc_path) |
|
40 | sys.path.append(rc_path) | |
42 |
|
41 | |||
43 | log = logging.getLogger(__name__) |
|
|||
44 |
|
||||
45 |
|
42 | |||
46 | class Command(BasePasterCommand): |
|
43 | class Command(BasePasterCommand): | |
47 |
|
44 | |||
48 | max_args = 1 |
|
45 | max_args = 1 | |
49 | min_args = 1 |
|
46 | min_args = 1 | |
50 |
|
47 | |||
51 | usage = "CONFIG_FILE" |
|
|||
52 | group_name = "Kallithea" |
|
48 | group_name = "Kallithea" | |
53 | takes_config_file = -1 |
|
49 | takes_config_file = -1 | |
54 | parser = BasePasterCommand.standard_parser(verbose=True) |
|
50 | parser = BasePasterCommand.standard_parser(verbose=True) | |
55 |
summary = " |
|
51 | summary = "Write template file for extending Kallithea in Python." | |
|
52 | usage = "CONFIG_FILE" | |||
|
53 | description = '''\ | |||
|
54 | A rcextensions directory with a __init__.py file will be created next to | |||
|
55 | the ini file. Local customizations in that file will survive upgrades. | |||
|
56 | The file contains instructions on how it can be customized. | |||
|
57 | ''' | |||
56 |
|
58 | |||
57 | def command(self): |
|
59 | def command(self): | |
58 | logging.config.fileConfig(self.path_to_ini_file) |
|
|||
59 | from pylons import config |
|
60 | from pylons import config | |
60 |
|
61 | |||
61 | def _make_file(ext_file, tmpl): |
|
|||
62 | bdir = os.path.split(ext_file)[0] |
|
|||
63 | if not os.path.isdir(bdir): |
|
|||
64 | os.makedirs(bdir) |
|
|||
65 | with open(ext_file, 'wb') as f: |
|
|||
66 | f.write(tmpl) |
|
|||
67 | log.info('Writen new extensions file to %s' % ext_file) |
|
|||
68 |
|
||||
69 | here = config['here'] |
|
62 | here = config['here'] | |
70 |
|
|
63 | content = pkg_resources.resource_string( | |
71 | 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') |
|
64 | 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') | |
72 | ) |
|
65 | ) | |
73 | ext_file = os.path.join(here, 'rcextensions', '__init__.py') |
|
66 | ext_file = os.path.join(here, 'rcextensions', '__init__.py') | |
74 | if os.path.exists(ext_file): |
|
67 | if os.path.exists(ext_file): | |
75 | msg = ('Extension file already exists, do you want ' |
|
68 | msg = ('Extension file already exists, do you want ' | |
76 | 'to overwrite it ? [y/n]') |
|
69 | 'to overwrite it ? [y/n]') | |
77 | if ask_ok(msg): |
|
70 | if not ask_ok(msg): | |
78 | _make_file(ext_file, tmpl) |
|
71 | print 'Nothing done...' | |
79 |
|
|
72 | return | |
80 | log.info('nothing done...') |
|
73 | ||
81 | else: |
|
74 | dirname = os.path.dirname(ext_file) | |
82 | _make_file(ext_file, tmpl) |
|
75 | if not os.path.isdir(dirname): | |
|
76 | os.makedirs(dirname) | |||
|
77 | with open(ext_file, 'wb') as f: | |||
|
78 | f.write(content) | |||
|
79 | print 'Wrote new extensions file to %s' % ext_file | |||
83 |
|
80 | |||
84 | def update_parser(self): |
|
81 | def update_parser(self): | |
85 | pass |
|
82 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now