# HG changeset patch # User Thomas De Schampheleire # Date 1539895645 -7200 # Node ID a6b24ff6d65c33b84d4a6315013fb800816b47ee # Parent 0f9e7dbfa5d2172e1e99f2a4791641058d6a5e9d cli: remove now obsolete 'paster_commands' files diff -r 0f9e7dbfa5d2 -r a6b24ff6d65c kallithea/lib/paster_commands/__init__.py --- a/kallithea/lib/paster_commands/__init__.py Sun Nov 18 19:57:40 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . diff -r 0f9e7dbfa5d2 -r a6b24ff6d65c kallithea/lib/paster_commands/common.py --- a/kallithea/lib/paster_commands/common.py Sun Nov 18 19:57:40 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" -kallithea.lib.paster_commands.common -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Common code for gearbox commands. - -This file was forked by the Kallithea project in July 2014. -Original author and date, and relevant copyright and licensing information is below: -:created_on: Apr 18, 2010 -:author: marcink -:copyright: (c) 2013 RhodeCode GmbH, and others. -:license: GPLv3, see LICENSE.md for more details. -""" - -import os -import sys -import logging.config - -import paste.deploy -import gearbox.command - -import kallithea.config.middleware -import kallithea.model.base -import kallithea.lib.utils2 -import kallithea.lib.utils - - -class BasePasterCommand(gearbox.command.Command): - """ - Abstract Base Class for gearbox commands. - """ - - # 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): - """ - Overrides Command.run - - If needed by the command, read config file and initialize database before running. - """ - if self.takes_config_file: - path_to_ini_file = os.path.realpath(args.config_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(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) - - return super(BasePasterCommand, self).run(args) - - def get_parser(self, prog_name): - parser = super(BasePasterCommand, self).get_parser(prog_name) - - if self.takes_config_file: - parser.add_argument("-c", "--config", - help='Kallithea .ini file with configuration of database etc', - dest='config_file', required=True) - - return parser - - def error(self, msg, exitcode=1): - """Write error message and exit""" - sys.stderr.write('%s\n' % msg) - raise SystemExit(exitcode)