From: W. Trevor King Date: Sat, 18 Jul 2009 15:03:43 +0000 (-0400) Subject: be-handle-mail now handles non-text comments. X-Git-Tag: 1.0.0~62^2~46^2~40 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=70c8a070bfa520d72f0a5b487ca3bb2574d6de1e;p=be.git be-handle-mail now handles non-text comments. 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. --- diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail index 5409a37..e511a0b 100755 --- a/interfaces/email/interactive/be-handle-mail +++ b/interfaces/email/interactive/be-handle-mail @@ -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()