~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
14612.2.8 by William Grant
cronscripts
13
7675.202.5 by Michael Hudson
more science fiction
14
from zope.component import getUtility
15
14612.2.8 by William Grant
cronscripts
16
from lp.code.interfaces.branchjob import IReclaimBranchSpaceJobSource
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
17
from lp.services.config import config
7675.202.5 by Michael Hudson
more science fiction
18
from lp.services.job.runner import JobRunner
19
from lp.services.scripts.base import LaunchpadCronScript
14612.2.8 by William Grant
cronscripts
20
from lp.services.webapp.errorlog import globalErrorUtility
7675.202.5 by Michael Hudson
more science fiction
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()