be-handle-mail now handles non-text comments.
authorW. Trevor King <wking@drexel.edu>
Sat, 18 Jul 2009 15:03:43 +0000 (11:03 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 18 Jul 2009 15:03:43 +0000 (11:03 -0400)
This required replacing both the codec-wrapped sys.stdin _and_ the raw
sys.__stdin__ with StringIO(stdin).  becommands/comment will use only
one or the other depending on the comment's content type.

Caveat: Get_body_type only grabs the body and type of the first
non-mulitpart section, which may not be what the user expects.

Todo: Add multiple comments for each part of a multipart message, like
we do in interfaces/xml/be-mbox-to-xml.

interfaces/email/interactive/be-handle-mail

index 5409a3734316bab3233968f8c9e6509671d4a32e..e511a0b419ca3af199f81c4cc706d5999fec9fcd 100755 (executable)
@@ -147,10 +147,14 @@ def run_message(msg_text):
                 command_args = ["--alt-id", msg["message-id"]] + command_args
             command_args.append("-")
             stdin = body
+            if LOGFILE != None:
+                LOGFILE.write("len comment body: %d\n" % len(stdin))
     info["command-args"] = command_args
     # set stdin and catch stdout and stderr
     if stdin != None:
         new_stdin = StringIO.StringIO(stdin)
+        orig___stdin = sys.__stdin__
+        sys.__stdin__ = new_stdin
         orig_stdin = sys.stdin
         sys.stdin = new_stdin
     new_stdout = codecs.getwriter(ENCODING)(StringIO.StringIO())
@@ -175,6 +179,8 @@ def run_message(msg_text):
         err = InvalidCommand(msg, info, e)
     # restore stdin, stdout, and stderr
     if stdin != None:
+        sys.__stdin__ = new_stdin
+        sys.__stdin__ = orig___stdin
         sys.stdin = orig_stdin
     sys.stdout.flush()
     sys.stderr.flush()