sample code:
import subprocess
import shlex
popen_args = "soffice --calc --norestore --nologo \
accept=\"socket,host=localhost,port=2002; urp; StarOffice.ServiceManager\" "\
+ "/home/user/test_sheet.ods"
popen_args = shlex.split(popen_args)
data_file_subprocess_handle = subprocess.Popen(popen_args, stdout = subprocess.PIPE, text=True)
# NoNoNoNoNoNo it stalls application untill sheet is manually closed
# data_file_subprocess_handle.wait()
time.sleep(5)
I am loading big data sheets, so I need to set the sleep time to 5 seconds, to make sure the sheet is fully loaded before I can proceed with extracting etc ... If i don't wait long enough, the Popen crashes because it thinks there is no sheet open. using the wait function doesn't work, because then I have to close the application manually before the script continues.
Is there a subprocess.waitForApplicationToFinishLoading kind of function, or am I looking at this the completely wrong way?