py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2. In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.
One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2. See discussion on the respective previous
commits that made those explicit. There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2013-11-13 01:52:40 +01:00
|
|
|
|
|
|
|
"""
|
2017-07-02 21:10:41 +02:00
|
|
|
Shows backlog count of ScheduledEmail
|
2013-11-13 01:52:40 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-11-13 01:52:40 +01:00
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
2013-11-13 01:52:40 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
2017-04-15 04:03:56 +02:00
|
|
|
from django.utils.timezone import now as timezone_now
|
2013-11-13 01:52:40 +01:00
|
|
|
|
2017-07-02 21:10:41 +02:00
|
|
|
from zerver.models import ScheduledEmail
|
2013-11-13 01:52:40 +01:00
|
|
|
|
2017-08-07 21:45:57 +02:00
|
|
|
from datetime import timedelta
|
2013-11-13 01:52:40 +01:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2017-07-02 21:10:41 +02:00
|
|
|
help = """Shows backlog count of ScheduledEmail
|
2013-11-13 01:52:40 +01:00
|
|
|
(The number of currently overdue (by at least a minute) email jobs)
|
|
|
|
|
|
|
|
This is run as part of the nagios health check for the deliver_email command.
|
|
|
|
|
2016-11-22 01:44:16 +01:00
|
|
|
Usage: ./manage.py print_email_delivery_backlog
|
2013-11-13 01:52:40 +01:00
|
|
|
"""
|
|
|
|
|
2013-11-13 22:59:04 +01:00
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **Any) -> None
|
2017-07-02 21:10:41 +02:00
|
|
|
print(ScheduledEmail.objects.filter(
|
|
|
|
scheduled_timestamp__lte=timezone_now()-timedelta(minutes=1)).count())
|