Simple python script to start the OpenOffice software.
This script starts OpenOffice software.
The script uses the following modules:
1 2 3 4 5 | import os import sys import time import uno import subprocess |
Now we define the arguments for each software OpenOffice:
1 2 3 4 5 | NoConnectionException = uno.getClass("com.sun.star.connection.NoConnectException") ooffice = 'ooffice "-accept=socket,host=localhost,port=8100;urp;"' oocalc = 'oocalc "-accept=socket,host=localhost,port=8100;urp;"' ooimpress = 'ooimpress "-accept=socket,host=localhost,port=8100;urp;"' oowriter = 'oowriter "-accept=socket,host=localhost,port=8100;urp;"' |
The next step, we define a function that will start OpenOffice software.
See below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | def OOo(soft): ''' start ooo software ''' # using fork if os.fork(): return # Start OpenOffice.org and report any errors that # occur. try: retcode = subprocess.call(soft, shell=True) if retcode < 0: print >>sys.stderr,"retcode is ",-retcode elif retcode > 0: print >>sys.stderr,"retcode is ",retcode except OSError, e: print >>sys.stderr, "Error is :", err raise SystemExit() |
We use a variable to set the mode.
In this case, it is set to “False” and print some options:
1 2 3 4 5 6 | OOo_ok = False print "Use command =s below to start OOo features :" print "oocalc ooffice ooimpress oowriter " print "Do not use spaces, we will receive errors " |
Read from the keyboard software OpenOffice name to be started.
Then check if it is not already running.
1 2 3 4 5 6 | startooo=raw_input("What Ooo need to use > ") if not OOo_ok: OOo_ok = True OOo(startooo) |
Awaiting 5 seconds. During this time the software starts.
1 2 3 4 | time.sleep(5) print "OOo started now" |
This is all you need.