You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2012/01/25 09:36:38 UTC
svn commit: r1235678 -
/incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
Author: arielch
Date: Wed Jan 25 08:36:38 2012
New Revision: 1235678
URL: http://svn.apache.org/viewvc?rev=1235678&view=rev
Log:
i118814 - Allow set connection timeout in Mail API
Modified:
incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
Modified: incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py?rev=1235678&r1=1235677&r2=1235678&view=diff
==============================================================================
--- incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py (original)
+++ incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py Wed Jan 25 08:36:38 2012
@@ -40,6 +40,7 @@ from email.Header import Header
from email.MIMEMultipart import MIMEMultipart
from email.Utils import formatdate
from email.Utils import parseaddr
+from socket import _GLOBAL_DEFAULT_TIMEOUT
import sys, smtplib, imaplib, poplib
@@ -71,18 +72,31 @@ class PyMailSMTPService(unohelper.Base,
self.connectioncontext = xConnectionContext
if dbg:
print >> sys.stderr, "PyMailSMPTService connect"
+
server = xConnectionContext.getValueByName("ServerName")
if dbg:
- print >> sys.stderr, server
+ print >> sys.stderr, "ServerName: %s" % server
+
port = xConnectionContext.getValueByName("Port")
if dbg:
- print >> sys.stderr, port
- self.server = smtplib.SMTP(server, port)
+ print >> sys.stderr, "Port: %d" % port
+
+ tout = xConnectionContext.getValueByName("Timeout")
+ if dbg:
+ print >> sys.stderr, isinstance(tout,int)
+ if not isinstance(tout,int):
+ tout = _GLOBAL_DEFAULT_TIMEOUT
+ if dbg:
+ print >> sys.stderr, "Timeout: %s" % str(tout)
+
+ self.server = smtplib.SMTP(server, port,timeout=tout)
if dbg:
self.server.set_debuglevel(1)
+
connectiontype = xConnectionContext.getValueByName("ConnectionType")
if dbg:
- print >> sys.stderr, connectiontype
+ print >> sys.stderr, "ConnectionType: %s" % connectiontype
+
if connectiontype.upper() == 'SSL':
self.server.ehlo()
self.server.starttls()
@@ -214,7 +228,6 @@ class PyMailSMTPService(unohelper.Base,
filename=fname)
msg.attach(msgattachment)
-
uniquer = {}
for key in recipients:
uniquer[key] = True
@@ -340,7 +353,14 @@ class PyMailPOP3Service(unohelper.Base,
if connectiontype.upper() == 'SSL':
self.server = poplib.POP3_SSL(server, port)
else:
- self.server = poplib.POP3(server, port)
+ tout = xConnectionContext.getValueByName("Timeout")
+ if dbg:
+ print >> sys.stderr, isinstance(tout,int)
+ if not isinstance(tout,int):
+ tout = _GLOBAL_DEFAULT_TIMEOUT
+ if dbg:
+ print >> sys.stderr, "Timeout: %s" % str(tout)
+ self.server = poplib.POP3(server, port, timeout=tout)
print >> sys.stderr, "AFTER"
user = xAuthenticator.getUserName().encode('ascii')