2012-03-19 182 views
3

我可以使用套接字连接就好了,但是我听说当所有事情都是本地时,使用管道会更快,所以我想尝试一下,但是我无法获得连接。使用命名管道连接到LibreOffice

我开始与自由报

> soffice --headless --invisible --norestore --nodefault --nolockcheck --nofirstwizard --accept='pipe,name=ooo_pipe;urp;' 

而且最低限度Python脚本,应该工作,但并不算

import uno 
from com.sun.star.connection import NoConnectException 

pipe = 'ooo_pipe' 
localContext = uno.getComponentContext() 
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext) 
context = resolver.resolve("uno:pipe,name=%s;urp;StarOffice.ComponentContext" % pipe) 
+2

你是什么意思不起作用?你期望这个脚本做什么?你看到了什么呢? – subdir 2012-03-24 12:28:56

回答

4

我目前使用的插座模式。只需通过CMD测试我的机器上管:

/usr/lib/openoffice/program/soffice.bin -accept='pipe,name=foo;urp;StarOffice.ServiceManager' -nologo -headless -nofirststartwizard -invisible 

$ lsof -c soffice|egrep "pipe|foo" 
soffice.b 6698 user 3r FIFO    0,8  0t0 15766935 pipe 
soffice.b 6698 user 4w FIFO    0,8  0t0 15766935 pipe 
soffice.b 6698 user 15u unix 0xffff88009773ed00  0t0 15767001 /tmp/OSL_PIPE_1000_foo 

lsof的表明,有一个名为socket foo和它的确定以在Python的连接。在实验开始时,有些情况下没有生成foo,因此引发了com.sun.star.connection.NoConnectException。但之后我无法重复这个错误。

我们已经在生产中使用了插座式无头soffice几年,其稳定性和速度足够快。看来这里的管道模式仍然依赖于unix套接字,所以我建议使用套接字模式。