Mercurial > p > roundup > code
comparison roundup/scripts/roundup_mailgw.py @ 3386:263e8f485db5
don't try to set a timeout for IMAPS (thanks Paul Jimenez)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 18 Jul 2005 01:19:57 +0000 |
| parents | 437775793d8e |
| children | 22ec8e91da2b |
comparison
equal
deleted
inserted
replaced
| 3385:ed96527b1bda | 3386:263e8f485db5 |
|---|---|
| 12 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 12 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 13 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 13 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 16 # | 16 # |
| 17 # $Id: roundup_mailgw.py,v 1.20 2004-09-14 22:09:48 richard Exp $ | 17 # $Id: roundup_mailgw.py,v 1.21 2005-07-18 01:19:57 richard Exp $ |
| 18 | 18 |
| 19 """Command-line script stub that calls the roundup.mailgw. | 19 """Command-line script stub that calls the roundup.mailgw. |
| 20 """ | 20 """ |
| 21 __docformat__ = 'restructuredtext' | 21 __docformat__ = 'restructuredtext' |
| 22 | 22 |
| 23 # python version check | 23 # python version check |
| 24 from roundup import version_check | 24 from roundup import version_check |
| 25 from roundup import __version__ as roundup_version | 25 from roundup import __version__ as roundup_version |
| 26 | 26 |
| 27 import sys, os, re, cStringIO, getopt | 27 import sys, os, re, cStringIO, getopt, socket |
| 28 | 28 |
| 29 from roundup import mailgw | 29 from roundup import mailgw |
| 30 from roundup.i18n import _ | 30 from roundup.i18n import _ |
| 31 | 31 |
| 32 def usage(args, message=None): | 32 def usage(args, message=None): |
| 144 | 144 |
| 145 # otherwise, figure what sort of mail source to handle | 145 # otherwise, figure what sort of mail source to handle |
| 146 if len(args) < 3: | 146 if len(args) < 3: |
| 147 return usage(argv, _('Error: not enough source specification information')) | 147 return usage(argv, _('Error: not enough source specification information')) |
| 148 source, specification = args[1:3] | 148 source, specification = args[1:3] |
| 149 | |
| 150 # time out net connections after a minute if we can | |
| 151 if source not in ('mailbox', 'imaps'): | |
| 152 if hasattr(socket, 'setdefaulttimeout'): | |
| 153 socket.setdefaulttimeout(60) | |
| 154 | |
| 149 if source == 'mailbox': | 155 if source == 'mailbox': |
| 150 return handler.do_mailbox(specification) | 156 return handler.do_mailbox(specification) |
| 151 elif source == 'pop': | 157 elif source == 'pop': |
| 152 m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)', | 158 m = re.match(r'((?P<user>[^:]+)(:(?P<pass>.+))?@)?(?P<server>.+)', |
| 153 specification) | 159 specification) |
| 180 finally: | 186 finally: |
| 181 # handler might have closed the initial db and opened a new one | 187 # handler might have closed the initial db and opened a new one |
| 182 handler.db.close() | 188 handler.db.close() |
| 183 | 189 |
| 184 def run(): | 190 def run(): |
| 185 # time out after a minute if we can | |
| 186 import socket | |
| 187 if hasattr(socket, 'setdefaulttimeout'): | |
| 188 socket.setdefaulttimeout(60) | |
| 189 sys.exit(main(sys.argv)) | 191 sys.exit(main(sys.argv)) |
| 190 | 192 |
| 191 # call main | 193 # call main |
| 192 if __name__ == '__main__': | 194 if __name__ == '__main__': |
| 193 run() | 195 run() |
