diff --git a/rhodecode/lib/cleanup.py b/rhodecode/lib/paster_commands/cleanup.py copy from rhodecode/lib/cleanup.py copy to rhodecode/lib/paster_commands/cleanup.py --- a/rhodecode/lib/cleanup.py +++ b/rhodecode/lib/paster_commands/cleanup.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- """ - package.rhodecode.lib.cleanup - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + rhodecode.lib.paster_commands.make_rcextensions + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + cleanup-repos paster command for RhodeCode + :created_on: Jul 14, 2012 :author: marcink @@ -30,30 +33,28 @@ import logging import datetime from os.path import dirname as dn, join as jn -from rhodecode.model import init_model -from rhodecode.lib.utils2 import engine_from_config, safe_str +#to get the rhodecode import +rc_path = dn(dn(dn(os.path.realpath(__file__)))) +sys.path.append(rc_path) +from rhodecode.lib.utils import BasePasterCommand, ask_ok, REMOVED_REPO_PAT + +from rhodecode.lib.utils2 import safe_str from rhodecode.model.db import RhodeCodeUi -#to get the rhodecode import -sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) - -from rhodecode.lib.utils import BasePasterCommand, Command, ask_ok,\ - REMOVED_REPO_PAT, add_cache - log = logging.getLogger(__name__) -class CleanupCommand(BasePasterCommand): +class Command(BasePasterCommand): max_args = 1 min_args = 1 usage = "CONFIG_FILE" - summary = "Cleanup deleted repos" group_name = "RhodeCode" takes_config_file = -1 - parser = Command.standard_parser(verbose=True) + parser = BasePasterCommand.standard_parser(verbose=True) + summary = "Cleanup deleted repos" def _parse_older_than(self, val): regex = re.compile(r'((?P\d+?)d)?((?P\d+?)h)?((?P\d+?)m)?((?P\d+?)s)?') @@ -78,13 +79,8 @@ class CleanupCommand(BasePasterCommand): return datetime.datetime.strptime(date_part, '%Y%m%d_%H%M%S') def command(self): - logging.config.fileConfig(self.path_to_ini_file) - from pylons import config - - #get to remove repos !! - add_cache(config) - engine = engine_from_config(config, 'sqlalchemy.db1.') - init_model(engine) + #get SqlAlchemy session + self._init_session() repos_location = RhodeCodeUi.get_repos_location() to_remove = []