Mercurial > kallithea
changeset 7419:a6b24ff6d65c
cli: remove now obsolete 'paster_commands' files
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Thu, 18 Oct 2018 22:47:25 +0200 |
parents | 0f9e7dbfa5d2 |
children | 2da1689d7384 |
files | kallithea/lib/paster_commands/__init__.py kallithea/lib/paster_commands/common.py |
diffstat | 2 files changed, 0 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- 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 <http://www.gnu.org/licenses/>.
--- 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 <http://www.gnu.org/licenses/>. -""" -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)