ulif.openoffice.convert – A Document Converter

A convert office docs.

ulif.openoffice.convert.convert(*args, **kw)

Convert some document using unoconv.

Converts the document given in path to out_format and return a tuple containing status (0 if everything worked okay) as well as a directory path holding the result document.

The returned directory path is created freshly (unless outdir is given and exists). It is the caller’s responsibility to remove this directory after use.

url - connection string passed as -c parameter.

out_format - destination format as string. Must be one of the
formats provided by unoconv –show.

path - an absolute path to the document to be converted.

out_dir - an (existing) directory to place the results in. If no
such dir is given, we create a new one.
filter_props - a list of tuples containing filter setting for

the requested conversion filter. Each tuple must contain a setting key and value, such as (‘PageRange’, ‘1-2’). Each filter setting must be applicable for the requested conversion filter. While, for instance, the PDF export filter provides a myriad of such settings, other formats probvide only few. See the local unoconv documentation for available filters.

filter_props are passed to unoconv via the -e parameter.

template - path to a template to use.

timeout - seconds to wait until connections to Open/LibreOffice
are considered failed.
doctype - type of document to convert to. One of document,
graphics, presentation, spreadsheet.
executable - path to the unoconv executable to use. If none is
given the executable is looked up in the current system path.
ulif.openoffice.convert.exec_cmd(cmd)

Execute cmd in a subprocess.

Executes cmd in a subprocess (w/o shell). Returns (status, output). output contains both, stdout and stderr, as they would appear on the shell.

ulif.openoffice.convert.threadsafe(func)

A decorator for functions to run threadsafe.

Acquires a mutex before running the decorated function and releases the mutex after the result was retrieved.