~launchpad-pqm/launchpad/devel

12579.4.2 by Steve Kowalik
Add a cronscript to run DSDJs, and the associated bits.
1
#!/usr/bin/python -S
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
"""Process DistroSeriesDifferences."""
7
8
__metaclass__ = type
9
10
import _pythonpath
11
12579.4.4 by Steve Kowalik
The cronjob will exit early if the feature flag isn't set.
12
from lp.services.features import getFeatureFlag
12579.4.2 by Steve Kowalik
Add a cronscript to run DSDJs, and the associated bits.
13
from lp.services.job.runner import JobCronScript
12579.4.4 by Steve Kowalik
The cronjob will exit early if the feature flag isn't set.
14
from lp.soyuz.model.distroseriesdifferencejob import (
15
    FEATURE_FLAG_ENABLE_MODULE,
16
    )
12579.4.2 by Steve Kowalik
Add a cronscript to run DSDJs, and the associated bits.
17
from lp.soyuz.interfaces.distributionjob import (
18
    IDistroSeriesDifferenceJobSource,
19
    )
20
21
22
class RunDistroSeriesDifferenceJob(JobCronScript):
23
    """Run DistroSeriesDifferenceJob jobs."""
24
25
    config_name = 'distroseriesdifferencejob'
26
    source_interface = IDistroSeriesDifferenceJobSource
27
12579.4.4 by Steve Kowalik
The cronjob will exit early if the feature flag isn't set.
28
    def main(self):
29
        if not getFeatureFlag(FEATURE_FLAG_ENABLE_MODULE):
30
            self.logger.info("Feature flag is not enabled.")
31
            return
32
        super(RunDistroSeriesDifferenceJob, self).main()
33
12579.4.2 by Steve Kowalik
Add a cronscript to run DSDJs, and the associated bits.
34
35
if __name__ == '__main__':
36
    script = RunDistroSeriesDifferenceJob()
37
    script.lock_and_run()