#!/usr/bin/python"""Unpack MIME email and only write ouf PDF in Outlook form.""""""Convert that PDF to a PS file """import osimport sysimport emailimport tempfileimport shutildef main(): #Get the message from stdin fp = sys.stdin.read() #Convert this to a message object msg = email.message_from_string(fp) for part in msg.walk(): # multipart/* are just containers if part.get_content_maintype() == 'multipart': continue if part.get_content_type() == 'application/octet-stream': #Create temp directory to store contents #tempcon = tempfile.mkdtemp() #Change to our tempcon #os.chdir(tempcon) fh = open('axaptareport.pdf', 'wb') fh.write(part.get_payload(decode=True)) fh.close() #os.system('/usr/bin/pdf2ps axaptareport.pdf') #os.chdir('..') #shutil.rmtree(tempcon)if __name__ == '__main__': main()