rev 3572 - scripts

Pierre Habouzit madcoder at costa.debian.org
Mon Apr 17 18:23:55 UTC 2006


Author: madcoder
Date: 2006-04-17 18:23:55 +0000 (Mon, 17 Apr 2006)
New Revision: 3572

Added:
   scripts/bzsync.py
Modified:
   scripts/bzlink.py
Log:
Add copyright/license (BSD)
Add bzsync.py (a lot less nicely written than bzlink). that does that :

either (1) :

  ./bzsync.py nnn http://bugs.kde.org/NNN
  
  sets nnn as forwarded to http://bugs.kde.org/NNN
  copy State/Resolution as user tags (like bzlink would do)

or (2) :

  ./bzsync.py http://bugs.kde.org/NNN

  figures out which bts bug is forwarded to that NNN kde bug,
  and copy State/Resolution usertags.





Modified: scripts/bzlink.py
===================================================================
--- scripts/bzlink.py	2006-04-17 17:24:14 UTC (rev 3571)
+++ scripts/bzlink.py	2006-04-17 18:23:55 UTC (rev 3572)
@@ -1,4 +1,31 @@
 #! /usr/bin/env python
+###############################################################################
+# Cppyright: Pierre Habouzit <madcoder at debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+###############################################################################
 
 import sys, re, os, ldap
 import email, smtplib

Added: scripts/bzsync.py
===================================================================
--- scripts/bzsync.py	2006-04-17 17:24:14 UTC (rev 3571)
+++ scripts/bzsync.py	2006-04-17 18:23:55 UTC (rev 3572)
@@ -0,0 +1,97 @@
+#! /usr/bin/env python
+###############################################################################
+# Cppyright: Pierre Habouzit <madcoder at debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+###############################################################################
+
+"""
+Usage: %s nnn http://bugs.kde.org/NNN
+
+    mark debian bug #nnn be forwarded to http://bugs.kde.org/NNN
+    also update usertag flags (bzStatus/bzRes atm).
+
+"""
+
+import sys, re, os, commands, email, smtplib
+from email.MIMEText import MIMEText
+from bzlink import BtsQuery, patterns
+
+wget   = "wget -o /dev/null -O - %s | egrep '<b>(Status|Resolution)'"
+bugurl = re.compile(r"^http://bugs.kde.org/([0-9]*)$")
+
+def usage(exitCode = 1):
+    print >> sys.stderr, (__doc__ % (sys.argv[0].split('/')[-1]))
+    sys.exit(exitCode)
+
+def prepareMail(bug, url):
+    flags = commands.getoutput(wget % (url))
+    flags = re.sub(r"<[^<]*>", "", flags)
+
+
+    body  = "user debian-qt-kde at lists.debian.org\n"
+    body += "forwarded %s %s\n" % (bug, url)
+    body += "usertag %s =\n" % (bug)
+    for l in flags.splitlines():
+        k, v = l.split(':')
+        if k == 'Status':
+            body += "usertag %s + bzStatus-%s\n" % (bug, v.lower())
+        if k == 'Resolution':
+            body += "usertag %s + bzRes-%s\n" % (bug, v.lower())
+    body += "thanks\n"
+
+    return body
+
+if __name__ == "__main__":
+    url = sys.argv[-1]
+
+    m = bugurl.match(url)
+    if not m: usage(1)
+
+    bzBug = m.group(1)
+
+    if len(sys.argv) is 2:
+        bts = BtsQuery()
+        bug = bts.fromBzBug(patterns, int(bzBug))
+        if bug is None:
+            print >> sys.stderr, "Cannot find any debian bug forwarded to upstream bug %s" % bzBug
+            sys.exit(1)
+        bug = bug['debbugsID'][0]
+    elif len(sys.argv) is 3:
+        bug = sys.argv[1]
+    else: usage(1)
+
+    msg = MIMEText(prepareMail(bug, url))
+    msg['From'] = 'debian-qt-kde at lists.debian.org'
+    msg['To']   = 'control at bugs.debian.org'
+    msg['X-Debbugs-No-Ack'] = 'no-acks'
+    msg['Content-Type'] = 'text/plain; charset="utf-8"'
+
+    s = smtplib.SMTP()
+    s.connect()
+    s.sendmail(msg['From'], [msg['To']], msg.as_string())
+    s.close()
+
+# vim:set foldmethod=indent foldnestmax=1:


Property changes on: scripts/bzsync.py
___________________________________________________________________
Name: svn:executable
   + *




More information about the pkg-kde-commits mailing list