Kaydet (Commit) 37c6cfde authored tarafından Michael Stahl's avatar Michael Stahl

officehelper.py: fix obvious Python 3 issues

Change-Id: I40691cd6b1a0a6777e6469bf242fb41dac423587
üst 94a1b9c4
......@@ -80,10 +80,10 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
print("PyMailSMPTService connect", file=dbgout)
server = xConnectionContext.getValueByName("ServerName")
if dbg:
print >> dbgout, server
print(server, file=dbgout)
port = int(xConnectionContext.getValueByName("Port"))
if dbg:
print >> dbgout, port
print(port, file=dbgout)
self.server = smtplib.SMTP(server, port)
#stderr not available for us under windows, but
#set_debuglevel outputs there, and so throw
......@@ -93,7 +93,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
self.server.set_debuglevel(1)
connectiontype = xConnectionContext.getValueByName("ConnectionType")
if dbg:
print >> dbgout, connectiontype
print(connectiontype, file=dbgout)
if connectiontype == 'Ssl':
self.server.ehlo()
self.server.starttls()
......@@ -103,7 +103,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
password = xAuthenticator.getPassword().encode('ascii')
if user != '':
if dbg:
print >> dbgout, 'Logging in, username of', user
print("Logging in, username of" + user, file=dbgout)
self.server.login(user, password)
for listener in self.listeners:
......@@ -265,13 +265,13 @@ class PyMailIMAPService(unohelper.Base, XMailService):
self.connectioncontext = xConnectionContext
server = xConnectionContext.getValueByName("ServerName")
if dbg:
print >> dbgout, server
print(server, file=dbgout)
port = int(xConnectionContext.getValueByName("Port"))
if dbg:
print >> dbgout, port
print(port, file=dbgout)
connectiontype = xConnectionContext.getValueByName("ConnectionType")
if dbg:
print >> dbgout, connectiontype
print(connectiontype, file=dbgout)
print("BEFORE", file=dbgout)
if connectiontype == 'Ssl':
self.server = imaplib.IMAP4_SSL(server, port)
......@@ -283,7 +283,7 @@ class PyMailIMAPService(unohelper.Base, XMailService):
password = xAuthenticator.getPassword().encode('ascii')
if user != '':
if dbg:
print >> dbgout, 'Logging in, username of', user
print("Logging in, username of" + user, file=dbgout)
self.server.login(user, password)
for listener in self.listeners:
......@@ -334,13 +334,13 @@ class PyMailPOP3Service(unohelper.Base, XMailService):
self.connectioncontext = xConnectionContext
server = xConnectionContext.getValueByName("ServerName")
if dbg:
print >> dbgout, server
print(server, file=dbgout)
port = int(xConnectionContext.getValueByName("Port"))
if dbg:
print >> dbgout, port
print(port, file=dbgout)
connectiontype = xConnectionContext.getValueByName("ConnectionType")
if dbg:
print >> dbgout, connectiontype
print(connectiontype, file=dbgout)
print("BEFORE", file=dbgout)
if connectiontype == 'Ssl':
self.server = poplib.POP3_SSL(server, port)
......@@ -351,7 +351,7 @@ class PyMailPOP3Service(unohelper.Base, XMailService):
user = xAuthenticator.getUserName().encode('ascii')
password = xAuthenticator.getPassword().encode('ascii')
if dbg:
print >> dbgout, 'Logging in, username of', user
print("Logging in, username of" + user, file=dbgout)
self.server.user(user)
self.server.pass_(user, password)
......
......@@ -40,28 +40,28 @@ def bootstrap():
get the ServiceManager by calling getServiceManager() on the returned object.
"""
try:
# soffice script used on *ix, Mac; soffice.exe used on Windoof
# soffice script used on *ix, Mac; soffice.exe used on Win
if "UNO_PATH" in os.environ:
sOffice = os.environ["UNO_PATH"]
else:
sOffice = "" # lets hope for the best
sOffice = os.path.join(sOffice, "soffice")
if platform.startswith("win"):
if platform.startswith("win"):
sOffice += ".exe"
# Generate a random pipe name.
random.seed()
sPipeName = "uno" + str(random.random())[2:]
# Start the office process, don't check for exit status since an exception is caught anyway if the office terminates unexpectedly.
cmdArray = (sOffice, "--nologo", "--nodefault", "".join(["--accept=pipe,name=", sPipeName, ";urp;"]))
os.spawnv(os.P_NOWAIT, sOffice, cmdArray)
# ---------
xLocalContext = uno.getComponentContext()
resolver = xLocalContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", xLocalContext)
"com.sun.star.bridge.UnoUrlResolver", xLocalContext)
sConnect = "".join(["uno:pipe,name=", sPipeName, ";urp;StarOffice.ComponentContext"])
# Wait until an office is started, but loop only nLoop times (can we do this better???)
......@@ -77,8 +77,8 @@ def bootstrap():
sleep(0.5) # Sleep 1/2 second.
except BootstrapException:
raise
except Exception, e: # Any other exception
raise
except Exception as e: # Any other exception
raise BootstrapException("Caught exception " + str(e), None)
return xContext
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment