Mercurial > kallithea
changeset 5597:624d57352745
paster: minor changes to paster commands, making them slightly more consistent
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 27 Nov 2015 01:47:12 +0100 |
parents | 5a148717d392 |
children | edb24bc0f71a |
files | kallithea/lib/paster_commands/cache_keys.py kallithea/lib/paster_commands/cleanup.py kallithea/lib/paster_commands/install_iis.py kallithea/lib/paster_commands/ishell.py kallithea/lib/paster_commands/make_index.py kallithea/lib/paster_commands/make_rcextensions.py kallithea/lib/paster_commands/repo_scan.py kallithea/lib/paster_commands/setup_db.py kallithea/lib/paster_commands/update_repoinfo.py kallithea/lib/utils.py |
diffstat | 10 files changed, 63 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/paster_commands/cache_keys.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/cache_keys.py Fri Nov 27 01:47:12 2015 +0100 @@ -29,7 +29,6 @@ import os import sys -import logging from kallithea.model.meta import Session from kallithea.lib.utils import BasePasterCommand @@ -40,8 +39,6 @@ rc_path = dn(dn(dn(os.path.realpath(__file__)))) sys.path.append(rc_path) -log = logging.getLogger(__name__) - class Command(BasePasterCommand): @@ -57,6 +54,7 @@ def command(self): #get SqlAlchemy session self._init_session() + _caches = CacheInvalidation.query().order_by(CacheInvalidation.cache_key).all() if self.options.show: for c_obj in _caches: @@ -64,11 +62,10 @@ elif self.options.cleanup: for c_obj in _caches: Session().delete(c_obj) - print 'removing key:%s' % (c_obj.cache_key) + print 'Removing key: %s' % (c_obj.cache_key) Session().commit() else: - print 'nothing done exiting...' - sys.exit(0) + print 'Nothing done, exiting...' def update_parser(self): self.parser.add_option(
--- a/kallithea/lib/paster_commands/cleanup.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/cleanup.py Fri Nov 27 01:47:12 2015 +0100 @@ -22,7 +22,7 @@ Original author and date, and relevant copyright and licensing information is below: :created_on: Jul 14, 2012 :author: marcink -:copyright: (c) 2013 RhodeCode GmbH. +:copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details. """ @@ -31,7 +31,6 @@ import sys import re import shutil -import logging import datetime from kallithea.lib.utils import BasePasterCommand, ask_ok, REMOVED_REPO_PAT @@ -43,8 +42,6 @@ rc_path = dn(dn(dn(os.path.realpath(__file__)))) sys.path.append(rc_path) -log = logging.getLogger(__name__) - class Command(BasePasterCommand): @@ -110,27 +107,25 @@ to_remove_filtered.append([name, date_]) to_remove = to_remove_filtered - print >> sys.stdout, 'removing %s deleted repos older than %s (%s)' \ + print 'Removing %s deleted repos older than %s (%s)' \ % (len(to_remove), older_than, older_than_date) else: - print >> sys.stdout, 'removing all [%s] deleted repos' \ - % len(to_remove) + print 'Removing all %s deleted repos' % len(to_remove) if self.options.dont_ask or not to_remove: # don't ask just remove ! remove = True else: remove = ask_ok('the following repositories will be deleted completely:\n%s\n' 'are you sure you want to remove them [y/n]?' - % ', \n'.join(['%s removed on %s' - % (safe_str(x[0]), safe_str(x[1])) for x in to_remove])) + % '\n'.join(['%s removed on %s' % (safe_str(x[0]), safe_str(x[1])) + for x in to_remove])) if remove: for path, date_ in to_remove: - print >> sys.stdout, 'removing repository %s' % path + print 'Removing repository %s' % path shutil.rmtree(path) else: - print 'nothing done exiting...' - sys.exit(0) + print 'Nothing done, exiting...' def update_parser(self): self.parser.add_option(
--- a/kallithea/lib/paster_commands/install_iis.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/install_iis.py Fri Nov 27 01:47:12 2015 +0100 @@ -1,3 +1,24 @@ +# -*- 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.install_iis +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +IIS installation tools for Kallithea +""" + + import os import sys from paste.script.appinstall import AbstractInstallCommand @@ -37,7 +58,9 @@ except ImportError: raise BadCommand('missing requirement: isapi-wsgi not installed') - file = '''import sys + file = '''\ +# Created by Kallithea install_iis +import sys if hasattr(sys, "isapidllhandle"): import win32traceutil @@ -78,8 +101,8 @@ dispatchfile = os.path.join(os.getcwd(), 'dispatch.py') self.ensure_file(dispatchfile, outdata, False) - print 'generating', dispatchfile + print 'Generating %s' % (dispatchfile,) - print ('run \'python "%s" install\' with administrative privileges ' + print ('Run \'python "%s" install\' with administrative privileges ' 'to generate the _dispatch.dll file and install it into the ' 'default web site') % (dispatchfile,)
--- a/kallithea/lib/paster_commands/ishell.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/ishell.py Fri Nov 27 01:47:12 2015 +0100 @@ -28,7 +28,6 @@ import os import sys -import logging from kallithea.lib.utils import BasePasterCommand @@ -37,8 +36,6 @@ rc_path = dn(dn(dn(os.path.realpath(__file__)))) sys.path.append(rc_path) -log = logging.getLogger(__name__) - class Command(BasePasterCommand): @@ -55,7 +52,7 @@ #get SqlAlchemy session self._init_session() - # imports, used in ipython shell + # imports, used in IPython shell import os import sys import time @@ -70,7 +67,7 @@ cfg.InteractiveShellEmbed.confirm_exit = False embed(config=cfg, banner1="Kallithea IShell.") except ImportError: - print 'ipython installation required for ishell' + print 'IPython installation is required for ishell' sys.exit(-1) def update_parser(self):
--- a/kallithea/lib/paster_commands/make_index.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/make_index.py Fri Nov 27 01:47:12 2015 +0100 @@ -23,13 +23,11 @@ :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details. - """ import os import sys -import logging from string import strip from kallithea.model.repo import RepoModel @@ -53,7 +51,6 @@ summary = "Creates or updates full text search index" def command(self): - logging.config.fileConfig(self.path_to_ini_file) #get SqlAlchemy session self._init_session() from pylons import config
--- a/kallithea/lib/paster_commands/make_rcextensions.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/make_rcextensions.py Fri Nov 27 01:47:12 2015 +0100 @@ -23,7 +23,6 @@ :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details. - """ @@ -67,7 +66,7 @@ msg = ('Extension file already exists, do you want ' 'to overwrite it ? [y/n]') if not ask_ok(msg): - print 'Nothing done...' + print 'Nothing done, exiting...' return dirname = os.path.dirname(ext_file)
--- a/kallithea/lib/paster_commands/repo_scan.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/repo_scan.py Fri Nov 27 01:47:12 2015 +0100 @@ -28,7 +28,6 @@ import os import sys -import logging from kallithea.model.scm import ScmModel from kallithea.lib.utils import BasePasterCommand, repo2db_mapper @@ -38,8 +37,6 @@ rc_path = dn(dn(dn(os.path.realpath(__file__)))) sys.path.append(rc_path) -log = logging.getLogger(__name__) - class Command(BasePasterCommand):
--- a/kallithea/lib/paster_commands/setup_db.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/setup_db.py Fri Nov 27 01:47:12 2015 +0100 @@ -1,3 +1,24 @@ +# -*- 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.setup_db +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Databaset setup paster command for Kallithea +""" + + import os import sys from paste.script.appinstall import AbstractInstallCommand @@ -74,6 +95,7 @@ dest='public_access', default=None, help='Disable public access on this installation ') + def command(self): config_spec = self.args[0] section = self.options.section_name @@ -100,7 +122,7 @@ dist = conf.context.distribution if dist is None: raise BadCommand( - "The section %r is not the application (probably a filter). " + "The section %r is not the application (probably a filter). " "You should add #section_name, where section_name is the " "section that configures your application" % plain_section) installer = self.get_installer(dist, ep_group, ep_name)
--- a/kallithea/lib/paster_commands/update_repoinfo.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/paster_commands/update_repoinfo.py Fri Nov 27 01:47:12 2015 +0100 @@ -28,7 +28,6 @@ import os import sys -import logging import string from kallithea.lib.utils import BasePasterCommand @@ -41,8 +40,6 @@ rc_path = dn(dn(dn(os.path.realpath(__file__)))) sys.path.append(rc_path) -log = logging.getLogger(__name__) - class Command(BasePasterCommand):
--- a/kallithea/lib/utils.py Fri Nov 27 01:47:06 2015 +0100 +++ b/kallithea/lib/utils.py Fri Nov 27 01:47:12 2015 +0100 @@ -790,11 +790,10 @@ Inits SqlAlchemy Session """ logging.config.fileConfig(self.path_to_ini_file) + from pylons import config from kallithea.model import init_model from kallithea.lib.utils2 import engine_from_config - - #get to remove repos !! add_cache(config) engine = engine_from_config(config, 'sqlalchemy.db1.') init_model(engine)