Commit a5157949 authored by Yusei Tahara's avatar Yusei Tahara

Retry connection. NoConnectException sometimes occurs.

parent 3ff2d0a7
Pipeline #6516 failed with stage
in 0 seconds
import sys
import os
import time
def getServiceManager(host, port, uno_path, office_binary_path):
"""Get the ServiceManager from the running OpenOffice.org.
......@@ -20,6 +21,13 @@ def getServiceManager(host, port, uno_path, office_binary_path):
uno_context)
# Connect to the running OpenOffice.org and get its
# context.
uno_connection = resolver.resolve("uno:socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (host, port))
# Retry 10 times if needed.
for i in range(10):
try:
uno_connection = resolver.resolve("uno:socket,host=%s,port=%s;urp;StarOffice.ComponentContext" % (host, port))
break
except:
# I don't know how to import com.sun.star.connection.NoConnectException
  • At least do except Exception:

  • BTW, once uno is imported (so you can just after the above local import), it's as simple as:

    from com.sun.star.connection import NoConnectException
  • Thanks. I will fix.

Please register or sign in to reply
time.sleep(1)
# Get the ServiceManager object
return uno_connection.ServiceManager
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