Skip to content
Snippets Groups Projects
Commit 139b0da2 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[backend] Allow user to set path to clean-up

parent d4045277
No related branches found
No related tags found
1 merge request!194Scheduler
...@@ -46,12 +46,18 @@ class Command(BaseCommand): ...@@ -46,12 +46,18 @@ class Command(BaseCommand):
parser.add_argument('--olderthan', type=int, metavar='MINUTES', parser.add_argument('--olderthan', type=int, metavar='MINUTES',
default=0, help='All files which are older than this value ' \ default=0, help='All files which are older than this value ' \
'in *minutes* and are not locked or being used by active ' \ 'in *minutes* and are not locked or being used by active ' \
'experiments (running or scheduled) will be deleted') 'experiments (running or scheduled) will be deleted ' \
'[default: %(default)s]')
parser.add_argument('--delete', action='store_true', default=False, parser.add_argument('--delete', action='store_true', default=False,
help='By default we only list cache files that will ' \ help='By default we only list cache files that will ' \
'be erased. If you pass this flag, then we really erase them') 'be erased. If you pass this flag, then we really erase them')
parser.add_argument('--path', default=settings.CACHE_ROOT,
help='By default, we erase the CACHE path on your settings. Set ' \
'this flag if you want to operate on a different path ' \
'[default: %(default)s]')
def handle(self, *ignored, **arguments): def handle(self, *ignored, **arguments):
...@@ -62,11 +68,11 @@ class Command(BaseCommand): ...@@ -62,11 +68,11 @@ class Command(BaseCommand):
if arguments['verbosity'] == 1: logger.setLevel(logging.INFO) if arguments['verbosity'] == 1: logger.setLevel(logging.INFO)
elif arguments['verbosity'] >= 2: logger.setLevel(logging.DEBUG) elif arguments['verbosity'] >= 2: logger.setLevel(logging.DEBUG)
deleted = cleanup_cache(settings.CACHE_ROOT, deleted = cleanup_cache(arguments['path'],
age_in_minutes=arguments['olderthan'], age_in_minutes=arguments['olderthan'],
delete=arguments['delete']) delete=arguments['delete'])
if not arguments['delete']: if not arguments['delete']:
print("%d cache files can be deleted" % len(deleted)) print("%d cache files can be deleted" % len(deleted))
for k in deleted: for k in deleted:
print(os.path.join(settings.CACHE_ROOT, k)) print(os.path.join(arguments['path'], k))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment