List Info

Thread: quickstarter / storeToURL problem (python)




quickstarter / storeToURL problem (python)
user name
2006-01-18 12:37:31
hello again,

thanks for the quick reply.
unfortunately i cannot give any more details regarding the
errormessage. 
i'm not catching it
anymore, but all it tells me is

model.storeToURL(storeUrl, storeProps)       
uno.com.sun.star.task.ErrorCodeIOException

is there a way to get more backtrace from openoffice?

here's an example for the created urls.
file:///C:/DOKUME~1/daniela/LOKALE~1/Temp/Kanawai/leeres%20S
chreiben_12345_18-01-2006_01_28_04_mh0MirCo.odt.txt
to me they don't look any different when they do work.
any more ideas?

> Daniela Garling wrote:
>
> Please dump the URL you created on demand to the
console.
> May be it will be generated wrong in such case.
> As next try you should dump the error message given by
the catched 
> exception. May be it shows the problem already.
>
> Regards
> Andreas
>
>> 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-unsubscribeapi.openoffice.org
>> For additional commands, e-mail: dev-helpapi.openoffice.org
>>
>
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
> For additional commands, e-mail: dev-helpapi.openoffice.org
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-18 17:50:09
Daniela Garling wrote:

> hello again,
> 
> thanks for the quick reply.
> unfortunately i cannot give any more details regarding
the errormessage. 
> i'm not catching it
> anymore, but all it tells me is
> 
> model.storeToURL(storeUrl, storeProps)       
> uno.com.sun.star.task.ErrorCodeIOException

You should catch this exception and tells us which ErrorCode
is reported
by this exception (it's a member of the exception).

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBAgmx.de is
a spam sink.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-19 10:35:19
Mathias Bauer schrieb:

>Daniela Garling wrote:
>
>  
>
>>hello again,
>>
>>thanks for the quick reply.
>>unfortunately i cannot give any more details
regarding the errormessage. 
>>i'm not catching it
>>anymore, but all it tells me is
>>
>>model.storeToURL(storeUrl, storeProps)       
>>uno.com.sun.star.task.ErrorCodeIOException
>>    
>>
>
>You should catch this exception and tells us which
ErrorCode is reported
>by this exception (it's a member of the exception).
>
>Best regards,
>Mathias
>
>  
>
I don't quite know how to. What I do with python is a try:
something 
except ErrorCodeIOException: do something else.
Now, how would i "catch" the exception in order to
get to its ErrCode? 
My debugger tells me that
ErrorCodeIOException is a class-object consisting of a
__doc__ string 
(which is None), __module__ (which is
"uno"), __pyunointerface__
("com.sun.star.task.ErrorCodeIOException"), 
__pyunostruct__
("com.sun.star.task.ErrorCodeIOException"),
and typeName (also a string
"com.sun.star.task.ErrorCodeIOException").
No ErrCode to be found. What am I doing wrong?

As to the idea of inserting a little break between saving
the document 
to disk and extracting it's raw text:
I had implemented a little test to try that. the function
rawText would 
try "storeToURL" and upon an errorcodeioexception
I had it wait for 2 seconds before calling itself again and
so trying to 
extract it again. I had it running for a couple of
minutes to no avail. :/

Thanks for taking the time!
Daniela

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-19 12:14:24
Daniela Garling a écrit :

> I don't quite know how to. What I do with python is a
try: something 
> except ErrorCodeIOException: do something else.
> Now, how would i "catch" the exception in
order to get to its ErrCode? 
Except Exception, e:
	print str(e)

that would make it fine 

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-19 20:14:44
Daniela Garling wrote:

> Now, how would i "catch" the exception in
order to get to its ErrCode? 
> My debugger tells me that
> ErrorCodeIOException is a class-object consisting of a
__doc__ string 
> (which is None), __module__ (which is
> "uno"), __pyunointerface__
("com.sun.star.task.ErrorCodeIOException"), 
> __pyunostruct__
("com.sun.star.task.ErrorCodeIOException"),
> and typeName (also a string
"com.sun.star.task.ErrorCodeIOException").
> No ErrCode to be found. What am I doing wrong?

Sorry, I don't know the Python binding. From the idl file
you can see
that the ErrCodeIOException has a member "ErrCode"
of type "long". I
expected that the Python bindings allows to access this
member. Maybe
someone who knows the Python binding can help us here.

> As to the idea of inserting a little break between
saving the document 
> to disk and extracting it's raw text:
> I had implemented a little test to try that. the
function rawText would 
> try "storeToURL" and upon an
errorcodeioexception
> I had it wait for 2 seconds before calling itself again
and so trying to 
> extract it again. I had it running for a couple of
> minutes to no avail. :/

It seems that you misunderstood me. I asked you to do the
following:

quit quickstarter
wait 10 secs
start quickstarter
wait 10 secs
start python app
initiate creation of document
save document to disk, thereby initiate extraction of
rawtext

Does that make a difference?

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBAgmx.de is
a spam sink.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-23 11:27:53
Hello again,

>Sorry, I don't know the Python binding. From the idl
file you can see
>that the ErrCodeIOException has a member
"ErrCode" of type "long". I
>expected that the Python bindings allows to access this
member. Maybe
>someone who knows the Python binding can help us here.
>
>  
>
Clement wrote I should try:
Except Exception, e:
    print str(e)

But this only showed me, that apparently the ErrCode is not
accessible 
in Python. e was an empty string :/

>quit quickstarter
>wait 10 secs
>start quickstarter
>wait 10 secs
>start python app
>initiate creation of document
>save document to disk, thereby initiate extraction of
rawtext
>  
>
Oh, sorry I misunderstood you there. I now tried to do it
this way, with 
the same results.
I still have to try it once (let it fail), close the app,
start the app, 
try it again (success).

Again, thanks for taking the time!
Daniela

------------------------------------------------------------
--------------------------------
# original problem description
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 unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-24 15:42:50
Daniela Garling wrote:

>>quit quickstarter
>>wait 10 secs
>>start quickstarter
>>wait 10 secs
>>start python app
>>initiate creation of document
>>save document to disk, thereby initiate extraction
of rawtext
>>  
>>
> Oh, sorry I misunderstood you there. I now tried to do
it this way, with 
> the same results.

OK, so it is not a race condition (starting and closing
office somehow
interact strangely).

> I still have to try it once (let it fail), close the
app, start the app, 
> try it again (success).

I don't understand how the QS is involved here, maybe it's
just a symptom.

Let's try to summarize: which of the following scenarios
works and wich
doesn't:

(1)
OOo and OOo quickstarter don't run and your Python app also
doesn't run.
Now you start the Quickstarter, wait a view seconds.
Then you start your Python application.
You create your document etc.

(2)
OOo and OOo quickstarter don't run and your Python app also
doesn't run.
Now you don't start the Quickstarter or OOo, but your Python
application. It should start OOo by itself.
You create your document etc.

(3)
OOo and OOo quickstarter don't run and your Python app also
doesn't run.
Now you start OOo, e.g. by loading an OOo Writer document,
wait until
the document is loaded successfully.
Then you start your Python application.
You create your document etc.

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBAgmx.de is
a spam sink.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-24 16:24:02
>I don't understand how the QS is involved here, maybe
it's just a symptom.
>  
>
That's what I believe too, but I'm not capable of finding
out what this 
symptom might indicate ;)

>Let's try to summarize: which of the following scenarios
works and wich
>doesn't:
>
>(1)
>OOo and OOo quickstarter don't run and your Python app
also doesn't run.
>Now you start the Quickstarter, wait a view seconds.
>Then you start your Python application.
>You create your document etc.
>  
>
Does not work. I get IOException with ErrorCode 2074
(invalid parameters).

>(2)
>OOo and OOo quickstarter don't run and your Python app
also doesn't run.
>Now you don't start the Quickstarter or OOo, but your
Python
>application. It should start OOo by itself.
>You create your document etc.
>  
>
I haven't tried this scenario, mostly due to my lack of
knowledge 
regarding the automatic start of
openoffice without an open quickstarter.

>(3)
>OOo and OOo quickstarter don't run and your Python app
also doesn't run.
>Now you start OOo, e.g. by loading an OOo Writer
document, wait until
>the document is loaded successfully.
>Then you start your Python application.
>You create your document etc.
>  
>
Does not work. --> IOException with ErrorCode 2074.

(4)
OOo and OOo quickstarter don't run and my Python app also
doesn't run.
i start the quickstarter, i start my app, i create an
odt-doc, fill it 
with some contents (with my app),
save it to disk (storeAsURL). I create a new filename by
appending 
".txt" to the one just used.
I turn that into a storeUrl and try storeToURL ->
IOException.
I close my app.
I open my app.
same process as just described with successful result.

I know how absurd this sounds but it's been tested and
tested and tested ...

Kind regards,
Daniela



------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-24 17:00:42
Daniela Garling wrote:

> OOo and OOo quickstarter don't run and my Python app
also doesn't run.
> i start the quickstarter, i start my app, i create an
odt-doc, fill it 
> with some contents (with my app),
> save it to disk (storeAsURL). I create a new filename
by appending 
> ".txt" to the one just used.
> I turn that into a storeUrl and try storeToURL ->
IOException.
> I close my app.
> I open my app.
> same process as just described with successful result.
> 
> I know how absurd this sounds but it's been tested and
tested and tested ...

I can't believe that it works this way. I had a closer look:
your filter
name is definitely wrong and your program should *never*
work.

Please use the filter name "Text (encoded)" - note
the *small* "e" and
don't forget the blank character.

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project
Lead
Please reply to the list only, nospamforMBAgmx.de is
a spam sink.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

quickstarter / storeToURL problem (python)
user name
2006-01-25 11:00:38
Hello again,
first up - THANK YOU VERY MUCH!
In fact, the capitalized E in "Encoded" was indeed
the problem. Now 
everything is running smoothly,
just the way it's intended.

I did use the filter name with the capitalized e because it
was written 
that way in an example on
the official udk.openoffice.org website 
(http://udk.openoffice.org/python/samples/ooextract.py).
Maybe someone in charge should correct it there as well.

I still believe there must be some other issue there though,
since - i 
swear - this problem only
occured when I had restarted the quickstarter. I have tried
the same 
setup on another machine,
with the same result.
I should probably add, that we're not working with the
builtin-python, but
with python 2.3.5 from python.org. We replaced openoffice's
python like 
described on
h
ttp://udk.openoffice.org/python/python-bridge.html

When working with the included python there was no problem
with the 
capitalized e (tested
yesterday as well), the testscripts worked like a charm (the

ooextract.py with the filtername
"Text (Encoded)" for example).

Again, thank you very much for solving my symptom though ;)
Best regards,
Daniela


>>OOo and OOo quickstarter don't run and my Python app
also doesn't run.
>>i start the quickstarter, i start my app, i create
an odt-doc, fill it 
>>with some contents (with my app),
>>save it to disk (storeAsURL). I create a new
filename by appending 
>>".txt" to the one just used.
>>I turn that into a storeUrl and try storeToURL ->
IOException.
>>I close my app.
>>I open my app.
>>same process as just described with successful
result.
>>
>>    
>>
>I can't believe that it works this way. I had a closer
look: your filter
>name is definitely wrong and your program should *never*
work.
>
>Please use the filter name "Text (encoded)" -
note the *small* "e" and
>don't forget the blank character.
>
>Best regards,
>Mathias
>
>  
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1-10]

about | contact  Other archives ( Real Estate discussion Medical topics )