OpenOffice.org UNO/API Anyone;
I did a copy/paste from the snipits website:
------------------
# Connection Details to connect
# over an InterProcess Communication (IPC)
# pipe to the running OpenOffice process
def connect():
import uno
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
remoteContext = resolver.resolve(
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
return remoteContext
if __name__=="__main__":
remoteContext = connect()
------------------
Then:
------------------
User:> pwd
/opt/openoffice.org2.0/program
User:> scalc &
[1] 2991
User:> python ~/py/zt
['/home/User/py', '/opt/openoffice.org2.0/program',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/lib-dynload',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/lib-tk',
'/usr/local/lib/python2.5',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/python23.zip',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/python2.3',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/python2.3/plat-linux2',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/python2.3/lib-tk',
'/opt/openoffice.org2.0/program/python-core-2.3.4/lib/python2.3/lib-dynload']
Traceback (most recent call last):
File "/home/User/py/zt", line 38, in ?
remoteContext = connect()
File "/home/User/py/zt", line 34, in connect
remoteContext = resolver.resolve(
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
__main__.com.sun.star.connection.NoConnectException: Connector :
couldn't connect to socket (Success)
User:>
------------------
First of all:
__main__.com.sun.star.connection.NoConnectException: Connector :
couldn't connect to socket (Success) GET RID OF THAT STUPID 'Success'
when there isn't any. ;)
Second:
I want to use a combination of script.sh and program.py to do:
scalc &
sleep (s) (gotta wait for it, machine dependent time)
load file.xls
saveas file.csv
(repeat load/save as needed)
close scalc
Since starting scalc is NOT possible under python that goes in the
script.sh (along with a sleep command since soffice programs take awhile
to get going) and then it is to run the python script which does the
load...close sequence.
This is just the latest effort. ALL efforts to use all posted stuff
found to date to connect have failed.
By The Way: Although I ran this from inside the OpenOffice tree (as
prescribed by all web posted instructions found), there is absolutely no
way the production effort will be run from there. Applications go where
applications go and production goes in its proper place. The two do not
get mixed. That is absurdity. Trying to un-mix yours/mine during an
Application update is not a minor effort.
The ['/home....] is from :
#python
import os
import sys
print list(sys.path)
... the copy/paste and initiator code.
The Python in /opt/.../program seems to take care of setting the
sys.path for the user, which I consider proper for a borrowed and
embedded aid to do.
The power of Unix lies in its command lines and pipes. I am surprised
soffice has a near total lack of same.
I still want the (rather lame) automation enabled. What does work that
will accomplish it? I have no use for an embedded script that runs
when the application starts. That requires too many redundant embedded
scripts (one for write, one for calc, one for...). The applications need
to run normally and a single python script can be adapted for use under
multiple OS's and applications.
Although I have little use for Windows per se I don't have any real
trouble with using something a complicated as:
.
.
import win32com.client
.
. (check environmental controls)
.
def ---()
...(snip) prep stuff
excel = win32com.client.Dispatch( 'Excel.Application' )
excel.Visible=0 #=1 shows the spreadsheet (can be handy)
xlCSV = 6
for nm in list:
csv = os.path.splitext( nm )[0] + '.csv'
print "Processing file:", csv
if os.path.exists(csv):
os.unlink(csv)
wb = excel.Workbooks.Open( nm )
wb.SaveAs( csv, xlCSV )
wb.Close( False )
excel.Quit()
#enddef
.
. (other stuff; routing, cleanup, post processing, etc.)
So how do I do that in Linux with OpenOffice.org?
Steve
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]