summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3a1f351)
raw | patch | inline | side by side (parent: 3a1f351)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Wed, 7 Nov 2001 05:29:26 +0000 (05:29 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Wed, 7 Nov 2001 05:29:26 +0000 (05:29 +0000) |
file. Truncates the spool file after parsing.
Fixed a couple of small bugs introduced in roundup.mailgw when I started
the popgw.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@378 57a73879-2fb5-44c3-a270-3262357dd7e2
Fixed a couple of small bugs introduced in roundup.mailgw when I started
the popgw.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@378 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup-mailgw | patch | blob | history | |
roundup/mailgw.py | patch | blob | history |
diff --git a/roundup-mailgw b/roundup-mailgw
index 8e5e7754e8cefee578edcc24c0d45a63a6c46934..6aad854e11ef76e9506f8a3d8cb4abd9b6699351 100755 (executable)
--- a/roundup-mailgw
+++ b/roundup-mailgw
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: roundup-mailgw,v 1.8 2001-11-01 22:04:37 richard Exp $
+# $Id: roundup-mailgw,v 1.9 2001-11-07 05:29:26 richard Exp $
import sys
if int(sys.version[0]) < 2:
# invoke the mail handler
db = instance.open('admin')
handler = instance.MailGW(db)
-handler.main(sys.stdin)
+
+# if there's no more arguments, read a single message from stdin
+if len(sys.argv) < 2:
+ handler.main(sys.stdin)
+
+# otherwise, there's a spool file to read from
+import fcntl, FCNTL
+spool_file = sys.argv[2]
+
+# open the spool file and lock it
+f = open(spool_file, 'r+')
+fcntl.flock(f.fileno(), FCNTL.LOCK_EX)
+
+# handle and clear the mailbox
+try:
+ from mailbox import UnixMailbox
+ import mimetools
+ mailbox = UnixMailbox(f, factory=mimetools.Message)
+ # grab one message
+ message = mailbox.next()
+ while message:
+ # call the instance mail handler
+ handler.handle_Message(message)
+ message = mailbox.next()
+ # nuke the file contents
+ os.ftruncate(f.fileno(), 0)
+except:
+ import traceback
+ traceback.print_exc()
+fcntl.flock(f.fileno(), FCNTL.LOCK_UN)
#
# $Log: not supported by cvs2svn $
+# Revision 1.8 2001/11/01 22:04:37 richard
+# Started work on supporting a pop3-fetching server
+# Fixed bugs:
+# . bug #477104 ] HTML tag error in roundup-server
+# . bug #477107 ] HTTP header problem
+#
# Revision 1.7 2001/08/07 00:24:42 richard
# stupid typo
#
diff --git a/roundup/mailgw.py b/roundup/mailgw.py
index b430f05debeb58c323eed67a7167b2a1b80532d2..d11b112938398d9f8ec148004337f85a01d2324e 100644 (file)
--- a/roundup/mailgw.py
+++ b/roundup/mailgw.py
an exception, the original message is bounced back to the sender with the
explanatory message given in the exception.
-$Id: mailgw.py,v 1.28 2001-11-01 22:04:37 richard Exp $
+$Id: mailgw.py,v 1.29 2001-11-07 05:29:26 richard Exp $
'''
m.append(s.getvalue())
m.append('---- failed message follows ----')
try:
- fp.seek(0)
+ message.fp.seek(0)
except:
pass
- m.append(fp.read())
+ m.append(message.fp.read())
if m:
try:
smtp = smtplib.SMTP(self.MAILHOST)
#
# $Log: not supported by cvs2svn $
+# Revision 1.28 2001/11/01 22:04:37 richard
+# Started work on supporting a pop3-fetching server
+# Fixed bugs:
+# . bug #477104 ] HTML tag error in roundup-server
+# . bug #477107 ] HTTP header problem
+#
# Revision 1.27 2001/10/30 11:26:10 richard
# Case-insensitive match for ISSUE_TRACKER_EMAIL in address in e-mail.
#