diff --git a/beat/web/experiments/management/commands/cleanup_orphaned_caches.py b/beat/web/experiments/management/commands/cleanup_orphaned_caches.py index 8e02872caa49699cb2c1400dd3ca8c9f1a10a316..e19698014c21249e5936865116dbbab2b9046385 100644 --- a/beat/web/experiments/management/commands/cleanup_orphaned_caches.py +++ b/beat/web/experiments/management/commands/cleanup_orphaned_caches.py @@ -27,37 +27,45 @@ import logging -logger = logging.getLogger(__name__) from django.core.management.base import BaseCommand from ... import utils +logger = logging.getLogger(__name__) + class Command(BaseCommand): - help = 'Sets and resets queue configurations' - + help = "Sets and resets queue configurations" def add_arguments(self, parser): - parser.add_argument('--delete', action='store_true', dest='delete', - default=False, help='Really deletes the CachedFiles - ' \ - 'otherwise only displays what would be deleted') + parser.add_argument( + "--delete", + action="store_true", + dest="delete", + default=False, + help="Really deletes the CachedFiles - " + "otherwise only displays what would be deleted", + ) def handle(self, *ignored, **arguments): # Setup this command's logging level global logger - arguments['verbosity'] = int(arguments['verbosity']) - if arguments['verbosity'] >= 1: - if arguments['verbosity'] == 1: logger.setLevel(logging.INFO) - elif arguments['verbosity'] >= 2: logger.setLevel(logging.DEBUG) + arguments["verbosity"] = int(arguments["verbosity"]) + if arguments["verbosity"] >= 1: + if arguments["verbosity"] == 1: + logger.setLevel(logging.INFO) + elif arguments["verbosity"] >= 2: + logger.setLevel(logging.DEBUG) - if arguments['delete']: + if arguments["delete"]: utils.cleanup_orphaned_cachedfiles() else: - l = utils.list_orphaned_cachedfiles() - for c in l: print(c) - print('%d CachedFiles are unreacheable' % len(l)) + orphaned_files = utils.list_orphaned_cachedfiles() + for file_ in orphaned_files: + print(file_) + print("%d CachedFiles are unreacheable" % len(orphaned_files))