]> piware.de Git - bin.git/commitdiff
add fixbug
authormartin@piware.de <>
Sun, 28 Jan 2007 12:29:25 +0000 (13:29 +0100)
committermartin@piware.de <>
Sun, 28 Jan 2007 12:29:25 +0000 (13:29 +0100)
fixbug [new file with mode: 0755]

diff --git a/fixbug b/fixbug
new file mode 100755 (executable)
index 0000000..1238f90
--- /dev/null
+++ b/fixbug
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+
+import os, os.path, sys, urllib, subprocess, smtplib
+
+if len(sys.argv) != 2:
+    print '''Usage: fixbug <bug number>'''
+    sys.exit (1)
+
+bug = int(sys.argv[1])
+desc = sys.stdin.read()
+
+# generate bug report
+report = ''
+
+report += ''' status fixreleased
+
+%s
+''' % desc
+
+# sign it
+sign_command = 'gpg'
+if os.access('/usr/bin/gnome-gpg', os.X_OK):
+    sign_command = 'gnome-gpg'
+
+gpg = subprocess.Popen([sign_command, '--clearsign'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+signed_report = gpg.communicate(report)[0]
+assert gpg.returncode == 0
+
+# generate email
+myemailaddr = os.getenv('DEBEMAIL')
+assert myemailaddr
+to = '%i@bugs.launchpad.net' % bug
+
+mail = '''From: %s
+To: %s
+Subject: Fixed
+
+%s''' % (myemailaddr, to, signed_report)
+
+s = smtplib.SMTP('fiordland.ubuntu.com')
+s.sendmail(myemailaddr, to, mail)
+s.quit()