~launchpad-pqm/launchpad/devel

10899.3.11 by Aaron Bentley
Update script to use system python.
1
#!/usr/bin/python -S
10899.2.3 by Aaron Bentley
Add daily builds script, rename SourcePackageRecipe.requestDailyBuilds.
2
#
3
# Copyright 2010 Canonical Ltd.  This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
6
# pylint: disable-msg=W0403
7
8
"""Request builds for stale daily build recipes."""
9
10
__metaclass__ = type
11
12
import _pythonpath
10899.2.4 by Aaron Bentley
Fix lint issues.
13
14
import transaction
10899.2.3 by Aaron Bentley
Add daily builds script, rename SourcePackageRecipe.requestDailyBuilds.
15
from zope.component import getUtility
16
14612.2.8 by William Grant
cronscripts
17
from lp.code.interfaces.sourcepackagerecipebuild import (
18
    ISourcePackageRecipeBuildSource,
19
    )
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
20
from lp.services.config import config
10899.2.3 by Aaron Bentley
Add daily builds script, rename SourcePackageRecipe.requestDailyBuilds.
21
from lp.services.scripts.base import LaunchpadCronScript
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
22
from lp.services.webapp.errorlog import globalErrorUtility
10899.2.3 by Aaron Bentley
Add daily builds script, rename SourcePackageRecipe.requestDailyBuilds.
23
24
25
class RequestDailyBuilds(LaunchpadCronScript):
26
    """Run create merge proposal jobs."""
27
28
    def __init__(self):
29
        name = 'request_daily_builds'
30
        dbuser = config.request_daily_builds.dbuser
31
        LaunchpadCronScript.__init__(self, name, dbuser)
32
33
    def main(self):
34
        globalErrorUtility.configure(self.name)
35
        source = getUtility(ISourcePackageRecipeBuildSource)
12070.1.1 by Tim Penhey
Log the recipes that are having daily builds requested.
36
        builds = source.makeDailyBuilds(self.logger)
10899.2.3 by Aaron Bentley
Add daily builds script, rename SourcePackageRecipe.requestDailyBuilds.
37
        self.logger.info('Requested %d daily builds.' % len(builds))
38
        transaction.commit()
39
40
41
if __name__ == '__main__':
42
    script = RequestDailyBuilds()
43
    script.lock_and_run()