Re: [Tutor] adapting a converter openoffice
Tim Michelsen [EMAIL PROTECTED] wrote Therefore 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;') when I execute this script nothing happens and I would have to cancel it. When you say nothing happemed I assume you mean the script never terminated? If so I suspect your command needs to be run in the background by placing an ampersand at the end, like so: code = os.system('soffice -headless -accept=socket,port=8100;urp; ') That should result in os.system returning with an exit code. HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adapting a converter openoffice
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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] adapting a converter openoffice
When you say nothing happemed I assume you mean the script never terminated? Yes, you are right. it does not terminate and only blocks the screen. As stated on the site the script needs some special parameters of Openoffice. Therefore, until I step further, I wrap it around a shell script that I will put in my PATH: #!/bin/bash ###licence ##which licence applies for this script? If not changed it will be released under GPL: #This shell script is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. # #This shell script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # #You should have received a copy of the GNU General Public License along with this shell script ; if not, write to the #Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #or read the text online: http://www.gnu.org/licenses/gpl.txt ###script description ##convert from/to openoffice document formats using a script from ##http://www.artofsolving.com/opensource/pyodconverter ##see also: http://www.linux.com/articles/61713 #start OpenOffice as a service soffice -headless -accept=socket,port=8100;urp; #get variables # @1 = SOURCE # @2 = DESTINATION #convert command # /opt/local/pyodconverter $SOURCE $DESTINATION cd /opt/local/pyodconverter/ python ./DocumentConverter.py $1 $2 exit Maybe one day I will be able to do this in python using pyodconverter as a class... ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] adapting a converter openoffice
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. PyODConverter needs OpenOffice.org to be running as a service which can be initiated through the following command on the command line (linux shell): soffice -headless -accept=socket,port=8100;urp; once the service is up and running the conversion process is really straight forward: python DocumentConverter.py test.odt test.pdf where DocumentConverter.py is the ready-to-use converter program downloadable at http://www.artofsolving.com/opensource/pyodconverter I want to be able to convert the files anywhere without the need to start the OOo service seperately. Therefore 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? Thanks in advance for your help! Timmie ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor