/usr/lib/python2.7/dist-packages/captcha/management/commands/captcha_clean.py is in python-django-captcha 0.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from django.core.management.base import BaseCommand
from captcha.models import get_safe_now
import sys
class Command(BaseCommand):
help = "Clean up expired captcha hashkeys."
def handle(self, **options):
from captcha.models import CaptchaStore
verbose = int(options.get('verbosity'))
expired_keys = CaptchaStore.objects.filter(expiration__lte=get_safe_now()).count()
if verbose >= 1:
print("Currently %d expired hashkeys" % expired_keys)
try:
CaptchaStore.remove_expired()
except:
if verbose >= 1:
print("Unable to delete expired hashkeys.")
sys.exit(1)
if verbose >= 1:
if expired_keys > 0:
print("%d expired hashkeys removed." % expired_keys)
else:
print("No keys to remove.")
|