Changeset - d8b7a1a023a6
[Not reviewed]
default
0 5 0
domruf - 8 years ago 2017-06-11 16:56:12
dominikruf@gmail.com
gearbox: if a config file is specified, store it in the command instance so it is available without tg

This will prevent a plain 'gearbox make-rcext -c kallithea.ini' from crashing in

here = config['here']

Note:
kallithea.CONFIG serves a very similar purpose.

Modified by Mads Kiilerich.
5 files changed with 14 insertions and 19 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/paster_commands/celeryd.py
Show inline comments
 
@@ -20,9 +20,8 @@ class Command(BasePasterCommand):
 

	
 
    def take_action(self, args):
 
        from kallithea.lib import celerypylons
 
        from tg import config
 
        try:
 
            CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
 
            CELERY_ON = str2bool(self.config['app_conf'].get('use_celery'))
 
        except KeyError:
 
            CELERY_ON = False
 

	
 
@@ -31,7 +30,7 @@ class Command(BasePasterCommand):
 
                            'file before running celeryd')
 
        kallithea.CELERY_ON = CELERY_ON
 

	
 
        load_rcextensions(config['here'])
 
        load_rcextensions(self.config['here'])
 
        cmd = celerypylons.worker.worker(celerypylons.app.app_or_default())
 

	
 
        celery_args = args.celery_args
kallithea/lib/paster_commands/common.py
Show inline comments
 
@@ -31,7 +31,6 @@ import logging.config
 

	
 
import paste.deploy
 
import gearbox.command
 
from tg import config
 

	
 
import kallithea.config.middleware
 
import kallithea.model.base
 
@@ -60,6 +59,7 @@ class BasePasterCommand(gearbox.command.
 
    # override to control how much get_parser and run should do:
 
    takes_config_file = True
 
    requires_db_session = True
 
    config = None # set to the actual config object in run if takes_config_file is true
 

	
 
    def run(self, args):
 
        """
 
@@ -69,13 +69,15 @@ class BasePasterCommand(gearbox.command.
 
        """
 
        if self.takes_config_file:
 
            path_to_ini_file = os.path.realpath(args.config_file)
 
            conf = paste.deploy.appconfig('config:' + path_to_ini_file)
 
            self.config = paste.deploy.appconfig('config:' + path_to_ini_file)
 
            # TODO: also initialize kallithea.CONFIG?
 
            logging.config.fileConfig(path_to_ini_file)
 

	
 
            if self.requires_db_session:
 
                kallithea.config.middleware.make_app_without_logging(conf.global_conf, **conf.local_conf)
 
                kallithea.lib.utils.setup_cache_regions(config)
 
                engine = kallithea.lib.utils2.engine_from_config(config, 'sqlalchemy.')
 
                kallithea.config.middleware.make_app_without_logging(self.config.global_conf, **self.config.local_conf)
 
                # *now*, tg.config has been set and could be used ... but we just keep using self.config
 
                kallithea.lib.utils.setup_cache_regions(self.config)
 
                engine = kallithea.lib.utils2.engine_from_config(self.config, 'sqlalchemy.')
 
                kallithea.model.base.init_model(engine)
 

	
 
        return super(BasePasterCommand, self).run(args)
kallithea/lib/paster_commands/make_index.py
Show inline comments
 
@@ -40,9 +40,8 @@ class Command(BasePasterCommand):
 
    "Kallithea: Create or update full text search index"
 

	
 
    def take_action(self, args):
 
        from tg import config
 
        index_location = config['index_dir']
 
        load_rcextensions(config['here'])
 
        index_location = self.config['index_dir']
 
        load_rcextensions(self.config['here'])
 

	
 
        repo_location = args.repo_location \
 
            if args.repo_location else RepoModel().repos_path
kallithea/lib/paster_commands/make_rcextensions.py
Show inline comments
 
@@ -44,9 +44,7 @@ class Command(BasePasterCommand):
 
    requires_db_session = False
 

	
 
    def take_action(self, args):
 
        from tg import config
 

	
 
        here = config['here']
 
        here = self.config['here']
 
        content = pkg_resources.resource_string(
 
            'kallithea', os.path.join('config', 'rcextensions', '__init__.py')
 
        )
kallithea/lib/paster_commands/setup_db.py
Show inline comments
 
@@ -91,11 +91,8 @@ class Command(BasePasterCommand):
 
        return parser
 

	
 
    def take_action(self, opts):
 
        path_to_ini_file = os.path.realpath(opts.config_file)
 
        conf = paste.deploy.appconfig('config:' + path_to_ini_file)
 

	
 
        dbconf = conf['sqlalchemy.url']
 
        dbmanage = DbManage(dbconf=dbconf, root=conf['here'],
 
        dbconf = self.config['sqlalchemy.url']
 
        dbmanage = DbManage(dbconf=dbconf, root=self.config['here'],
 
                            tests=False, cli_args=vars(opts))
 
        dbmanage.create_tables(override=True)
 
        opts = dbmanage.config_prompt(None)
0 comments (0 inline, 0 general)