Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cron: Move patchwork-cron script to a management command
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
- Loading branch information
Showing
4 changed files
with
28 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
|