~launchpad-pqm/launchpad/devel

10637.3.1 by Guilherme Salgado
Use the default python version instead of a hard-coded version
1
#!/usr/bin/python -S
8687.15.34 by Karl Fogel
Add license header blocks to .py, .zcml, and .pt files that don't have it
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
7675.202.5 by Michael Hudson
more science fiction
6
# pylint: disable-msg=W0403
7
8
"""Delete from disk branches deleted from the database."""
9
10
__metaclass__ = type
11
12
import _pythonpath
13
from zope.component import getUtility
14
15
from canonical.config import config
16
from canonical.launchpad.webapp.errorlog import globalErrorUtility
7675.202.12 by Michael Hudson
mostly minor changes to get acceptance test to pass!
17
from lp.code.interfaces.branchjob import (
7675.202.5 by Michael Hudson
more science fiction
18
    IReclaimBranchSpaceJobSource)
19
from lp.services.job.runner import JobRunner
20
from lp.services.scripts.base import LaunchpadCronScript
21
22
7675.202.9 by Michael Hudson
lots of typing and a silly test
23
class RunReclaimBranchSpaceJobs(LaunchpadCronScript):
7675.202.5 by Michael Hudson
more science fiction
24
    """Run merge proposal creation jobs."""
25
26
    def main(self):
27
        globalErrorUtility.configure('reclaimbranchspace')
28
        job_source = getUtility(IReclaimBranchSpaceJobSource)
9314.1.8 by Aaron Bentley
Log oopses in reclaimbranchspace
29
        runner = JobRunner.fromReady(job_source, self.logger)
7675.202.5 by Michael Hudson
more science fiction
30
        runner.runAll()
31
        self.logger.info(
32
            'Reclaimed space for %s branches.', len(runner.completed_jobs))
33
34
35
if __name__ == '__main__':
7675.202.9 by Michael Hudson
lots of typing and a silly test
36
    script = RunReclaimBranchSpaceJobs(
7675.202.5 by Michael Hudson
more science fiction
37
        'reclaimbranchspace', config.reclaimbranchspace.dbuser)
38
    script.lock_and_run()