1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
#!/usr/bin/python -S
#
# Copyright 2010 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""
This script should be run from the top-level of the LP tree.
It notifies bug supervisors or owners (if no bug supervisor is
defined) for projects with bug expiry enabled that we are
re-enabling auto expiration. It then disables the feature on these
projects. The notification is also meant to notify users they will
have to re-enable this option. No surprises FTW!
Run with no options, this script is largely harmless. It will
merely do the queries.
"""
import _pythonpath
from storm.expr import Not
from lp.services.scripts.base import LaunchpadScript
from lp.services.mail.sendmail import simple_sendmail
from canonical.launchpad.interfaces.lpstorm import IMasterStore
from canonical.launchpad.interfaces.emailaddress import EmailAddressStatus
MAIL_MSG = """
Hi,
We are contacting you because you are the maintainer or bug
supervisor for %(name)s at https://launchpad.net/%(project)s.
Your project has the option to expire bugs enabled. For more info
on this feature, please see:
https://help.launchpad.net/Bugs/Expiry
This feature has not been active on Launchpad for some time, despite
the feature being enabled by default when registering projects. We
have done some work to allow us to re-enable this feature. We will
be turning auto-expiring of bugs back on two weeks from now. This
means that roughly around 13 September 2010 bugs meeting the conditions
outlined in the help wiki above will be auto expired. They will be
marked with the "Expired" status in Launchpad bugs.
However, since this feature has been enabled by default but
inactive, we are turning off the configuration option that reads:
'Expire "Incomplete" bug reports when they become inactive'
If you indeed want this behavior on Launchpad, you will need to
visit the configuration page on Launchpad and check this option
again. Your bug tracker config page is found at:
https://bugs.launchpad.net/%(project)s/+configure-bugtracker
We appologize for this inconveniece for those wanting this feature,
but we felt it best to be cautious and not auto expire a project's
bugs without giving advance notice.
Cheers,
The Launchpad Bugs Team
"""
class ExpiryNotifyScript(LaunchpadScript):
description = 'Notify users about bug expiry and disable the feature.'
def add_my_options(self):
self.parser.add_option('-D', '--debug', action='store_true',
dest='debug', default=False,
help='Drop into PDB and figure this out.')
self.parser.add_option('-u', '--update', action='store_true',
dest='update', default=False,
help='Update DB to disable bug expiry.')
self.parser.add_option('-r', '--report', action='store_true',
dest='report', default=False,
help='Report stats on the data and exit.')
self.parser.add_option('-s', '--sendmail', action='store_true',
dest='sendmail', default=False,
help='Actually send the mail out.')
def main(self):
# Anyone else hate circular imports?
from lp.registry.model.product import Product
from lp.registry.model.person import Person
from canonical.launchpad.database import EmailAddress
# Get the supervisors, owners, and projects.
store = IMasterStore(Product)
supervisors = list(store.find(
(Product, Person, EmailAddress),
Product.enable_bug_expiration == True,
Not(Product.bug_supervisor == None),
Product.bug_supervisor == Person.id,
EmailAddress.person == Person.id,
EmailAddress.status == EmailAddressStatus.PREFERRED,
))
owners = list(store.find(
(Product, Person, EmailAddress),
Product.enable_bug_expiration == True,
Product.bug_supervisor == None,
Product._owner == Person.id,
EmailAddress.person == Person.id,
EmailAddress.status == EmailAddressStatus.PREFERRED,
))
contacts = supervisors + owners
projects = store.find(
Product,
Product.enable_bug_expiration == True,
)
# Optionally, show a bit of info about this data.
if self.options.report:
print '%d projects with bug expiry enabled' % projects.count()
print '%d projects with no bug supervisor' % len(owners)
print '%d projects with a contactable bug supervisor' % (
len(supervisors))
if self.options.debug:
for project, person, email in contacts:
self.logger.debug(
'Data: (%s, %s, %s)' % (
project.name, person.displayname, email.email))
# Handle the emails.
for project, person, email in contacts:
# Skip anything "~registry" owns.
if person.name == 'registry':
continue
msg = MAIL_MSG % {
'project': project.name,
'name': project.displayname}
if self.options.report:
print msg
if self.options.sendmail:
simple_sendmail(
'launchpad@bugs.launchpad.net', email.email,
'Launchpad Bugs Re-enabling Auto Expiring Bugs', msg)
# Actually update the settings here.
if self.options.update:
for project in projects:
project.enable_bug_expiration = False
self.txn.commit()
self.logger.debug('ExpiryNotifyScript is done.')
if __name__ == '__main__':
script = ExpiryNotifyScript()
script.run()
|