~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.7 by Karl Fogel
Add the copyright header block to more files.
2
#
14538.2.49 by Curtis Hovey
Updated copyright.
3
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
8687.15.7 by Karl Fogel
Add the copyright header block to more files.
4
# GNU Affero General Public License version 3 (see the file LICENSE).
5
7675.891.4 by Bryce Harrington
Update docstrings on updateremoteproduct cron job to clarify what it does
6
"""Cron job to update Product.remote_product using bug watch information.
7
8
This script sets the remote_product string value on Launchpad Products
9
by looking it up from one of the product's bug watches.
10
"""
9678.4.39 by Barry Warsaw
[rs=gary] Fix the test_all_scripts failures by making sure apport_python_hook
11
7793.5.18 by Bjorn Tillenius
Fix lint warnings.
12
# pylint: disable-msg=W0403
9678.4.39 by Barry Warsaw
[rs=gary] Fix the test_all_scripts failures by making sure apport_python_hook
13
import _pythonpath
7793.5.13 by Bjorn Tillenius
Add a cronscript for updating the remote_product.
14
15
import time
16
14612.2.8 by William Grant
cronscripts
17
from lp.bugs.scripts.updateremoteproduct import RemoteProductUpdater
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
18
from lp.services.config import config
8356.1.1 by Leonard Richardson
Partial move.
19
from lp.services.scripts.base import LaunchpadCronScript
7793.5.13 by Bjorn Tillenius
Add a cronscript for updating the remote_product.
20
21
22
class UpdateRemoteProduct(LaunchpadCronScript):
23
24
    def main(self):
25
        start_time = time.time()
26
7793.5.14 by Bjorn Tillenius
Add logging to show that the script actually does the right thing.
27
        updater = RemoteProductUpdater(self.txn, self.logger)
7793.5.13 by Bjorn Tillenius
Add a cronscript for updating the remote_product.
28
        updater.update()
29
30
        run_time = time.time() - start_time
31
        self.logger.info("Time for this run: %.3f seconds." % run_time)
32
33
34
if __name__ == '__main__':
35
    script = UpdateRemoteProduct(
36
        "updateremoteproduct", dbuser=config.updateremoteproduct.dbuser)
37
    script.lock_and_run()