views:

347

answers:

1

I'm trying to get the sample and other sample codes i find for pyuno running with openoffice 3.1.1 and python 2.5 with no luck.

Unfortunately, pyuno does not give any clues about what goes wrong.


In [1]: import uno
In [2]: local = uno.getComponentContext()
In [3]: resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)
---------------------------------------------------------------------------
com.sun.star.uno.RuntimeException         Traceback (most recent call last)

/opt/openoffice.org/basis3.1/program/ in ()

com.sun.star.uno.RuntimeException: : 'tuple' object has no attribute 'getTypes', traceback follows
no traceback available

below is the output of execution of /opt/openoffice.org/basis3.1/program/officehelper.py which basically boots the headless office instance and returns a related context object.

den@ev:/opt/openoffice.org/basis3.1/program > python officehelper.py
Traceback (most recent call last):
  File "officehelper.py", line 42, in 
    from com.sun.star.connection import NoConnectException
  File "uno.py", line 273, in _uno_import
    RuntimeException = pyuno.getClass( "com.sun.star.uno.RuntimeException" )
RuntimeError: pyuno.getClass: expecting one string argument

pyuno takes only 1 argument and it hasto be a string, as defined in http://udk.openoffice.org/source/browse/udk/pyuno/source/module/pyuno%5Fmodule.cxx?rev=1.14&view=markup i could not manage to get pyuno.getClass work anyway.

any suggestions about how to get pyuno working?

+2  A: 

In [1]: import uno In [2]: local = uno.getComponentContext() In [3]: resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)

OOP gone wrong, imho. i know its OT, but i tried getting uno to work before, and gave up. this is pure Steve Yegge Prose (read up on http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html).

when you translate those lines into a more speakable form, they come out roughly as:

"Let 'local' be the result of calling method 'get component context' of 'uno'. Let the 'service manager' be the attribute 'service manager' of 'local'. Let 'resolver' be the result of calling the 'service manager' method 'create instance with context', using arguments 'com sun star bridge uno url resolver' and 'local'."

omg. no surprise something is wrong with a program that is so atrociously over-specific, convoluted, and self-referential while being not self-aware... you call a sub-method of 'local' and that sub-method has to be told what 'local' means? say what? hats off to the fearless developers who can cut through this. happy debugging.

ADDED:

thx for comment and points.

the pyuno problem i cannot do anything about in fact, but i encourage to persue a patient trytrytry approach with a clear deadline.

i also suggest to file an outright B.U.G. with the pyuno people (if they are in fact active—i got the impression that this was a rather silent project) because of the nonsense error message: the method in question appears to request one string argument, and it gets one, and it complains it did. this is so not helpful to the degree it becomes reasonable to declare a code fault.

in this kind of situation i often look into the sources. but you already did that, right?

i hate people to ask back ‘why do you want to do this?’ when i ask for help. however, sometimes someone (maybe you) does come up with another workable path in the process, one that does not include a solution to the particular problem, but helps to solve the superordinate one. so, if i may ask: what is the big picture?

flow
+1 for the help, +1 for the steve yegge reference -1 for pointing out the solutionlessness, thanks ;)
hinoglu
how i love the verbosity of your comments :) in the big picture, i'm trying to paint an on the fly document modifier/converter. I'll modify the contents of uploaded doc/docx documents and convert them to pdf. i was planning to use wvware first, but it does not provide docx compatibility. i've seen some other projects like docxtoany, unfortunately xsl sucks the life out of me. only way i could come up with was to use a headless openoffice instance bridging with python. but could not get it working :' i guess i'll give a try to docxtoany
hinoglu
if you are aiming at ms office doc(x) documents, then open office is maybe not even the ideal solution... i haven't thoroughly tested it but i'm afraid that many details of doc(x)s will render differently in open office. next important detail is: how much do you want to modify the documents? if it is just about putting your copyright notice on each page, then it could become a matter of assembling pdfs.
flow
just a small modification.as you pointed out, a copyright notice and a small logo to every page of the document. then save it as pdf. unfortunately source documents will only be in doc(x) format.
hinoglu