2 # vim:set encoding=utf-8:
3 ###############################################################################
5 # © 2006 Pierre Habouzit <madcoder@debian.org>
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. Neither the name of the University nor the names of its contributors
16 # may be used to endorse or promote products derived from this software
17 # without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 ###############################################################################
33 Usage: %s [-nv] nnn [remoteUri] [, nnn2 [remoteUri2]]
42 short run, don't deal with 'Done' bugs.
44 nnn the debian bug number
45 remoteUri the url of the remote bug
49 import sys, os, getopt, threading, time, signal
51 from remote import RemoteBts
52 from utils import BTSLConfig as Cnf
55 print >> sys.stderr, s
58 print >> sys.stderr, s
59 os.kill(os.getpid(), signal.SIGKILL)
62 def usage(exitCode = 1):
63 die(__doc__.lstrip() % (sys.argv[0].split('/')[-1]))
65 class Task(threading.Thread):
66 def __init__(self, rbts, res):
69 threading.Thread.__init__(self)
72 self.res += self.rbts.processQueue()
75 if __name__ == "__main__":
80 opts, args = getopt.getopt(sys.argv[1:], 'nsv', ['dry-run', 'short', 'verbose'])
81 if len(args) < 1: usage(1)
83 if o in ('-n', '--dry-run'):
85 if o in ('-s', '--short'):
87 if o in ('-v', '--verbose'):
90 RemoteBts.setup(Cnf.resources())
91 btsi = bts.BtsInterface(Cnf)
94 btsbug = btsi.getReport(id)
97 warn("#%s does not exist" % (id))
100 if short and btsbug.done:
103 if not btsbug.forward:
106 warn("#%s has no forwards" % (id))
107 if len(btsbug.fwdTo) is not 1:
108 warn("#%s has more than one forward" % (id))
111 rbts = RemoteBts.find(btsbug.forward)
114 warn("#%s: not understood: %s" % (btsbug.id, btsbug.forward))
120 for _, v in RemoteBts.resources.iteritems():
121 Task(v['bts'], res).start()
123 while threading.activeCount() > 1:
126 except KeyboardInterrupt:
130 for btsbug, cmds in res:
131 if btsbug.srcpackage in per_src:
132 per_src[btsbug.srcpackage] += cmds
134 per_src[btsbug.srcpackage] = cmds
136 mailer = bts.BtsMailer(debug)
138 for spkg, cmds in per_src.iteritems():
141 precmds.append("# bts-link upstream status pull for source package %s" % (spkg))
142 precmds.append("# see http://lists.debian.org/debian-devel-announce/2006/05/msg00001.html")
145 precmds.append("user %s" % (Cnf.get('general', 'user')))
148 cmds.append('thanks')
150 msg = mailer.BtsMail('\n'.join(precmds + cmds))
151 msg['From'] = Cnf.sender()
152 msg['To'] = 'control@bugs.debian.org'
153 msg['Cc'] = "%s, %s@packages.debian.org" % (Cnf.sender(), spkg)
154 msg['Subject'] = '[bts-link] source package %s' % (spkg)
155 msg['X-BTS-Link'] = spkg
156 if Cnf.replyTo(): msg['Reply-To'] = Cnf.replyTo()
158 mailer.sendmail(msg['From'], [msg['To'], msg['From'], "%s@packages.debian.org" % (spkg)], msg)
162 # vim:set foldmethod=indent foldnestmax=1: