Changeset - 624d57352745
[Not reviewed]
default
0 10 0
Mads Kiilerich - 10 years ago 2015-11-27 01:47:12
madski@unity3d.com
paster: minor changes to paster commands, making them slightly more consistent
10 files changed with 63 insertions and 40 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/paster_commands/cache_keys.py
Show inline comments
 
@@ -29,7 +29,6 @@ Original author and date, and relevant c
 

	
 
import os
 
import sys
 
import logging
 

	
 
from kallithea.model.meta import Session
 
from kallithea.lib.utils import BasePasterCommand
 
@@ -40,8 +39,6 @@ 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):
 

	
 
@@ -57,6 +54,7 @@ class Command(BasePasterCommand):
 
    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 @@ class Command(BasePasterCommand):
 
        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(
kallithea/lib/paster_commands/cleanup.py
Show inline comments
 
@@ -22,7 +22,7 @@ This file was forked by the Kallithea pr
 
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 os
 
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 @@ 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):
 

	
 
@@ -110,27 +107,25 @@ class Command(BasePasterCommand):
 
                    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(
kallithea/lib/paster_commands/install_iis.py
Show inline comments
 
# -*- 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 @@ class Command(AbstractInstallCommand):
 
        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 @@ if __name__=='__main__':
 

	
 
        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,)
kallithea/lib/paster_commands/ishell.py
Show inline comments
 
@@ -28,7 +28,6 @@ Original author and date, and relevant c
 

	
 
import os
 
import sys
 
import logging
 

	
 
from kallithea.lib.utils import BasePasterCommand
 

	
 
@@ -37,8 +36,6 @@ 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):
 

	
 
@@ -55,7 +52,7 @@ class Command(BasePasterCommand):
 
        #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 @@ class Command(BasePasterCommand):
 
            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):
kallithea/lib/paster_commands/make_index.py
Show inline comments
 
@@ -23,13 +23,11 @@ Original author and date, and relevant c
 
: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 @@ class Command(BasePasterCommand):
 
    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
kallithea/lib/paster_commands/make_rcextensions.py
Show inline comments
 
@@ -23,7 +23,6 @@ Original author and date, and relevant c
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 

	
 
"""
 

	
 

	
 
@@ -67,7 +66,7 @@ class Command(BasePasterCommand):
 
            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)
kallithea/lib/paster_commands/repo_scan.py
Show inline comments
 
@@ -28,7 +28,6 @@ Original author and date, and relevant c
 

	
 
import os
 
import sys
 
import logging
 

	
 
from kallithea.model.scm import ScmModel
 
from kallithea.lib.utils import BasePasterCommand, repo2db_mapper
 
@@ -38,8 +37,6 @@ 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):
 

	
kallithea/lib/paster_commands/setup_db.py
Show inline comments
 
# -*- 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 @@ class Command(AbstractInstallCommand):
 
                       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 @@ class Command(AbstractInstallCommand):
 
        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)
kallithea/lib/paster_commands/update_repoinfo.py
Show inline comments
 
@@ -28,7 +28,6 @@ Original author and date, and relevant c
 

	
 
import os
 
import sys
 
import logging
 
import string
 

	
 
from kallithea.lib.utils import BasePasterCommand
 
@@ -41,8 +40,6 @@ 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):
 

	
kallithea/lib/utils.py
Show inline comments
 
@@ -790,11 +790,10 @@ class BasePasterCommand(Command):
 
        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)
0 comments (0 inline, 0 general)