10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.7
by Karl Fogel
Add the copyright header block to more files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
6493.4.2
by Guilherme Salgado
person notification |
6 |
# pylint: disable-msg=W0403
|
7 |
||
8 |
"""Send person notifications.
|
|
9 |
||
10 |
This script sends out all the pending person notifications, and sets
|
|
11 |
date_emailed to the current date.
|
|
12 |
"""
|
|
13 |
||
14 |
__metaclass__ = type |
|
15 |
||
16 |
import _pythonpath |
|
17 |
||
14605.1.1
by Curtis Hovey
Moved canonical.config to lp.services. |
18 |
from lp.services.config import config |
10322.3.2
by Curtis Hovey
Added a unit test for personnotifications. |
19 |
|
8356.1.1
by Leonard Richardson
Partial move. |
20 |
from lp.services.scripts.base import LaunchpadCronScript |
10322.3.2
by Curtis Hovey
Added a unit test for personnotifications. |
21 |
from lp.registry.scripts.personnotification import PersonNotificationManager |
6493.4.2
by Guilherme Salgado
person notification |
22 |
|
23 |
||
24 |
class SendPersonNotifications(LaunchpadCronScript): |
|
6493.6.5
by Guilherme Salgado
Few changes as suggested by Brad. |
25 |
"""Send pending notifications to people.
|
26 |
||
27 |
Pending notifications are stored in the PersonNotification table and have
|
|
28 |
a date_emailed == None.
|
|
29 |
||
30 |
This script will also delete the notifications that have been retained for
|
|
31 |
more than config.person_notification.retained_days days.
|
|
32 |
"""
|
|
33 |
||
6493.4.2
by Guilherme Salgado
person notification |
34 |
def main(self): |
10322.3.2
by Curtis Hovey
Added a unit test for personnotifications. |
35 |
manager = PersonNotificationManager(self.txn, self.logger) |
10322.3.4
by Curtis Hovey
Purge unsentable notifcations early. |
36 |
unsent_notifications = manager.sendNotifications() |
37 |
manager.purgeNotifications(unsent_notifications) |
|
6493.4.2
by Guilherme Salgado
person notification |
38 |
|
39 |
||
40 |
if __name__ == '__main__': |
|
6493.6.4
by Guilherme Salgado
Fix the script which sends notifications and write tests for PersonNotification. |
41 |
script = SendPersonNotifications( |
42 |
'send-person-notifications', dbuser=config.person_notification.dbuser) |
|
6493.4.2
by Guilherme Salgado
person notification |
43 |
script.lock_and_run() |