[Tutor] adapting a converter openoffice

Luke Paireepinart rabidpoobear at gmail.com
Thu Jul 26 23:29:09 CEST 2007


Tim Michelsen wrote:
> Hello,
> I am Python learning in an early stage.
>
> I am currently trying to code a converter for openoffice based on 
> PyODConverter:
> http://www.artofsolving.com/opensource/pyodconverter
>
> My goal is to be able to run my script from anywhere in the system (put 
> it in Path) and then convert a file from/to openoffice formats to other 
> formats such as doc/pdf etc.
>
> My main problem is how to issue system commands and then run the above 
> script.
>   
> [snip]
> I tried to add this code on top of the original converter:
>
> ###get OOo service started first:
> import os
> code = os.system('soffice -headless -accept="socket,port=8100;urp;"') # 
> Just execute the command, return a success/fail code
>
> when I execute this script nothing happens and I would have to cancel it.
>
> Is there any way to start the OOo service from a python script?
>   
My first hunch would be that the command is running as a background 
service (daemon) so it's not returning control to your program from the 
os.system call because the execution hasn't completed yet.
Try doing a ps -ax or whatever, to see what processes you have running,
after you start your python program and before you quit it.
If you see an instance of soffice running, try terminating it and see if 
your program continues to execute (and probably raises errors).
If this is the case, you will want to use one of the other os commands, 
or subprocess, so that the soffice program will continue to run but 
you'll get control back in your program.
The only caveat to that approach would be that the soffice app 
continuing to run is dependent upon your python program continuing to 
run.  I.E. when you exit the python program, the soffice instance that 
it started (if it started one) will be ended.  Although, you  could 
probably just allow the python program to continue to run.  Not sure, I 
don't know anything about linux and I haven't had to do something 
similar to this before.
hope that he;lps.
-Luke


More information about the Tutor mailing list