~deryck/+junk/lpjunk

« back to all changes in this revision

Viewing changes to notify_expiry.py

  • Committer: Deryck Hodge
  • Date: 2010-08-25 13:40:13 UTC
  • Revision ID: deryck@devurandom.org-20100825134013-07e93g1q53mc5n4e
More comment and text fixes, and move the commit() inside the "udpate" section.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 
67
67
class ExpiryNotifyScript(LaunchpadScript):
68
68
 
69
 
    description = 'A script to notify users about re-enabling bug expiry.'
 
69
    description = 'Notify users about bug expiry and disable the feature.'
70
70
 
71
71
    def add_my_options(self):
72
72
        self.parser.add_option('-D', '--debug', action='store_true',
87
87
        from lp.registry.model.product import Product
88
88
        from lp.registry.model.person import Person
89
89
        from canonical.launchpad.database import EmailAddress
 
90
 
 
91
        # Get the supervisors, owners, and projects.
90
92
        store = IMasterStore(Product)
91
93
        supervisors = list(store.find(
92
94
            (Product, Person, EmailAddress),
110
112
            Product.enable_bug_expiration == True,
111
113
        )
112
114
 
 
115
        # Optionally, show a bit of info about this data.
113
116
        if self.options.report:
114
117
            print '%d projects with bug expiry enabled' % projects.count()
115
118
            print '%d projects with no bug supervisor' % len(owners)
121
124
                        'Data: (%s, %s, %s)' % (
122
125
                            project.name, person.displayname, email.email))
123
126
 
124
 
        # Send the mail here
 
127
        # Handle the emails.
125
128
        for project, person, email in contacts:
126
129
            msg = MAIL_MSG % {
127
130
                'project': project.name,
131
134
            if self.options.sendmail:
132
135
                simple_sendmail(
133
136
                    'launchpad@bugs.launchpad.net', email.email,
134
 
                    'Bug Expiration Coming Again to Launchpad', msg)
 
137
                    'Launchpad Bugs Re-enabling Auto Expiring Bugs', msg)
135
138
 
 
139
        # Actually update the settings here.
136
140
        if self.options.update:
137
 
            # Disable bug expiry.
138
141
            for project in projects:
139
142
                project.enable_bug_expiration = False
 
143
            self.txn.commit()
140
144
 
141
 
        self.txn.commit()
142
145
        self.logger.debug('ExpiryNotifyScript is done.')
143
146
 
144
147
if __name__ == '__main__':