#!/usr/bin/env python import re import sys import subprocess outputDirectory = '/home/xjjk/tmp' # Must use full path eventName = "keysigning party" emailMessage = """Hallo! It was nice meeting you at %s! If I can make it to the next one, perhaps I'll see you there again? Anyway, thanks for signing my key (and you've not done so yet, hopefully you will soon...). I've signed your key to which you provided the fingerprint and have attached it to this e-mail. Take care! """ % (eventName) # Read keys from stdin (format: one key ID per line) keys = [key.splitlines()[0] for key in sys.stdin.readlines()] for key in keys: print '='*10, 'Processing %s' % key, '='*30 subprocess.call('gpg --recv-keys %s' % key, shell=True) subprocess.call('gpg --sign-key %s' % key, shell=True) # Extract primary UID e-mail address from fingerprint p = subprocess.Popen('gpg --fingerprint %s' % key, shell=True, stdout=subprocess.PIPE) p.wait() fingerprintOutput = p.stdout.readlines() for line in fingerprintOutput: if line.startswith("uid"): matches = re.compile("").search(line) if matches is not None: emailAddress = matches.group(1) break # Export subprocess.call('gpg --export -a %s > ~/tmp/%s.asc' % (key, key), shell=True) print # Send e-mail via KMail for key in keys: subprocess.call('dcop kmail KMailIface openComposer "%s" "" "" "Your signed key from %s" "%s" 0 "" "/home/xjjk/tmp/%s.asc"' % (emailAddress, eventName, emailMessage, key), shell=True)

Archive