MoinMessage

tests/test_fetch.py

31:d086c02844e3
2013-06-03 Paul Boddie Added initial support for fetching messages from page message stores. Added a confirmation message when messages are sent.
     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