~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
3691.197.49 by Francis J. Lacoste
Add expire-tickets.py script
2
3691.398.13 by Francis J. Lacoste
Rename answer tracker py and ZCML files.
3
# Copyright 2006-2007 Canonical Ltd.  All rights reserved.
4935.3.7 by Curtis Hovey
Added bad name suppression to cronscripts.
4
# pylint: disable-msg=C0103,W0403
3691.197.49 by Francis J. Lacoste
Add expire-tickets.py script
5
3691.398.19 by Francis J. Lacoste
Rename most remaining classes (views, database, authorizations, notifications, scripts.)
6
""" Expire all questions in the OPEN and NEEDSINFO states that didn't receive
7
any activity in the last X days.
3691.197.49 by Francis J. Lacoste
Add expire-tickets.py script
8
9
The expiration period is configured through
3691.398.24 by Francis J. Lacoste
Rename config section.
10
config.answertracker.days_before_expiration
3691.197.49 by Francis J. Lacoste
Add expire-tickets.py script
11
"""
12
13
__metaclass__ = type
14
4621.5.19 by Curtis Hovey
Revisions per review.
15
__all__ = ['ExpireQuestions']
16
17
3691.197.49 by Francis J. Lacoste
Add expire-tickets.py script
18
import _pythonpath
19
20
from canonical.config import config
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
21
from canonical.launchpad.scripts.base import LaunchpadCronScript
3691.398.19 by Francis J. Lacoste
Rename most remaining classes (views, database, authorizations, notifications, scripts.)
22
from canonical.launchpad.scripts.questionexpiration import QuestionJanitor
23
24
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
25
class ExpireQuestions(LaunchpadCronScript):
4621.5.10 by Curtis Hovey
Refactored the findExpirableBugTasks method to return a list of
26
    """Expire old questions.
27
3691.398.19 by Francis J. Lacoste
Rename most remaining classes (views, database, authorizations, notifications, scripts.)
28
    This script expires questions in the OPEN and NEEDSINFO states that
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
29
    didn't have any activity in the last X days. The number of days is
3691.398.24 by Francis J. Lacoste
Rename config section.
30
    configured through config.answertracker.days_before_expiration.
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
31
    """
4621.5.10 by Curtis Hovey
Refactored the findExpirableBugTasks method to return a list of
32
    usage = "usage: %prog [options]"
33
    description =  __doc__
34
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
35
36
    def main(self):
4621.5.10 by Curtis Hovey
Refactored the findExpirableBugTasks method to return a list of
37
        """Expire old questions."""
3691.398.19 by Francis J. Lacoste
Rename most remaining classes (views, database, authorizations, notifications, scripts.)
38
        janitor = QuestionJanitor(log=self.logger)
3691.398.20 by Francis J. Lacoste
Rename all methods.
39
        janitor.expireQuestions(self.txn)
3691.197.49 by Francis J. Lacoste
Add expire-tickets.py script
40
41
42
if __name__ == '__main__':
3691.398.19 by Francis J. Lacoste
Rename most remaining classes (views, database, authorizations, notifications, scripts.)
43
    script = ExpireQuestions('expire-questions',
3691.398.24 by Francis J. Lacoste
Rename config section.
44
        dbuser=config.answertracker.dbuser)
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
45
    script.lock_and_run()
46