Hello list,
I have encountered a problem that I cannot understand no
matter how hard
I try:
I have a python app that calls openoffice to create a
writer document.
it then saves it to disk
using model.storeAsURL where model is the current document.
So far so good.
Then I want to extract the raw text from the document using
this function:
# code snippet
################################################
def rawText(self, model, storepath):
cwd = systemPathToFileUrl( getcwd() )
makedir(self)
filename = os.environ['TEMP'] + '\' + storepath +
'.txt'
storeUrl = absolutize( cwd,
systemPathToFileUrl(filename) )
filterName = "Text (Encoded)"
storeProps = PropertyValue( "FilterName" , 0,
filterName , 0 ),
model.storeToURL(storeUrl, storeProps)
# end of code snippet
##########################################
now - this code works. everytime. EXCEPT for, when i just
restarted the
quickstarter.
so the way to reproduce the problem is:
quit quickstarter. start quickstarter. start python app.
initiate
creation of document. save
document to disk, thereby initiate extraction of rawtext.
->
ErrorCodeIOException
the way to "solve" this problem is:
quit python app. start python app. initiate creation of
document. save
document to disk,
thereby initiate extraction of rawtext. -> success.
i suspected it might have something to do with how fast the
office gets
done with the
saving of the document and all and tried working around that
by using
this code:
# code snippet #######################################
def rawText(self, model, storepath):
cwd = systemPathToFileUrl( getcwd() )
makedir(self)
filename = os.environ['TEMP'] + '\' + storepath +
'.txt'
storeUrl = absolutize( cwd,
systemPathToFileUrl(filename) )
filterName = "Text (Encoded)"
storeProps = PropertyValue( "FilterName" , 0,
filterName , 0 ),
try:
open(os.environ['TEMP'] + '\'+ storepath, 'r')
model.storeToURL(storeUrl, storeProps)
except ErrorCodeIOException:
time.sleep(2)
rawText(self, model, storepath)
# end of code snippet ##################################
to no avail though. :/ if there's anybody with any
explanation or
workaround or
even fix for this problem, please respond.
Thanks in advance,
Daniela
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|