3944.1.1
by Francis J. Lacoste
Use system version python2.4 for scripts. |
1 |
#!/usr/bin/python2.4
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
2 |
|
3 |
# Copyright 2005 Canonical Ltd. All rights reserved.
|
|
4935.3.7
by Curtis Hovey
Added bad name suppression to cronscripts. |
4 |
# pylint: disable-msg=C0103,W0403
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
5 |
|
6 |
# This script aims to ensure that there is a Malone watch on Debian bugs
|
|
7 |
# that meet certain criteria. The Malone watch will be linked to a BugTask
|
|
8 |
# on Debian for that bug. The business of syncing is handled separately.
|
|
9 |
||
10 |
__metaclass__ = type |
|
1240
by Canonical.com Patch Queue Manager
eliminate bugassignments in favour of bugtasks |
11 |
|
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
12 |
import os |
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
13 |
import logging |
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
14 |
import _pythonpath |
3691.348.1
by kiko
Remove the original lockfile class and use our contributed GlobalLock everywhere to avoid stale locks making our scripts stop to run. Update a bunch of scripts to use it. Hopefully backwards-compatible enough to survive tests. |
15 |
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
16 |
# zope bits
|
17 |
from zope.component import getUtility |
|
1382
by Canonical.com Patch Queue Manager
new page layout |
18 |
|
19 |
# canonical launchpad modules
|
|
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
20 |
from canonical.launchpad.scripts.debsync import ( |
3691.348.1
by kiko
Remove the original lockfile class and use our contributed GlobalLock everywhere to avoid stale locks making our scripts stop to run. Update a bunch of scripts to use it. Hopefully backwards-compatible enough to survive tests. |
21 |
do_import) |
3691.348.13
by kiko
Convert a couple of cronscripts over to LaunchpadScript |
22 |
from canonical.launchpad.scripts.base import ( |
4264.2.1
by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it |
23 |
LaunchpadCronScript, LaunchpadScriptFailure) |
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
24 |
from canonical.launchpad.interfaces import ILaunchpadCelebrities |
1149
by Canonical.com Patch Queue Manager
malone debbugs integration |
25 |
|
26 |
||
27 |
# setup core values and defaults
|
|
2450
by Canonical.com Patch Queue Manager
[r=jamesh] rework cve structure, and general polish |
28 |
debbugs_location_default = '/srv/bugs-mirror.debian.org/' |
29 |
debbugs_pl = '../lib/canonical/launchpad/scripts/debbugs-log.pl' |
|
2048
by Canonical.com Patch Queue Manager
debbugssync, hct enabling, and ui fixes. r=jamesh |
30 |
|
31 |
# the minimum age, in days, of a debbugs bug before we will import it
|
|
32 |
MIN_AGE = 7 |
|
33 |
||
34 |
||
4264.2.1
by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it |
35 |
class CreateDebWatches(LaunchpadCronScript): |
3691.348.13
by kiko
Convert a couple of cronscripts over to LaunchpadScript |
36 |
description = """ |
37 |
This script syncs debbugs from http://bugs.debian.org/ into Malone.
|
|
38 |
It selects interesting bugs in debian and makes sure that there is a
|
|
39 |
Malone bug for each of them. See debwatchsync for a tool that
|
|
40 |
syncronises the bugs in Malone and debbugs, too.
|
|
41 |
"""
|
|
42 |
loglevel = logging.WARNING |
|
43 |
def add_my_options(self): |
|
44 |
self.parser.set_defaults(max=None, debbugs=debbugs_location_default) |
|
45 |
self.parser.add_option('--debbugs', action='store', type='string', |
|
46 |
dest='debbugs', |
|
47 |
help="The location of your debbugs database.") |
|
48 |
self.parser.add_option('--max', action='store', type='int', dest='max', |
|
49 |
help="The maximum number of bugs to create.") |
|
50 |
self.parser.add_option('--package', action='append', type='string', |
|
51 |
help="A list of packages for which we should import bugs.", |
|
52 |
dest="packages", default=[]) |
|
53 |
||
54 |
def main(self): |
|
55 |
if not os.path.exists(os.path.join(self.options.debbugs, 'index/index.db')): |
|
56 |
# make sure the debbugs location looks sane
|
|
57 |
raise LaunchpadScriptFailure('%s is not a debbugs db.' |
|
58 |
% self.options.debbugs) |
|
59 |
||
60 |
# Make sure we import any Debian bugs specified on the command line
|
|
61 |
target_bugs = set() |
|
62 |
for arg in self.args: |
|
63 |
try: |
|
64 |
target_bug = int(arg) |
|
65 |
except ValueError: |
|
66 |
self.logger.error('%s is not a valid debian bug number.' % arg) |
|
67 |
target_bugs.add(target_bug) |
|
68 |
||
69 |
target_package_set = set() |
|
70 |
previousimportset = set() |
|
71 |
||
72 |
self.logger.info('Calculating target package set...') |
|
73 |
||
74 |
# first find all the published ubuntu packages
|
|
75 |
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu |
|
76 |
for p in ubuntu.currentrelease.publishedBinaryPackages( |
|
77 |
component='main'): |
|
78 |
target_package_set.add(p.binarypackagename.name) |
|
79 |
# then add packages passed on the command line
|
|
80 |
for package in self.options.packages: |
|
81 |
target_package_set.add(package) |
|
82 |
self.logger.info('%d binary packages targeted.' % len(target_package_set)) |
|
83 |
||
84 |
self.txn.abort() |
|
85 |
self.txn.begin() |
|
86 |
do_import(self.logger, self.options.max, self.options.debbugs, |
|
87 |
target_bugs, target_package_set, previousimportset, MIN_AGE, |
|
88 |
debbugs_pl) |
|
89 |
self.txn.commit() |
|
90 |
||
91 |
self.logger.info('Done!') |
|
1149
by Canonical.com Patch Queue Manager
malone debbugs integration |
92 |
|
93 |
if __name__ == '__main__': |
|
3691.348.13
by kiko
Convert a couple of cronscripts over to LaunchpadScript |
94 |
script = CreateDebWatches("debbugs-mkwatch") |
95 |
script.lock_and_run() |
|
1149
by Canonical.com Patch Queue Manager
malone debbugs integration |
96 |