On Sun, Mar 27, 2011 at 02:59:12PM -0600, Aaron Toponce wrote: > original = sys.stdin.readlines() > email = StringIO.StringIO(''.join(original)) > message = rfc822.Message(email) > > # ... snip several lines of code ... > > for line in original: > if len(line) == 1 and len(token_status) > 0: > print > for status in token_status: > print status > token_status = [] > else: > print line,
Somehow, the code lost its formatting, and I forgot to attach the Python script. Let's try this again: # converting a list to a file-type object for parsing rfc822 headers original = sys.stdin.readlines() email = StringIO.StringIO(''.join(original)) message = rfc822.Message(email) # ... snip ... # reprint the original mail, as well as the status of the hashcash check for line in original: if len(line) == 1 and len(token_status) > 0: print for status in token_status: print status token_status = [] else: print line, Thanks again. -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o
#!/usr/bin/env python import rfc822 import StringIO import subprocess import sys tokens = [] token_status = [] # converting a list to a file-type object for parsing rfc822 headers original = sys.stdin.readlines() email = StringIO.StringIO(''.join(original)) message = rfc822.Message(email) # check for the presence of "X-Hashcash" and "Hashcash" headers if message.has_key("X-Hashcash"): for list in message.getheaders("X-Hashcash"): tokens.append(list) if message.has_key("Hashcash"): for list in message.getheaders("Hashcash"): tokens.append(list) # check each token if len(tokens) > 0: for token in tokens: bits = token.split(":")[1] resource = token.split(":")[3] token_status.append(subprocess.call("hashcash -cdb %s -r %s -f /home/aaron/.mutt/hashcash.db %s" % (bits,resource,token), shell=True, stdout=subprocess.PIPE)) # reprint the original mail, as well as the status of the hashcash check for line in original: if len(line) == 1 and len(token_status) > 0: print for status in token_status: print status token_status = [] else: print line, #subprocess.Popen("less", shell=True)
signature.asc
Description: Digital signature