~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
2
# Copyright 2005 Canonical Ltd.  All rights reserved.
4935.3.7 by Curtis Hovey
Added bad name suppression to cronscripts.
3
# pylint: disable-msg=C0103,W0403
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
4
# Author: Gustavo Niemeyer <gustavo@niemeyer.net>
3249.6.1 by David Allouche
branch-scanner.py renaming and ScriptsAndDaemons compliance
5
#         David Allouche <david@allouche.net>
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
6
7
"""Update bzr branches information in the database"""
8
9
10
import _pythonpath
11
import logging
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
12
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
13
from canonical.config import config
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
14
from canonical.launchpad.scripts.base import LaunchpadCronScript
5121.1.1 by jml at canonical
Move the branch scanner to codehosting/
15
from canonical.codehosting.scanner.branch_scanner import BranchScanner
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
16
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
17
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
18
class UpdateBranches(LaunchpadCronScript):
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
19
    def main(self):
20
        # We don't want debug messages from bzr at that point.
21
        bzr_logger = logging.getLogger("bzr")
22
        bzr_logger.setLevel(logging.INFO)
23
3691.376.15 by David Allouche
do not use a separate launchpad.conf
24
        # Customize the oops reporting config
25
        oops_prefix = config.branchscanner.errorreports.oops_prefix
26
        config.launchpad.errorreports.oops_prefix = oops_prefix
27
        errordir = config.branchscanner.errorreports.errordir
28
        config.launchpad.errorreports.errordir = errordir
3691.376.16 by David Allouche
override copy_to_zlog as well
29
        copy_to_zlog = config.branchscanner.errorreports.copy_to_zlog
30
        config.launchpad.errorreports.copy_to_zlog = copy_to_zlog
3691.376.15 by David Allouche
do not use a separate launchpad.conf
31
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
32
        BranchScanner(self.txn, self.logger).scanAllBranches()
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
33
3109.3.1 by David Allouche
improve logging in update-branches.py
34
2841.1.1 by Gustavo Niemeyer
Implementing update-branches cronscript.
35
if __name__ == '__main__':
3691.348.13 by kiko
Convert a couple of cronscripts over to LaunchpadScript
36
    script = UpdateBranches("updatebranches", dbuser=config.branchscanner.dbuser)
37
    script.lock_and_run()
38