[Libreoffice-commits] .: scripting/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Dec 12 03:54:31 PST 2012


 scripting/source/pyprov/mailmerge.py    |   24 ++++++++++++------------
 scripting/source/pyprov/officehelper.py |   16 ++++++++--------
 2 files changed, 20 insertions(+), 20 deletions(-)

New commits:
commit 37c6cfde4db921699a1b2660beeb581a9e963630
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Dec 12 12:51:21 2012 +0100

    officehelper.py: fix obvious Python 3 issues
    
    Change-Id: I40691cd6b1a0a6777e6469bf242fb41dac423587

diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py
index b177d8e..236bea1 100755
--- a/scripting/source/pyprov/mailmerge.py
+++ b/scripting/source/pyprov/mailmerge.py
@@ -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)
 
diff --git a/scripting/source/pyprov/officehelper.py b/scripting/source/pyprov/officehelper.py
index 99d3b03..0b0bb68 100755
--- a/scripting/source/pyprov/officehelper.py
+++ b/scripting/source/pyprov/officehelper.py
@@ -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


More information about the Libreoffice-commits mailing list