Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 262083

Summary: app-office/unoconv-0.3 (New Package)
Product: Gentoo Linux Reporter: Dan Fego <dan.fego>
Component: New packagesAssignee: Gentoo Office Team <office>
Status: RESOLVED FIXED    
Severity: enhancement CC: christoph.safferling, denilsonsa, gregoire.favre, rktspm, shawlz, sunrise, walter.dacol, zioalex
Priority: High Keywords: EBUILD, InOverlay
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard: [sunrise-overlay]
Package list:
Runtime testing required: ---
Attachments: unoconv-0.3.ebuild
uconv-0.3-r1.ebuild using included patch to work with ooo3 on gentoo
Ebuild for unoconv-0.4 plus python 2.7 fix
Fix for KeyError Exception with python 2.7
New ebuild incorporating a new patch to work with libreoffice
Add support for libreoffice, needs unoconv-0.4-r3.ebuild
ebuild for unoconv git
updated timeout patch

Description Dan Fego 2009-03-11 07:19:32 UTC
Attached is the unoconv-0.3 ebuild. This package is currently in the graaff overlay (which is where I got the ebuild). It's currently marked as app-office.

From the project website:
(http://dag.wieers.com/home-made/unoconv/)

unoconv converts between any document format that OpenOffice understands. It uses OpenOffice's UNO bindings for non-interactive conversion of documents.

Supported document formats include Open Document Format (.odt), MS Word (.doc), MS Office Open/MS OOXML (.xml), Portable Document Format (.pdf), HTML, XHTML, RTF, Docbook (.xml), and more.

Reproducible: Always
Comment 1 Dan Fego 2009-03-11 07:21:05 UTC
Created attachment 184654 [details]
unoconv-0.3.ebuild
Comment 2 Dan Fego 2009-03-11 07:25:04 UTC
I was perhaps a bit quick to submit this, as the program compiles, but it doesn't work for me. I assumed it would be alright since other people on Gentoo are obviously using it. My bad.
Comment 3 Alessandro Surace 2009-05-05 13:16:11 UTC
Hi Dan,
thanks for the ebuild.

With OOo3 the unoconv source must be changed so you need to specify the URE_BOOTSTRAP at the top of unoconv after "import getopt, sys, os, glob, time"

os.putenv('URE_BOOTSTRAP','vnd.sun.star.pathname:/usr/lib/openoffice/program/fun
damentalrc')

And change the extrapaths:
extrapaths = glob.glob('/usr/lib*/openoffice*/program/') + glob.glob('/usr/lib*/ooo*/program') + glob.glob('/usr/lib/openoffice*/basis*/program') + [ '/Applications/NeoOffice.app/Contents/program', ]


A detailed explanation here http://mpd.homeip.net/?p=250
I've contacted the maintainer to ask him to do that mods.
 
Comment 4 shawlz 2009-05-12 21:56:21 UTC
$ unoconv -f pdf  word07.doc 
/usr/lib/openoffice/basis3.0/program/uno.py:33: RuntimeWarning: Python C API version mismatch for module pyuno: This Python has API version 1013, module pyuno has version 1012.
  import pyuno
Traceback (most recent call last):
  File "/home/vov/bin/exe/unoconv", line 564, in <module>
    main()
  File "/home/vov/bin/exe/unoconv", line 540, in main
    convertor = Convertor()
  File "/home/vov/bin/exe/unoconv", line 371, in __init__
    error(2, "Existing listener not found.\n%s" % e)
  File "/usr/lib/openoffice/basis3.0/program/uno.py", line 329, in _uno_struct__repr__
    return repr(self.__dict__["value"])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-23: ordinal not in range(128)
Comment 5 shawlz 2009-05-12 21:56:58 UTC
$ unoconv -f pdf  word07.doc 
/usr/lib/openoffice/basis3.0/program/uno.py:33: RuntimeWarning: Python C API version mismatch for module pyuno: This Python has API version 1013, module pyuno has version 1012.
  import pyuno
Traceback (most recent call last):
  File "/home/vov/bin/exe/unoconv", line 564, in <module>
    main()
  File "/home/vov/bin/exe/unoconv", line 540, in main
    convertor = Convertor()
  File "/home/vov/bin/exe/unoconv", line 371, in __init__
    error(2, "Existing listener not found.\n%s" % e)
  File "/usr/lib/openoffice/basis3.0/program/uno.py", line 329, in _uno_struct__repr__
    return repr(self.__dict__["value"])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-23: ordinal not in range(128)
Comment 6 Sven Eden 2009-12-17 15:24:48 UTC
Created attachment 213294 [details]
uconv-0.3-r1.ebuild using included patch to work with ooo3 on gentoo

The ebuild uses EAPI 2 and applies a patch doing the changes to the unoconv source described by Alessandro Surace. With those unoconv works like a charm on my x86 computer, tested with html, Microsoft Word and Microsoft Excel files, all converted to pdf.
Comment 7 Christoph Safferling 2010-06-29 16:18:57 UTC
Hm, doesn't work here. Anything I'm doing wrong? I used the 0.3-r1 tarball. 

$ unoconv -f pdf 01-intro.rtf 
Traceback (most recent call last):
  File "/usr/bin/unoconv", line 30, in <module>
    import uno, unohelper
  File "/usr/lib/openoffice/basis3.2/program/uno.py", line 33, in <module>
    import pyuno
SystemError: dynamic module not initialized properly
Comment 8 Grégoire Favre 2010-08-20 21:07:35 UTC
I also got the SystemError: dynamic module not initialized properly.
I wonder if that's supposed to work with app-office/openoffice-bin-3.2.1 for amd64 or if I should compil it myself (just for reading email that %*ç%* people write using docx would be a shame).
Comment 9 J.Borme 2010-08-23 07:41:03 UTC
(In reply to comment #8)
> I also got the SystemError: dynamic module not initialized properly.
> I wonder if that's supposed to work with app-office/openoffice-bin-3.2.1 for
> amd64 or if I should compil it myself (just for reading email that %*ç%*
> people write using docx would be a shame).
> 

I tested with both on amd64. app-office/unoconv-0.3-r2 (from graaff overlay) works properly with app-office/openoffice-3.2.1 on amd64 and refuses to work with app-office/openoffice-bin-3.2.0.

So in some way it depends on openoffice-3.2.1 (not the binary) or the paths have to be fixed for it to work with openoffice-bin.

Sample messages
# On a different terminal, I run quickpkg openoffice and emerge --unmerge openoffice
09:26:42 jerome e/ unoconv -f pdf chapter2.docx 
unoconv: Cannot find the pyuno.so library in sys.path and known paths.
Please locate this library and send your feedback to <tools@lists.rpmforge.net>.

# On another terminal, emerge openoffice-bin
09:26:48 jerome e/ unoconv -f pdf chapter2.docx 
Traceback (most recent call last):
  File "/usr/bin/unoconv", line 24, in <module>
    import uno, unohelper
  File "/usr/lib/openoffice/basis-link/program/uno.py", line 33, in <module>
    import pyuno
SystemError: dynamic module not initialized properly

# On another terminal, emerge --usepkgonly openoffice
09:33:06 jerome e/ unoconv -f pdf chapter2.docx 
09:38:00 jerome e/ 
# It works!
Comment 10 Denilson Sá Maia 2010-08-25 02:17:00 UTC
(In reply to comment #7)
> SystemError: dynamic module not initialized properly

I got this here too. The reason is that the (pre-)compiled module installed within OOo is not compatible with our currently installed Python version. There is a very quick and simple solution, though: change the shebang to point to the OOo's own python.

Before:
#!/usr/bin/python
After:
#!/usr/lib64/openoffice/program/python

I had to do only two changes in order to get unoconv working here. The first one was the shebang, as I just described. The second one was basically the same as the proposed patch above. The difference is that I've removed redundant paths that don't exist here. Here is my line:

extrapaths = glob.glob('/usr/lib64/openoffice/basis*/program/')

With these two changes, unoconv appears to work correctly.
Comment 11 Grégoire Favre 2010-08-27 18:55:53 UTC
Nicely done, with this one lign change (python path) the svn works out of the box for me : thank you very much !!!

Index: unoconv
===================================================================
--- unoconv     (revision 9075)
+++ unoconv     (working copy)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/lib64/openoffice/program/python
 
 ### This program is free software; you can redistribute it and/or modify
 ### it under the terms of the GNU General Public License as published by
Comment 12 Denilson Sá Maia 2010-09-01 23:08:49 UTC
(In reply to comment #11)
> Nicely done, with this one lign change (python path) the svn works out of the
> box for me : thank you very much !!!

Actually... Things are a bit more complicated...

openoffice-bin users must use this hashbang:
/usr/lib/openoffice/program/python
(since /usr/lib is a symlink to /usr/lib64, I think it's better to use just "lib", as it will work for 32-bit users too)

But openoffice (compiled from source) doesn't install python there. I bet it uses system's own Python. That means the default hashbang will work, while the above one (for -bin users) will fail.

How to solve this? Good question.
Comment 13 Walter Da Col 2010-12-16 18:42:44 UTC
Hi, I've writed a new ebuild (0.3-r3) (it's on sunrise-overlay) using a wrapper to fix openoffice source/bin question.

see http://bugs.gentoo.org/345405
Comment 14 Rafael 2011-04-20 01:14:30 UTC
Can someone make an updated ebuild with libreoffice support?
Comment 15 Hans Meier 2011-04-27 19:43:43 UTC
There is a new Version 0.4

for

app-office/unoconv-0.4

http://dag.wieers.com/home-made/unoconv/

Please add this to Overlay Sunrise or to Portage, please.
Comment 16 Sven Eden 2011-05-17 19:44:16 UTC
Created attachment 273707 [details]
Ebuild for unoconv-0.4 plus python 2.7 fix

Hi everybody,

I have an ebuild for unoconv-0.4 in my overlay at http://git.overlays.gentoo.org/gitweb/?p=user/seden.git (available via layman)

Here it is, the said fix for python 2.7 (Throws KeyError if LD_LIBRARY_PATH is empty) follows.
Comment 17 Sven Eden 2011-05-17 19:45:21 UTC
Created attachment 273711 [details, diff]
Fix for KeyError Exception with python 2.7

Patch to add a wrapper that takes care of LD_LIBRARY_PATH if that is empty. On Python 2.7 a KeyError exception is thrown without the patch
Comment 18 Sven Eden 2011-05-17 20:01:37 UTC
Forgot to mention two points:
a) I have sent the patch to Dag Wiiers and
b) Tomorrow I'll write a live ebuild, because I need unoconv at work

Cheers
Comment 19 Sven Eden 2011-05-19 10:56:25 UTC
Created attachment 273933 [details]
New ebuild incorporating a new patch to work with libreoffice

The patch will follow next, the live ebuild will follow next week.

tested with liberoffice-3.3.2
Comment 20 Sven Eden 2011-05-19 10:57:15 UTC
Created attachment 273935 [details, diff]
Add support for libreoffice, needs unoconv-0.4-r3.ebuild

Said patch. I'll report it upstream as well.
Comment 21 Grégoire Favre 2011-05-21 21:56:23 UTC
Should that be working with libreoffice-bin-3.3.2 ?
I just emerged unoconv from seden's overlay but can't convert anything with unoconv. (I don't have python 2.6 on my computer if that matter)
Comment 22 Raphaël Droz 2011-08-01 12:35:14 UTC
Created attachment 281721 [details]
ebuild for unoconv git

An ebuild for the git version which contains 35a53d57cd (libreoffice support)
Comment 23 Raphaël Droz 2011-08-01 12:36:37 UTC
Created attachment 281723 [details]
updated timeout patch

I blindly updated the patch about the timeout but it probably needs
a deeper analyse/discussion.
Comment 24 Markos Chandras (RETIRED) gentoo-dev 2011-08-28 10:05:37 UTC
*** Bug 345405 has been marked as a duplicate of this bug. ***
Comment 25 Tomáš Chvátal (RETIRED) gentoo-dev 2011-08-28 15:44:44 UTC
We will take it, I will package it during next week.
Comment 26 Tomáš Chvátal (RETIRED) gentoo-dev 2011-09-23 13:25:19 UTC
Added to main tree. Thanks for the patch.
Comment 27 Rafael 2011-09-25 19:11:06 UTC
I installed app-office/unoconv-20110923 and it still doesn't work with app-office/libreoffice-bin-3.4.2-r2. It gives me this error message: 
unoconv: Cannot find the soffice binary in sys.path and known paths.
ERROR: Please locate this binary and send your feedback to: <tools@lists.rpmforge.net>.

In my machine, 'soffice.bin' is inside '/usr/lib64/libreoffice/program/'. Looking at the code in /usr/bin/unoconv I couldn't find any reference to this path. Instead, it has a reference to '/opt/libreoffice/program'.

I tried to add the path '/usr/lib64/libreoffice/program/' to extrapaths, like this:


extrapaths = glob.glob('/usr/lib*/libreoffice*/basis*/program') + \
             glob.glob('/opt/libreoffice/program') + \
             glob.glob('/usr/lib*/libreoffice/program') + \
             glob.glob('/usr/lib*/openoffice*/program') + \
             glob.glob('/usr/lib*/openoffice*/basis*/program') + \
             glob.glob('/usr/lib*/ooo*/program') + \
             glob.glob('/usr/lib*/ooo*/basis*/program') + \
             glob.glob('/usr/local/openoffice*/program') + \
             glob.glob('/usr/local/openoffice*/basis*/program') + \
             glob.glob('/usr/local/ooo*/program') + \
             glob.glob('/usr/local/ooo*/basis*/program') + \
             glob.glob('/opt/openoffice*/program') + \
             glob.glob('/opt/openoffice*/basis*/program') + \
             glob.glob('/Applications/OpenOffice.org.app/Contents/program') + \
             glob.glob('/Applications/OpenOffice.org.app/Contents/basis-link/program') + \
             glob.glob('/Applications/NeoOffice.app/Contents/program') + \
             glob.glob('/Applications/NeoOffice.app/Contents/basis-link/program') + \
             glob.glob('/usr/bin') + \
             glob.glob('/usr/local/bin') + \
             glob.glob('/opt/bin')


But then I get the following error:

raceback (most recent call last):
  File "/usr/bin/unoconv", line 814, in <module>
    main()
  File "/usr/bin/unoconv", line 790, in main
    convertor = Convertor()
  File "/usr/bin/unoconv", line 519, in __init__
    info(3, "Existing listener not found.\n%s" % e)
  File "/usr/lib/libreoffice/basis3.4/program/uno.py", line 323, in _uno_struct__repr__
    return repr(self.__dict__["value"])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-25: ordinal not in range(128)

Then I remenbered that libreoffice-bin has a bundled copy of python. Then I changed the shebang in '/usr/bin/unoconv' to:

#!/usr/lib64/libreoffice/program/python

And now unoconv works for me.
Comment 28 Markos Chandras (RETIRED) gentoo-dev 2011-10-07 20:10:39 UTC
(In reply to comment #27)
> I installed app-office/unoconv-20110923 and it still doesn't work with
> app-office/libreoffice-bin-3.4.2-r2. It gives me this error message: 
> unoconv: Cannot find the soffice binary in sys.path and known paths.
> ERROR: Please locate this binary and send your feedback to:
> <tools@lists.rpmforge.net>.
> 
> In my machine, 'soffice.bin' is inside '/usr/lib64/libreoffice/program/'.
> Looking at the code in /usr/bin/unoconv I couldn't find any reference to this
> path. Instead, it has a reference to '/opt/libreoffice/program'.
> 
> I tried to add the path '/usr/lib64/libreoffice/program/' to extrapaths, like
> this:
> 
> 
> extrapaths = glob.glob('/usr/lib*/libreoffice*/basis*/program') + \
>              glob.glob('/opt/libreoffice/program') + \
>              glob.glob('/usr/lib*/libreoffice/program') + \
>              glob.glob('/usr/lib*/openoffice*/program') + \
>              glob.glob('/usr/lib*/openoffice*/basis*/program') + \
>              glob.glob('/usr/lib*/ooo*/program') + \
>              glob.glob('/usr/lib*/ooo*/basis*/program') + \
>              glob.glob('/usr/local/openoffice*/program') + \
>              glob.glob('/usr/local/openoffice*/basis*/program') + \
>              glob.glob('/usr/local/ooo*/program') + \
>              glob.glob('/usr/local/ooo*/basis*/program') + \
>              glob.glob('/opt/openoffice*/program') + \
>              glob.glob('/opt/openoffice*/basis*/program') + \
>              glob.glob('/Applications/OpenOffice.org.app/Contents/program') + \
>             
> glob.glob('/Applications/OpenOffice.org.app/Contents/basis-link/program') + \
>              glob.glob('/Applications/NeoOffice.app/Contents/program') + \
>             
> glob.glob('/Applications/NeoOffice.app/Contents/basis-link/program') + \
>              glob.glob('/usr/bin') + \
>              glob.glob('/usr/local/bin') + \
>              glob.glob('/opt/bin')
> 
> 
> But then I get the following error:
> 
> raceback (most recent call last):
>   File "/usr/bin/unoconv", line 814, in <module>
>     main()
>   File "/usr/bin/unoconv", line 790, in main
>     convertor = Convertor()
>   File "/usr/bin/unoconv", line 519, in __init__
>     info(3, "Existing listener not found.\n%s" % e)
>   File "/usr/lib/libreoffice/basis3.4/program/uno.py", line 323, in
> _uno_struct__repr__
>     return repr(self.__dict__["value"])
> UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-25:
> ordinal not in range(128)
> 
> Then I remenbered that libreoffice-bin has a bundled copy of python. Then I
> changed the shebang in '/usr/bin/unoconv' to:
> 
> #!/usr/lib64/libreoffice/program/python
> 
> And now unoconv works for me.

YOu need to open a new bug for that plz