Mercurial > p > roundup > code
comparison roundup/mailgw.py @ 1664:2ff95415ffb2
handle deprecation of FCNTL in python2.2+
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 18 Jun 2003 23:31:52 +0000 |
| parents | fc9dafcb62e0 |
| children | dc543c28a7d0 |
comparison
equal
deleted
inserted
replaced
| 1663:09f0a54829eb | 1664:2ff95415ffb2 |
|---|---|
| 71 set() method to add the message to the item's spool; in the second case we | 71 set() method to add the message to the item's spool; in the second case we |
| 72 are calling the create() method to create a new node). If an auditor raises | 72 are calling the create() method to create a new node). If an auditor raises |
| 73 an exception, the original message is bounced back to the sender with the | 73 an exception, the original message is bounced back to the sender with the |
| 74 explanatory message given in the exception. | 74 explanatory message given in the exception. |
| 75 | 75 |
| 76 $Id: mailgw.py,v 1.121 2003-04-27 02:16:46 richard Exp $ | 76 $Id: mailgw.py,v 1.122 2003-06-18 23:31:52 richard Exp $ |
| 77 ''' | 77 ''' |
| 78 | 78 |
| 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri | 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri |
| 80 import time, random, sys | 80 import time, random, sys |
| 81 import traceback, MimeWriter, rfc822 | 81 import traceback, MimeWriter, rfc822 |
| 219 def do_mailbox(self, filename): | 219 def do_mailbox(self, filename): |
| 220 ''' Read a series of messages from the specified unix mailbox file and | 220 ''' Read a series of messages from the specified unix mailbox file and |
| 221 pass each to the mail handler. | 221 pass each to the mail handler. |
| 222 ''' | 222 ''' |
| 223 # open the spool file and lock it | 223 # open the spool file and lock it |
| 224 import fcntl, FCNTL | 224 import fcntl |
| 225 # FCNTL is deprecated in py2.3 and fcntl takes over all the symbols | |
| 226 if hasattr(fcntl, 'LOCK_EX'): | |
| 227 FCNTL = fcntl | |
| 228 else: | |
| 229 import FCNTL | |
| 225 f = open(filename, 'r+') | 230 f = open(filename, 'r+') |
| 226 fcntl.flock(f.fileno(), FCNTL.LOCK_EX) | 231 fcntl.flock(f.fileno(), FCNTL.LOCK_EX) |
| 227 | 232 |
| 228 # handle and clear the mailbox | 233 # handle and clear the mailbox |
| 229 try: | 234 try: |
