~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
#
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.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
17
from canonical.config import config
8356.1.1 by Leonard Richardson
Partial move.
18
from lp.services.scripts.base import LaunchpadCronScript
7793.5.13 by Bjorn Tillenius
Add a cronscript for updating the remote_product.
19
from canonical.launchpad.scripts.updateremoteproduct import (
20
    RemoteProductUpdater)
21
22
23
class UpdateRemoteProduct(LaunchpadCronScript):
24
25
    def main(self):
26
        start_time = time.time()
27
7793.5.14 by Bjorn Tillenius
Add logging to show that the script actually does the right thing.
28
        updater = RemoteProductUpdater(self.txn, self.logger)
7793.5.13 by Bjorn Tillenius
Add a cronscript for updating the remote_product.
29
        updater.update()
30
31
        run_time = time.time() - start_time
32
        self.logger.info("Time for this run: %.3f seconds." % run_time)
33
34
35
if __name__ == '__main__':
36
    script = UpdateRemoteProduct(
37
        "updateremoteproduct", dbuser=config.updateremoteproduct.dbuser)
38
    script.lock_and_run()