Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to convert when specifying a non-existing output directory (ErrCode 283) #133

Closed
gazofnaz opened this issue May 9, 2013 · 4 comments
Labels
Milestone

Comments

@gazofnaz
Copy link
Contributor

gazofnaz commented May 9, 2013

Hi Guys,

I noticed from 0.5 onwards there was a change in the way --output & --outputpath are used. It's entirely possible that the problem below is just me misunderstanding the available options :)

In the application I support, we specify a custom output directory for the exported document. This directory does not exist at the point of execution. It is created on the fly.

This process works with v0.4, but fails in 0.5 & 0.6.

In 0.5 the conversion starts, but LibreOffice dies when writing the export to disk, and leaves behind the ominous .lock file.

I've noticed I can fix the problem by altering unoconv:

In version 0.5, line 824, change

outputfn = op.output

to

outputfn = os.path.join(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension)

This seems to mimic the behavior of 0.4... but my python is not so great!

For reference here is the command I'm running:

unoconv -f 'docx' -v -d 'web' -o '/home/me/somefilename/' --timeout '60' '/home/me/somefilename.html'

And the software:

unoconv 0.5
Written by Dag Wieers <dag@wieers.com>
Homepage at http://dag.wieers.com/home-made/unoconv/

platform posix/linux2
python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5]
LibreOffice 3.5

And the output:

Verbosity set to level 3
Connection type: socket,host=localhost,port=2002;urp;StarOffice.ComponentContext
Office base location: /usr/lib/libreoffice
Office binary location: /usr/lib/libreoffice/program
Existing listener not found.
Launching our own listener using /usr/lib/libreoffice/program/soffice.bin.
LibreOffice listener successfully started. (pid=26063)
Input file: /home/me/somefilename/somefilename.html
Selected output format: Microsoft Office Open XML [.docx]
Selected office filter: MS Word 2007 XML
Used doctype: web
Output file: /home/me/somefilename/somefilename/
unoconv: UnoException during export phase: Unable to store document to file:///home/me/somefilename/     with properties ((com.sun.star.beans.PropertyValue){ Name = (string)"FilterName", Handle = (long)0x0, Value = (any){ (string)"MS Word 2007     XML" }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){ Name = (string)"OutputStream", Handle = (    long)0x0, Value = (any){ (com.sun.star.uno.XInterface)0x34c8b88{, supportedInterfaces={com.sun.star.lang.XTypeProvider,com.sun.star.io.    XOutputStream}} }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){ Name = (string)"FilterData",     Handle = (long)0x0, Value = (any){ ([]any){} }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){     Name = (string)"Overwrite", Handle = (long)0x0, Value = (any){ (boolean)true }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }).     Exception:
Terminating LibreOffice instance.
LibreOffice instance unsuccessfully closed, sending TERM signal.
Waiting for LibreOffice instance to exit.

**edit, included the wrong output message

gazofnaz added a commit to gazofnaz/unoconv that referenced this issue May 11, 2013
dagwieers added a commit that referenced this issue Nov 26, 2013
#133 fix export to non existent directory
@mrsln
Copy link

mrsln commented Nov 29, 2013

Everything worked in 0.6 and libreoffice 4.1. I DID know where the output file would be, but now I have to do some weird magic to figure out the path.

@vpa
Copy link
Contributor

vpa commented Mar 4, 2014

Agreed, unfortunately this patch breaks the "unoconv 0.6" behaviour to specify with

-o /path/to/output.ext

the exact absolute path to the output file. It tries now to create

/path/to/output.ext/output.ext

and fails:

Output file: /path/to/output.ext/output.ext
unoconv: UnoException during export phase:
Unable to store document to file:///path/to/output.ext/output.ext (ErrCode 283)

@ImaiTeki
Copy link

I tried fixing the bug vpa said.

# git diff unoconv
diff --git a/unoconv b/unoconv
index 6ddabd9..df04c1b 100755
--- a/unoconv
+++ b/unoconv
@@ -918,8 +918,12 @@ class Convertor:
                 (outputfn, ext) = os.path.splitext(inputfn)
                 if not op.output:
                     outputfn = outputfn + os.extsep + outputfmt.extension
-                elif len(op.filenames) > 1:
-                    outputfn = op.output + os.extsep + outputfmt.extension
+                elif len(op.filenames) == 1:
+                    (_fn,_ext) = os.path.splitext(op.output)
+                    if _ext == os.extsep+outputfmt.extension:
+                        outputfn = op.output
+                    else:
+                        outputfn = op.output + os.extsep + outputfmt.extension
                 else:
                     outputfn = realpath(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension)

@@ -1145,7 +1149,7 @@ if __name__ == '__main__':
             self.closed = 1

         def writeBytes( self, seq ):
-            sys.stdout.buffer.write( seq.value )
+            sys.stdout.write( seq.value )

         def flush( self ):
             pass

My environment is:

CentOS6.5
LibreOffice (virsion 4.0) is installed by yum.
libreoffice-pyuno is install by rpmforge.
python version is 2.6.6 (CentOS6.5 default)

And I chacked:

$ unoconv -f pdf  test.doc                  # create test.pdf
$ unoconv -f pdf -o hoge.pdf test.doc   # create hoge.pdf
$ unoconv -f pdf -o dir test1.doc test2.doc test3.doc # create dir/test1.pdf dir/test2.pdf dir/test3.pdf
$ unoconv -f pdf --stdout test.doc > piyo.pdf  # create piyo.pdf

urg pushed a commit to PeerJ/unoconv that referenced this issue Jul 8, 2014
rdtft pushed a commit to rdtft/unoconv that referenced this issue Sep 29, 2014
@dagwieers
Copy link
Member

This should be fixed now. Feel free to reopen this issue if you still experience unexpected behavior.
Sorry for the inconvenience :-/

@dagwieers dagwieers added this to the Release 0.7 milestone Jul 5, 2015
@dagwieers dagwieers changed the title Failure to convert when specifying a non-existing output directory Failure to convert when specifying a non-existing output directory (ErrCode 283) Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants