summaryrefslogtreecommitdiffstats
path: root/patchwork/management/commands/cron.py
blob: 6217e758d6bf90b72e99aa72f1b59dc38e67584d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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))