#!/usr/bin/python import os, os.path, sys, urllib, subprocess, smtplib if len(sys.argv) != 2: print '''Usage: fixbug ''' 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()