1 #!/usr/bin/env python 2 3 from MoinMessage import * 4 from email.mime.text import MIMEText 5 import sys 6 7 if __name__ == "__main__": 8 try: 9 signer = sys.argv[1] 10 recipient = sys.argv[2] 11 url = sys.argv[3] + "?action=FetchMessages" 12 args = sys.argv[4:] 13 except IndexError: 14 args = None 15 16 if not args: 17 print >>sys.stderr, "Need a signer, recipient, URL and some commands as arguments to this program." 18 sys.exit(1) 19 20 message = Message() 21 parts = [] 22 23 part = MIMEText("\n".join(args), "plain", sys.stdin.encoding) 24 message.add_update(part) 25 26 email_message = message.get_payload() 27 gpg = GPG() 28 29 try: 30 signed_message = gpg.signMessage(email_message, signer) 31 encrypted_message = gpg.encryptMessage(signed_message, recipient) 32 print sendMessage(encrypted_message, url) 33 except MoinMessageError, exc: 34 print exc 35 36 # vim: tabstop=4 expandtab shiftwidth=4