From b69e2eedec086a68590a8167736edea923432626 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 15 Oct 2002 06:51:32 +0000 Subject: [PATCH] store PIPE messages so we can re-send them on errors git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1353 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailgw.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 9bb0229..887f523 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.95 2002-10-07 00:52:51 richard Exp $ +$Id: mailgw.py,v 1.96 2002-10-15 06:51:32 richard Exp $ ''' import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -145,8 +145,15 @@ class MailGW: def do_pipe(self): ''' Read a message from standard input and pass it to the mail handler. + + Read into an internal structure that we can seek on (in case + there's an error). + + XXX: we may want to read this into a temporary file instead... ''' - self.main(sys.stdin) + s = cStringIO.StringIO() + s.write(sys.stdin.read()) + self.main(s) return 0 def do_mailbox(self, filename): @@ -337,8 +344,8 @@ class MailGW: body = w.startbody(content_type) try: message.rewindbody() - except IOError: - body.write("*** couldn't include message body: read from pipe ***") + except IOError, message: + body.write("*** couldn't include message body: %s ***"%message) else: body.write(message.fp.read()) -- 2.30.2