26from sys
import platform
38 """Bootstrap OOo and PyUNO Runtime.
39 The soffice process is started opening a named pipe of random name, then the local context
is used
40 to access the pipe. This function directly returns the remote component context,
from whereon you can
41 get the ServiceManager by calling getServiceManager() on the returned object.
45 if "UNO_PATH" in os.environ:
46 sOffice = os.environ[
"UNO_PATH"]
49 sOffice = os.path.join(sOffice,
"soffice")
50 if platform.startswith(
"win"):
55 sPipeName =
"uno" + str(random.random())[2:]
58 cmdArray = (sOffice,
"--nologo",
"--nodefault",
"".join([
"--accept=pipe,name=", sPipeName,
";urp;"]))
59 os.spawnv(os.P_NOWAIT, sOffice, cmdArray)
64 resolver = xLocalContext.ServiceManager.createInstanceWithContext(
65 "com.sun.star.bridge.UnoUrlResolver", xLocalContext)
66 sConnect =
"".join([
"uno:pipe,name=", sPipeName,
";urp;StarOffice.ComponentContext"])
72 xContext = resolver.resolve(sConnect)
74 except NoConnectException:
77 raise BootstrapException(
"Cannot connect to soffice server.",
None)
80 except BootstrapException:
82 except Exception
as e:
83 raise BootstrapException(
"Caught exception " + str(e),
None)
def getComponentContext()