From f7aeab077874d33fc99354661bfeedf508c292b3 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 28 May 2015 13:39:05 +0800 Subject: cron: Move patchwork-cron script to a management command Signed-off-by: Jeremy Kerr --- patchwork/bin/patchwork-cron.py | 15 --------------- patchwork/management/commands/cron.py | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) delete mode 100755 patchwork/bin/patchwork-cron.py create mode 100755 patchwork/management/commands/cron.py (limited to 'patchwork') diff --git a/patchwork/bin/patchwork-cron.py b/patchwork/bin/patchwork-cron.py deleted file mode 100755 index 148e97c..0000000 --- a/patchwork/bin/patchwork-cron.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import sys -from patchwork.utils import send_notifications, do_expiry - -def main(args): - errors = send_notifications() - for (recipient, error) in errors: - print "Failed sending to %s: %s" % (recipient.email, ex) - - do_expiry() - -if __name__ == '__main__': - sys.exit(main(sys.argv)) - diff --git a/patchwork/management/commands/cron.py b/patchwork/management/commands/cron.py new file mode 100755 index 0000000..6217e75 --- /dev/null +++ b/patchwork/management/commands/cron.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +from django.core.management.base import BaseCommand, CommandError +from patchwork.utils import send_notifications, do_expiry + +class Command(BaseCommand): + help = ('Run periodic patchwork functions: send notifications and ' + 'expire unused users') + + def handle(self, *args, **kwargs): + errors = send_notifications() + for (recipient, error) in errors: + self.stderr.write("Failed sending to %s: %s" % + (recipient.email, ex)) + + do_expiry() + +if __name__ == '__main__': + sys.exit(main(sys.argv)) + -- cgit v1.2.3