Hi ,
I am opening a calc file by below command
edit_file_path = ":D/untitled.txt"
office_path = 'soffice'
calc = '-o'
pipe = "--accept=socket,host=localhost,port=2002;urp"
subprocess.Popen([office_path, calc, pipe, edit_file_path])
time.sleep(10)
and then doing some operations by
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext)
initialObject = resolver.resolve(
"uno:socket,host=localhost,port=2002;urp;"
"StarOffice.ServiceManager")
self.ctx = initialObject.getPropertyValue("DefaultContext")
self.smgr = self.ctx.ServiceManager
self.desktop = self.smgr.createInstanceWithContext(
"com.sun.star.frame.Desktop", self.ctx)
self.frame = self.desktop.getCurrentFrame()
if not self.frame:
raise Exception("Could not get frame")
self.dispatcher = self.smgr.createInstanceWithContext(
"com.sun.star.frame.DispatchHelper", self.ctx)
self.transformer = self.smgr.createInstanceWithContext(
"com.sun.star.util.URLTransformer", self.ctx)
self.configProvider = self.smgr.createInstanceWithContext(
"com.sun.star.configuration.ConfigurationProvider", self.ctx)
However sometimes if file is not open in less time , (may be because of taking some processing time, or sometime document ask user to select options like discard the previous one) , then the next uno commands fail with exception.
Is there any way I can check whether file is opened and connection is made before executing the other uno commands.
Sleep is not preferable as user can take infinite time if document wants user to provide some inputs.
Thanks a lot