我已經搜索了答案,但目前爲止沒有任何幫助。我有一個方法可以用來創建一個odt文件並用文本填充它。我還希望用戶在創建文件時查看該文件。我使用Python 3.4.3 unotools 0.3.3 LinuxMint 17.1 LibreOffice的4.2.8.2python3 unotools連接錯誤無法連接
問題:
unotools.errors.ConnectionError: failed to connect: ('socket,host=localhost,port=8100', {})
的unotools樣品從工作細端 - 創建並保存沒有錯誤一sample.odt。我的代碼草案:
def writer_report(self):
subprocess.Popen(["soffice", "--accept='socket,host=localhost,port=8100;urp;StarOffice.Service'"])
time.sleep(5) # using this to give time for LibreOffice to open - temporary
context = connect(Socket('localhost', '8100'))
writer = Writer(context)
writer.set_string_to_end('world\n')
writer.set_string_to_start('hello\n')
writer.store_to_url('output.odt','FilterName','writer8')
writer.close(True)
的LibreOffice的應用程序打開並保持打開狀態。但是,連接似乎丟失了。
我希望有人能給我幫助,謝謝。
感謝您的建議。我試圖延長時間,但仍然沒有快樂。 –