LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   uniconv 0.4 problem (python debugging?) (https://www.linuxquestions.org/questions/programming-9/uniconv-0-4-problem-python-debugging-852477/)

catkin 12-26-2010 12:44 PM

uniconv 0.4 problem (python debugging?)
 
Hello :)

Running the uniconv 0.4 python script for the first time, on an OOo-generated test .doc (with a single line of text):
Code:

c@CW8:~/d/tmp$ unoconv --stdout -f text Test.doc
Traceback (most recent call last):
  File "/usr/bin/unoconv", line 67, in <module>
    os.environ['LD_LIBRARY_PATH'] = oolibpath + os.pathsep + os.environ['LD_LIBRARY_PATH']
  File "/usr/lib64/python2.6/UserDict.py", line 22, in __getitem__
    raise KeyError(key)
KeyError: 'LD_LIBRARY_PATH'

The problem is probably in the environment, possible a python version mismatch ... but I don't have enough python to know where to begin.

Here's what looks like the relevant part of /usr/bin/unoconv:
Code:

53 try:
 54    import uno, unohelper
 55 except ImportError:
 56    for oolibpath in extrapaths:
 57        if os.path.exists(os.path.join(oolibpath, "pyuno.so")):
 58            filename = "pyuno.so"
 59        elif os.path.exists(os.path.join(oolibpath, "pyuno.pyd")):
 60            filename = "pyuno.pyd"
 61        else:
 62            continue
 63        try:
 64            sys.path.append(oolibpath)
 65            import uno, unohelper
 66            ### Export an environment that OpenOffice is pleased to work with
 67            os.environ['LD_LIBRARY_PATH'] = oolibpath + os.pathsep + os.environ['LD_LIBRARY_PATH']
 68            break

$LD_LIBRARY_PATH is not set in the calling shell ... ?

Here's /usr/lib64/python2.6/UserDict.py, up to line 22:
Code:

  1 """A more or less complete user-defined wrapper around dictionary objects."""
  2
  3 class UserDict:
  4    def __init__(self, dict=None, **kwargs):
  5        self.data = {}
  6        if dict is not None:
  7            self.update(dict)
  8        if len(kwargs):
  9            self.update(kwargs)
 10    def __repr__(self): return repr(self.data)
 11    def __cmp__(self, dict):
 12        if isinstance(dict, UserDict):
 13            return cmp(self.data, dict.data)
 14        else:
 15            return cmp(self.data, dict)
 16    def __len__(self): return len(self.data)
 17    def __getitem__(self, key):
 18        if key in self.data:
 19            return self.data[key]
 20        if hasattr(self.__class__, "__missing__"):
 21            return self.__class__.__missing__(self, key)
 22        raise KeyError(key)

In case more code is needed, uniconv 0.4 is online for a month at http://pastebin.com/9tuNeijQ or it can be installed amazingly easily (yay for python!) along with its man page from http://dag.wieers.com/home-made/unoc...nv-0.4.tar.bz2:
Code:

root@CW8:~# cp /home/c/d/Repository/src/unoconv-0.4.tar.bz2 /tmp \
  && cd /tmp \
  && tar -xvf  unoconv-0.4.tar.bz2 \
  && cd unoconv-0.4 \
  && make \
  && make install
[snip]
install -Dp -m0755 unoconv /usr/bin/unoconv
install -Dp -m0644 docs/unoconv.1 /usr/share/man/man1/unoconv.1

Best

Charles

catkin 12-27-2010 06:06 AM

Fixed by patch from Novell bugzilla.

EDIT but now failing with
Code:

c@CW8:~/d/tmp$ soffice -headless -accept='socket,host=127.0.0.1,port=2002;urp;'
c@CW8:~/d/tmp$ unoconv --stdout -f text Test.doc
Traceback (most recent call last):
  File "/usr/bin/unoconv", line 796, in <module>
    main()
  File "/usr/bin/unoconv", line 775, in main
    convertor.convert(inputfn)
  File "/usr/bin/unoconv", line 608, in convert
    doc = self.desktop.loadComponentFromURL( inputurl , "_blank", 0, inputprops )
AttributeError: loadComponentFromURL

That is a known issue for OOO 3.0.0 (I am using 3.2.1) which is still open (http://www.openoffice.org/issues/show_bug.cgi?id=90701) with fix most comprehensibly given at http://piiis.blogspot.com/2008_10_01_archive.html. Tried but did not fix. Maybe switch to PyODConverter (Python OpenDocument Converter)?


All times are GMT -5. The time now is 02:33 PM.