# HG changeset patch # User Mads Kiilerich # Date 2015-04-28 16:55:05 # Node ID faf943716616721440c0859597785a41a8da8373 # Parent 42c6d8e4a0de72adf924096ce3108c95b9a84966 rcextensions: cleanup of code and documentation More cleanup is needed - this is just to clarify what it currently does. diff --git a/docs/setup.rst b/docs/setup.rst --- a/docs/setup.rst +++ b/docs/setup.rst @@ -68,16 +68,21 @@ You are now ready to use Kallithea. To r settings, as well as edit more advanced options on users and repositories + +Extensions +---------- + Optionally users can create an ``rcextensions`` package that extends Kallithea functionality. To do this simply execute:: paster make-rcext my.ini -This will create an ``rcextensions`` package in the same place that your ``ini`` file -lives. With ``rcextensions`` it's possible to add additional mapping for whoosh, +This will create an ``rcextensions`` package next to the specified ``ini`` file. +With ``rcextensions`` it's possible to add additional mapping for whoosh, stats and add additional code into the push/pull/create/delete repo hooks, -for example, for sending signals to build-bots such as Jenkins. -Please see the ``__init__.py`` file inside ``rcextensions`` package +for example for sending signals to build-bots such as Jenkins. + +See the ``__init__.py`` file inside the generated ``rcextensions`` package for more details. diff --git a/kallithea/lib/paster_commands/make_rcextensions.py b/kallithea/lib/paster_commands/make_rcextensions.py --- a/kallithea/lib/paster_commands/make_rcextensions.py +++ b/kallithea/lib/paster_commands/make_rcextensions.py @@ -30,7 +30,6 @@ from __future__ import with_statement import os import sys -import logging import pkg_resources from kallithea.lib.utils import BasePasterCommand, ask_ok @@ -40,46 +39,44 @@ from os.path import dirname as dn rc_path = dn(dn(dn(os.path.realpath(__file__)))) sys.path.append(rc_path) -log = logging.getLogger(__name__) - class Command(BasePasterCommand): max_args = 1 min_args = 1 - usage = "CONFIG_FILE" group_name = "Kallithea" takes_config_file = -1 parser = BasePasterCommand.standard_parser(verbose=True) - summary = "Creates additional extensions for kallithea" + summary = "Write template file for extending Kallithea in Python." + usage = "CONFIG_FILE" + description = '''\ + A rcextensions directory with a __init__.py file will be created next to + the ini file. Local customizations in that file will survive upgrades. + The file contains instructions on how it can be customized. + ''' def command(self): - logging.config.fileConfig(self.path_to_ini_file) from pylons import config - def _make_file(ext_file, tmpl): - bdir = os.path.split(ext_file)[0] - if not os.path.isdir(bdir): - os.makedirs(bdir) - with open(ext_file, 'wb') as f: - f.write(tmpl) - log.info('Writen new extensions file to %s' % ext_file) - here = config['here'] - tmpl = pkg_resources.resource_string( + content = pkg_resources.resource_string( 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') ) ext_file = os.path.join(here, 'rcextensions', '__init__.py') if os.path.exists(ext_file): msg = ('Extension file already exists, do you want ' 'to overwrite it ? [y/n]') - if ask_ok(msg): - _make_file(ext_file, tmpl) - else: - log.info('nothing done...') - else: - _make_file(ext_file, tmpl) + if not ask_ok(msg): + print 'Nothing done...' + return + + dirname = os.path.dirname(ext_file) + if not os.path.isdir(dirname): + os.makedirs(dirname) + with open(ext_file, 'wb') as f: + f.write(content) + print 'Wrote new extensions file to %s' % ext_file def update_parser(self): pass