39
parser = OptionParser(description=("This script syncs debbugs from "
40
"http://bugs.debian.org/ into Malone. It selects interesting "
41
"bugs in debian and makes sure that there is a Malone bug for "
42
"each of them. See debwatchsync for a tool that syncronises "
43
"the bugs in Malone and debbugs, too."))
44
logger_options(parser, logging.WARNING)
45
parser.set_defaults(max=None, debbugs=debbugs_location_default)
46
parser.add_option('--debbugs', action='store', type='string',
48
help="The location of your debbugs database.")
49
parser.add_option('--max', action='store', type='int', dest='max',
50
help="The maximum number of bugs to create.")
51
parser.add_option('--package', action='append', type='string',
52
help="A list of packages for which we should import bugs.",
53
dest="packages", default=[])
54
options, args = parser.parse_args()
57
logger = logger_from_options(options)
59
# make sure the debbugs location looks sane
60
if not os.path.exists(os.path.join(options.debbugs, 'index/index.db')):
61
logger.error('%s is not a debbugs db.' % options.debbugs)
64
# Make sure we import any Debian bugs specified on the command line
69
logger.error('%s is not a valid debian bug number.' % arg)
70
target_bugs.add(target_bug)
72
logger.info('Setting up utilities...')
73
execute_zcml_for_scripts()
76
target_package_set = set()
77
previousimportset = set()
79
logger.info('Connecting to database...')
80
ztm = initZopeless(implicitBegin=False)
83
logger.info('Calculating target package set...')
85
# first find all the published ubuntu packages
86
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
87
for p in ubuntu.currentrelease.publishedBinaryPackages(
89
target_package_set.add(p.binarypackagename.name)
90
# then add packages passed on the command line
91
for package in options.packages:
92
target_package_set.add(package)
93
logger.info('%d binary packages targeted.' % len(target_package_set))
95
lockfile_path = '/var/lock/launchpad-debbugs-mkwatch.lock'
96
lockfile = LockFile(lockfile_path)
100
logger.info('Lockfile %s already exists, exiting.' % lockfile_path)
106
do_import(logger, options.max, options.debbugs, target_bugs,
107
target_package_set, previousimportset, MIN_AGE, debbugs_pl)
110
logger.exception('Uncaught exception!')
34
class CreateDebWatches(LaunchpadScript):
36
This script syncs debbugs from http://bugs.debian.org/ into Malone.
37
It selects interesting bugs in debian and makes sure that there is a
38
Malone bug for each of them. See debwatchsync for a tool that
39
syncronises the bugs in Malone and debbugs, too.
41
loglevel = logging.WARNING
42
def add_my_options(self):
43
self.parser.set_defaults(max=None, debbugs=debbugs_location_default)
44
self.parser.add_option('--debbugs', action='store', type='string',
46
help="The location of your debbugs database.")
47
self.parser.add_option('--max', action='store', type='int', dest='max',
48
help="The maximum number of bugs to create.")
49
self.parser.add_option('--package', action='append', type='string',
50
help="A list of packages for which we should import bugs.",
51
dest="packages", default=[])
54
if not os.path.exists(os.path.join(self.options.debbugs, 'index/index.db')):
55
# make sure the debbugs location looks sane
56
raise LaunchpadScriptFailure('%s is not a debbugs db.'
57
% self.options.debbugs)
59
# Make sure we import any Debian bugs specified on the command line
65
self.logger.error('%s is not a valid debian bug number.' % arg)
66
target_bugs.add(target_bug)
68
target_package_set = set()
69
previousimportset = set()
71
self.logger.info('Calculating target package set...')
73
# first find all the published ubuntu packages
74
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
75
for p in ubuntu.currentrelease.publishedBinaryPackages(
77
target_package_set.add(p.binarypackagename.name)
78
# then add packages passed on the command line
79
for package in self.options.packages:
80
target_package_set.add(package)
81
self.logger.info('%d binary packages targeted.' % len(target_package_set))
85
do_import(self.logger, self.options.max, self.options.debbugs,
86
target_bugs, target_package_set, previousimportset, MIN_AGE,
90
self.logger.info('Done!')
118
92
if __name__ == '__main__':
119
sys.exit(main(sys.argv))
93
script = CreateDebWatches("debbugs-mkwatch")