Commit 2ad06905 authored by Boris Kocherov's avatar Boris Kocherov

rework @yusei patch a5157949

parent cedd433c
import sys
import os
import time
def getServiceManager(host, port, uno_path, office_binary_path):
"""Get the ServiceManager from the running OpenOffice.org.
......@@ -21,13 +20,6 @@ def getServiceManager(host, port, uno_path, office_binary_path):
uno_context)
# Connect to the running OpenOffice.org and get its
# context.
# 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
time.sleep(1)
uno_connection = resolver.resolve("uno:socket,host=%s,port=%s,tcpNoDelay=1;urp;StarOffice.ComponentContext" % (host, port))
# Get the ServiceManager object
return uno_connection.ServiceManager
......@@ -2,14 +2,26 @@
import sys
import helper_util
from getopt import getopt, GetoptError
import time
import uno
NoConnectException = uno.getClass("com.sun.star.connection.NoConnectException")
def test_openoffice(hostname, port):
# increase count if NoConnectException raised
count = 10
try:
helper_util.getServiceManager(hostname, port)
for i in range(count - 1):
try:
helper_util.getServiceManager(hostname, port)
break
except NoConnectException:
if i == count - 2:
helper_util.getServiceManager(hostname, port)
time.sleep(1)
return True
except Exception, err:
print err
except:
import traceback
sys.stderr.write(traceback.format_exc())
return False
......
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