diff --git a/tests.py b/tests.py index 4ee0a5d..9af4826 100644 --- a/tests.py +++ b/tests.py @@ -2,6 +2,7 @@ from PIL import Image from thumbnailer import library as thumb + class ThumbnailerTestCase(unittest.TestCase): def assertDimensions(self, t): w, h = Image.open(t).size diff --git a/thumbnailer/library/__init__.py b/thumbnailer/library/__init__.py index bbb4683..e66e392 100644 --- a/thumbnailer/library/__init__.py +++ b/thumbnailer/library/__init__.py @@ -22,9 +22,6 @@ '-vframes', '1', '-ss', '1', ) -UC_ARGS = ( - 'unoconv', -) def create(f, **kwargs): if isinstance(f, basestring): @@ -88,8 +85,6 @@ def create(self, f): class OfficeBackend(PdfBackend): - # TODO: perhaps import unoconv and use some of it's internals. - # Particularly it would be nice to use a persistent server (OO.org/LibreOffice). def __init__(self, connection=None, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT): from . import unoclient super(OfficeBackend, self).__init__(width, height) @@ -101,7 +96,6 @@ def __init__(self, connection=None, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT): self.client = unoclient.Client(connection) def create(self, f): - args = list(UC_ARGS) if not isinstance(f, basestring): o, fname = tempfile.mkstemp() try: diff --git a/thumbnailer/library/unoclient.py b/thumbnailer/library/unoclient.py index 2f4e757..7625922 100644 --- a/thumbnailer/library/unoclient.py +++ b/thumbnailer/library/unoclient.py @@ -1,5 +1,5 @@ import os, uno -from unohelper import Base, systemPathToFileUrl, absolutize +from unohelper import Base, systemPathToFileUrl from com.sun.star.beans import PropertyValue from com.sun.star.connection import NoConnectException from com.sun.star.io import IOException, XOutputStream @@ -8,6 +8,9 @@ except ImportError: from StringIO import StringIO +# Taken from example: +# http://www.openoffice.org/udk/python/samples/ooextract.py + # To run in Foreground: # soffice --accept=socket,host=localhost,port=2002;urp; # To run headless: @@ -51,7 +54,6 @@ def __init__(self, connection): 'com.sun.star.frame.Desktop', context, ) - self.cwd = systemPathToFileUrl(os.getcwd()) def export_to_pdf(self, path): stream = OutputStream() @@ -66,8 +68,8 @@ def export_to_pdf(self, path): ) document = None try: - fileUrl = absolutize(self.cwd, systemPathToFileUrl(path)) - document = self.desktop.loadComponentFromURL(fileUrl, '_blank', 0, props_in) + pathUrl = systemPathToFileUrl(os.path.abspath(path)) + document = self.desktop.loadComponentFromURL(pathUrl, '_blank', 0, props_in) document.storeToURL('private:stream', props_out) finally: if document: