Commit ef8af75a authored by Gabriel Monnerat's avatar Gabriel Monnerat

Change folder structure of cloudooo to put handler, mimemapper, granulator,

helpers related to handler in same folder than handler. Like this cloudooo will
become pluggable, with independent backends.
I will allows eggification of backends
i.e
  cloudooo.handler.ooo
  cloudooo.handler.imagemagick
  cloudooo.handler.pdftk



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@41929 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cf2a7922
1.0.10 (unreleased) 1.0.10 (unreleased)
=================== ===================
- Change folder structure of cloudooo to put handler, mimemapper, helpers
related to handler in same folder than handler.
- Refactor code to use json instead of jsonpickle. - Refactor code to use json instead of jsonpickle.
- Add getTableItem, getTableItemList and getTableMatrix for OOGranulate - Add getTableItem, getTableItemList and getTableMatrix for OOGranulate
- Add getParagraphItemList and getParagraphItem for OOGranulate - Add getParagraphItemList and getParagraphItem for OOGranulate
......
...@@ -27,14 +27,14 @@ ...@@ -27,14 +27,14 @@
############################################################################## ##############################################################################
import gc import gc
import monitor import handler.ooo.monitor as monitor
from signal import signal, SIGHUP from signal import signal, SIGHUP
from application.openoffice import openoffice from handler.ooo.application.openoffice import openoffice
from application.xvfb import xvfb from handler.ooo.application.xvfb import xvfb
from wsgixmlrpcapplication import WSGIXMLRPCApplication from wsgixmlrpcapplication import WSGIXMLRPCApplication
from utils import convertStringToBool, configureLogger from handler.ooo.utils import convertStringToBool, configureLogger
from os import path, mkdir from os import path, mkdir
from mimemapper import mimemapper from handler.ooo.mimemapper import mimemapper
def stopProcesses(): def stopProcesses():
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implements
from cloudooo.interfaces.application import IApplication from cloudooo.handler.ooo.interfaces.application import IApplication
from cloudooo.utils import logger, socketStatus, waitStopDaemon from cloudooo.handler.ooo.utils import logger, socketStatus, waitStopDaemon
from psutil import pid_exists, Process from psutil import pid_exists, Process
......
...@@ -35,10 +35,10 @@ from threading import Lock ...@@ -35,10 +35,10 @@ from threading import Lock
from zope.interface import implements from zope.interface import implements
from application import Application from application import Application
from xvfb import xvfb from xvfb import xvfb
from cloudooo.interfaces.lockable import ILockable from cloudooo.handler.ooo.interfaces.lockable import ILockable
from cloudooo.utils import logger, waitStartDaemon, removeDirectory, \ from cloudooo.handler.ooo.utils import logger, waitStartDaemon, \
waitStopDaemon, convertStringToBool, \ removeDirectory, waitStopDaemon, \
socketStatus convertStringToBool, socketStatus
class OpenOffice(Application): class OpenOffice(Application):
...@@ -114,10 +114,10 @@ class OpenOffice(Application): ...@@ -114,10 +114,10 @@ class OpenOffice(Application):
connection_list[0].local_address[1] == self.port: connection_list[0].local_address[1] == self.port:
process.terminate() process.terminate()
except psutil.error.AccessDenied, e: except psutil.error.AccessDenied, e:
logger.debug(e) logger.error(e)
except TypeError, e: except TypeError, e:
# exception to prevent one psutil issue with svn processes # exception to prevent one psutil issue with svn processes
logger.debug(e) logger.error(e)
except NotImplementedError, e: except NotImplementedError, e:
logger.error("lsof isn't installed on this machine: " + str(e)) logger.error("lsof isn't installed on this machine: " + str(e))
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
############################################################################## ##############################################################################
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from cloudooo.utils import logger, waitStartDaemon, remove_file from cloudooo.handler.ooo.utils import logger, waitStartDaemon, remove_file
from zope.interface import implements from zope.interface import implements
from application import Application from application import Application
from cloudooo.interfaces.application import IApplication from cloudooo.handler.ooo.interfaces.application import IApplication
from os.path import exists from os.path import exists
......
...@@ -31,9 +31,9 @@ from zipfile import ZipFile ...@@ -31,9 +31,9 @@ from zipfile import ZipFile
from StringIO import StringIO from StringIO import StringIO
from lxml import etree from lxml import etree
from os import path from os import path
from cloudooo.utils import logger from cloudooo.handler.ooo.utils import logger
from cloudooo.document import OdfDocument from cloudooo.handler.ooo.document import OdfDocument
from cloudooo.interfaces.granulate import ITableGranulator, \ from cloudooo.handler.ooo.interfaces.granulate import ITableGranulator, \
IImageGranulator, \ IImageGranulator, \
ITextGranulator ITextGranulator
......
##############################################################################
#
# Copyright (c) 2009-2010 Nexedi SA and Contributors. All Rights Reserved.
# Gabriel M. Monnerat <gabriel@tiolive.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import json
import re
import pkg_resources
from base64 import decodestring, encodestring
from os import environ, path
from subprocess import Popen, PIPE
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.handler.ooo.application.xvfb import xvfb
from zope.interface import implements
from cloudooo.handler.ooo.interfaces.handler import IHandler
from cloudooo.handler.ooo.mimemapper import mimemapper
from cloudooo.handler.ooo.document import FileSystemDocument
from cloudooo.handler.ooo.monitor.timeout import MonitorTimeout
from cloudooo.handler.ooo.utils import logger
from psutil import pid_exists
class OOHandler:
"""OOHandler is used to access the one Document and OpenOffice.
For each Document inputed is created on instance of this class to manipulate
the document. This Document must be able to create and remove a temporary
document at FS, load and export.
"""
implements(IHandler)
def __init__(self, base_folder_url, data, source_format, **kw):
"""Creates document in file system and loads it in OOo."""
self.document = FileSystemDocument(base_folder_url,
data,
source_format)
self.zip = kw.get('zip', False)
self.uno_path = kw.get("uno_path", None)
self.office_binary_path = kw.get("office_binary_path", None)
self.timeout = kw.get("timeout", 600)
self.refresh = kw.get('refresh', False)
self.source_format = source_format
if not self.uno_path:
self.uno_path = environ.get("uno_path")
if not self.office_binary_path:
self.office_binary_path = environ.get("office_binary_path")
def _getCommand(self, *args, **kw):
"""Transforms all parameters passed in a command"""
hostname, port = openoffice.getAddress()
kw['hostname'] = hostname
kw['port'] = port
python = path.join(self.office_binary_path, "python")
command_list = [path.exists(python) and python or "python",
pkg_resources.resource_filename(__name__,
path.join("helper", "unoconverter.py")),
"--uno_path='%s'" % self.uno_path,
"--office_binary_path='%s'" % self.office_binary_path,
"--document_url='%s'" % self.document.getUrl()]
for arg in args:
command_list.insert(3, "--%s" % arg)
for k, v in kw.iteritems():
command_list.append("--%s='%s'" % (k, v))
return ' '.join(command_list)
def _startTimeout(self):
"""start the Monitor"""
self.monitor = MonitorTimeout(openoffice, self.timeout)
self.monitor.start()
return
def _stopTimeout(self):
"""stop the Monitor"""
self.monitor.terminate()
return
def _subprocess(self, command):
"""Run one procedure"""
try:
self._startTimeout()
process = Popen(command,
shell=True,
stdout=PIPE,
stderr=PIPE,
close_fds=True)
stdout, stderr = process.communicate()
finally:
self._stopTimeout()
if pid_exists(process.pid):
process.terminate()
return stdout, stderr
def _callUnoConverter(self, *feature_list, **kw):
""" """
if not openoffice.status():
xvfb.restart()
openoffice.start()
command = self._getCommand(*feature_list, **kw)
stdout, stderr = self._subprocess(command)
if not stdout and len(re.findall("\w*Exception|\w*Error", stderr)) >= 1:
logger.debug(stderr)
self.document.restoreOriginal()
openoffice.restart()
kw['document_url'] = self.document.getUrl()
command = self._getCommand(*feature_list, **kw)
stdout, stderr = self._subprocess(command)
if stderr != "":
raise Exception, stderr
return stdout, stderr
def _serializeMimemapper(self, extension=None):
"""Serialize parts of mimemapper"""
if extension is None:
return json.dumps(dict(mimetype_by_filter_type=mimemapper._mimetype_by_filter_type))
filter_list = []
for service_type in mimemapper._doc_type_list_by_extension[extension]:
for extension in mimemapper.extension_list_by_doc_type[service_type]:
filter_list.append((extension,
service_type,
mimemapper.getFilterName(extension,
service_type)))
return json.dumps(dict(doc_type_list_by_extension=mimemapper._doc_type_list_by_extension,
filter_list=filter_list,
mimetype_by_filter_type=mimemapper._mimetype_by_filter_type))
def convert(self, destination_format=None, **kw):
"""Convert a document to another format supported by the OpenOffice
Keyword Arguments:
destination_format -- extension of document as String
"""
logger.debug("Convert: %s > %s" % (self.source_format, destination_format))
openoffice.acquire()
kw['source_format'] = self.source_format
if destination_format:
kw['destination_format'] = destination_format
kw['mimemapper'] = self._serializeMimemapper(destination_format)
kw['refresh'] = json.dumps(self.refresh)
try:
stdout, stderr = self._callUnoConverter(*['convert'], **kw)
finally:
openoffice.release()
if self.monitor.is_alive():
self._stopTimeout()
url = stdout.replace('\n', '')
self.document.reload(url)
content = self.document.getContent(self.zip)
self.document.trash()
return content
def getMetadata(self, base_document=False):
"""Returns a dictionary with all metadata of document.
Keywords Arguments:
base_document -- Boolean variable. if true, the document is also returned
along with the metadata."""
openoffice.acquire()
logger.debug("getMetadata")
kw = dict(mimemapper=self._serializeMimemapper())
if base_document:
feature_list = ['getmetadata', 'convert']
else:
feature_list = ['getmetadata']
try:
stdout, stderr = self._callUnoConverter(*feature_list, **kw)
finally:
openoffice.release()
if self.monitor.is_alive():
self._stopTimeout()
metadata = json.loads(decodestring(stdout))
if metadata.get("Data"):
self.document.reload(metadata['Data'])
metadata['Data'] = self.document.getContent()
else:
metadata['Data'] = ''
self.document.trash()
return metadata
def setMetadata(self, metadata):
"""Returns a document with new metadata.
Keyword arguments:
metadata -- expected an dictionary with metadata.
"""
openoffice.acquire()
metadata_pickled = json.dumps(metadata)
logger.debug("setMetadata")
kw = dict(metadata=encodestring(metadata_pickled))
try:
stdout, stderr = self._callUnoConverter(*['setmetadata'], **kw)
finally:
openoffice.release()
if self.monitor.is_alive():
self._stopTimeout()
doc_loaded = self.document.getContent()
self.document.trash()
return doc_loaded
from request import MonitorRequest from request import MonitorRequest
from memory import MonitorMemory from memory import MonitorMemory
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
monitor_request = None monitor_request = None
monitor_memory = None monitor_memory = None
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
# #
############################################################################## ##############################################################################
from cloudooo.monitor.monitor import Monitor from monitor import Monitor
from multiprocessing import Process from multiprocessing import Process
import psutil import psutil
from cloudooo.utils import logger from cloudooo.handler.ooo.utils import logger
from time import sleep from time import sleep
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
from zope.interface import implements from zope.interface import implements
from cloudooo.interfaces.monitor import IMonitor from cloudooo.handler.ooo.interfaces.monitor import IMonitor
class Monitor(object): class Monitor(object):
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
# #
############################################################################## ##############################################################################
from cloudooo.monitor.monitor import Monitor from monitor import Monitor
from threading import Thread from threading import Thread
from cloudooo.utils import logger from cloudooo.handler.ooo.utils import logger
from time import sleep from time import sleep
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
# #
############################################################################## ##############################################################################
from cloudooo.monitor.monitor import Monitor from monitor import Monitor
from multiprocessing import Process from multiprocessing import Process
from time import sleep from time import sleep
from cloudooo.utils import logger from cloudooo.handler.ooo.utils import logger
class MonitorTimeout(Monitor, Process): class MonitorTimeout(Monitor, Process):
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
from mimetypes import guess_all_extensions, guess_extension from mimetypes import guess_all_extensions, guess_extension
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
from zope.interface import implements from zope.interface import implements
from interfaces.manager import IManager, IERP5Compatibility from handler.ooo.interfaces.manager import IManager, IERP5Compatibility
from handler.oohandler import OOHandler from handler.ooo.handler import OOHandler
from mimemapper import mimemapper from handler.ooo.mimemapper import mimemapper
from utils import logger from handler.ooo.utils import logger
class Manager(object): class Manager(object):
......
...@@ -31,10 +31,10 @@ import sys ...@@ -31,10 +31,10 @@ import sys
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
from os import path, mkdir from os import path, mkdir
from os import environ, putenv from os import environ, putenv
from cloudooo.application.xvfb import xvfb from cloudooo.handler.ooo.application.xvfb import xvfb
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.utils import waitStartDaemon from cloudooo.handler.ooo.utils import waitStartDaemon
from cloudooo.mimemapper import mimemapper from cloudooo.handler.ooo.mimemapper import mimemapper
config = ConfigParser() config = ConfigParser()
testcase_path = path.dirname(__file__) testcase_path = path.dirname(__file__)
......
...@@ -4,7 +4,7 @@ import sys ...@@ -4,7 +4,7 @@ import sys
import unittest import unittest
from getopt import getopt, GetoptError from getopt import getopt, GetoptError
from time import sleep from time import sleep
from cloudooo.utils import socketStatus from cloudooo.handler.ooo.utils import socketStatus
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
from os import chdir, path, environ, curdir from os import chdir, path, environ, curdir
from subprocess import Popen from subprocess import Popen
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from cloudooo.application.application import Application from cloudooo.handler.ooo.application.application import Application
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -32,7 +32,7 @@ from base64 import decodestring ...@@ -32,7 +32,7 @@ from base64 import decodestring
from os import path from os import path
from os import remove from os import remove
from zipfile import ZipFile, is_zipfile from zipfile import ZipFile, is_zipfile
from cloudooo.document import FileSystemDocument from cloudooo.handler.ooo.document import FileSystemDocument
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from cloudooo.filter import Filter from cloudooo.handler.ooo.filter import Filter
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -27,24 +27,24 @@ ...@@ -27,24 +27,24 @@
############################################################################## ##############################################################################
import unittest import unittest
from cloudooo.document import FileSystemDocument, OdfDocument from cloudooo.handler.ooo.document import FileSystemDocument, OdfDocument
from cloudooo.handler.oohandler import OOHandler from cloudooo.handler.ooo.handler import OOHandler
from cloudooo.application.openoffice import OpenOffice from cloudooo.handler.ooo.application.openoffice import OpenOffice
from cloudooo.manager import Manager from cloudooo.manager import Manager
from cloudooo.mimemapper import MimeMapper from cloudooo.handler.ooo.mimemapper import MimeMapper
from cloudooo.filter import Filter from cloudooo.handler.ooo.filter import Filter
from cloudooo.application.xvfb import Xvfb from cloudooo.handler.ooo.application.xvfb import Xvfb
from cloudooo.monitor.request import MonitorRequest from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudooo.handler.ooo.granulator import OOGranulator from cloudooo.handler.ooo.granulator import OOGranulator
from cloudooo.interfaces.document import IDocument, IOdfDocument from cloudooo.handler.ooo.interfaces.document import IDocument, IOdfDocument
from cloudooo.interfaces.lockable import ILockable from cloudooo.handler.ooo.interfaces.lockable import ILockable
from cloudooo.interfaces.manager import IManager from cloudooo.handler.ooo.interfaces.manager import IManager
from cloudooo.interfaces.application import IApplication from cloudooo.handler.ooo.interfaces.application import IApplication
from cloudooo.interfaces.filter import IFilter from cloudooo.handler.ooo.interfaces.filter import IFilter
from cloudooo.interfaces.mimemapper import IMimemapper from cloudooo.handler.ooo.interfaces.mimemapper import IMimemapper
from cloudooo.interfaces.handler import IHandler from cloudooo.handler.ooo.interfaces.handler import IHandler
from cloudooo.interfaces.monitor import IMonitor from cloudooo.handler.ooo.interfaces.monitor import IMonitor
from cloudooo.interfaces.granulate import ITableGranulator, \ from cloudooo.handler.ooo.interfaces.granulate import ITableGranulator, \
IImageGranulator, \ IImageGranulator, \
ITextGranulator ITextGranulator
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
import unittest import unittest
from cloudoooTestCase import cloudoooTestCase from cloudoooTestCase import cloudoooTestCase
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.mimemapper import MimeMapper from cloudooo.handler.ooo.mimemapper import MimeMapper
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
text_expected_tuple = (('doc', 'Microsoft Word 6.0'), text_expected_tuple = (('doc', 'Microsoft Word 6.0'),
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
############################################################################## ##############################################################################
import unittest import unittest
import cloudooo.monitor import cloudooo.handler.ooo.monitor as monitor
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.monitor.request import MonitorRequest from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudooo.monitor.memory import MonitorMemory from cloudooo.handler.ooo.monitor.memory import MonitorMemory
class TestMonitorInit(cloudoooTestCase): class TestMonitorInit(cloudoooTestCase):
...@@ -45,28 +45,28 @@ class TestMonitorInit(cloudoooTestCase): ...@@ -45,28 +45,28 @@ class TestMonitorInit(cloudoooTestCase):
def tearDown(self): def tearDown(self):
"""stop all monitors""" """stop all monitors"""
cloudooo.monitor.stop() monitor.stop()
def testMonitorInitGlobalAttributes(self): def testMonitorInitGlobalAttributes(self):
"""Test the global attributes""" """Test the global attributes"""
self.assertEquals(cloudooo.monitor.monitor_request, None) self.assertEquals(monitor.monitor_request, None)
self.assertEquals(cloudooo.monitor.monitor_memory, None) self.assertEquals(monitor.monitor_memory, None)
def testMonitorLoadOnlyMonitorRequest(self): def testMonitorLoadOnlyMonitorRequest(self):
"""Check if the monitors are started""" """Check if the monitors are started"""
cloudooo.monitor.load(self.load_config) monitor.load(self.load_config)
self.assertEquals(isinstance(cloudooo.monitor.monitor_request, self.assertEquals(isinstance(monitor.monitor_request,
MonitorRequest), MonitorRequest),
True) True)
def testMonitorLoadMonitorMemory(self): def testMonitorLoadMonitorMemory(self):
"""Check if the MemoryMemory is started""" """Check if the MemoryMemory is started"""
self.load_config['enable_memory_monitor'] = True self.load_config['enable_memory_monitor'] = True
cloudooo.monitor.load(self.load_config) monitor.load(self.load_config)
self.assertEquals(isinstance(cloudooo.monitor.monitor_request, self.assertEquals(isinstance(monitor.monitor_request,
MonitorRequest), MonitorRequest),
True) True)
self.assertEquals(isinstance(cloudooo.monitor.monitor_memory, self.assertEquals(isinstance(monitor.monitor_memory,
MonitorMemory), MonitorMemory),
True) True)
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
import unittest import unittest
from time import sleep from time import sleep
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.monitor.memory import MonitorMemory from cloudooo.handler.ooo.monitor.memory import MonitorMemory
from psutil import Process from psutil import Process
from types import IntType from types import IntType
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
import unittest import unittest
from time import sleep from time import sleep
from cloudooo.monitor.request import MonitorRequest from cloudooo.handler.ooo.monitor.request import MonitorRequest
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
class TestMonitorRequest(cloudoooTestCase): class TestMonitorRequest(cloudoooTestCase):
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
import unittest import unittest
from time import sleep from time import sleep
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.monitor.timeout import MonitorTimeout from cloudooo.handler.ooo.monitor.timeout import MonitorTimeout
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -32,7 +32,7 @@ from zipfile import ZipFile ...@@ -32,7 +32,7 @@ from zipfile import ZipFile
from StringIO import StringIO from StringIO import StringIO
from lxml import etree from lxml import etree
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.handler.ooo.granulator import OOGranulator from cloudooo.handler.ooo.handler.ooo.granulator import OOGranulator
class TestOOGranulator(cloudoooTestCase): class TestOOGranulator(cloudoooTestCase):
......
...@@ -31,8 +31,8 @@ from os import path ...@@ -31,8 +31,8 @@ from os import path
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from base64 import encodestring, decodestring from base64 import encodestring, decodestring
from cloudoooTestCase import cloudoooTestCase from cloudoooTestCase import cloudoooTestCase
from cloudooo.handler.oohandler import OOHandler from cloudooo.handler.ooo.handler import OOHandler
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
import os import os
from lxml import etree from lxml import etree
......
...@@ -30,7 +30,7 @@ import unittest ...@@ -30,7 +30,7 @@ import unittest
from zipfile import ZipFile from zipfile import ZipFile
from lxml import etree from lxml import etree
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.document import OdfDocument from cloudooo.handler.ooo.document import OdfDocument
class TestOdfDocument(cloudoooTestCase): class TestOdfDocument(cloudoooTestCase):
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
import unittest import unittest
from cloudoooTestCase import cloudoooTestCase from cloudoooTestCase import cloudoooTestCase
from cloudooo.application.openoffice import OpenOffice from cloudooo.handler.ooo.application.openoffice import OpenOffice
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
from cloudooo.utils import waitStopDaemon from cloudooo.handler.ooo.utils import waitStopDaemon
from psutil import Process, AccessDenied from psutil import Process, AccessDenied
......
...@@ -282,8 +282,9 @@ class TestServer(cloudoooTestCase): ...@@ -282,8 +282,9 @@ class TestServer(cloudoooTestCase):
def testConvertPNGToSVG(self): def testConvertPNGToSVG(self):
"""Test export png to svg""" """Test export png to svg"""
output_url = join(self.tmp_url, "output.svg")
self._testConvertFile("data/test.png", self._testConvertFile("data/test.png",
join("output.svg"), output_url,
'png', 'png',
'svg', 'svg',
'SVG Scalable Vector Graphics image\n') 'SVG Scalable Vector Graphics image\n')
......
...@@ -32,8 +32,8 @@ import pkg_resources ...@@ -32,8 +32,8 @@ import pkg_resources
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from os.path import exists, join from os.path import exists, join
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.document import FileSystemDocument from cloudooo.handler.ooo.document import FileSystemDocument
class TestUnoConverter(cloudoooTestCase): class TestUnoConverter(cloudoooTestCase):
...@@ -63,7 +63,7 @@ class TestUnoConverter(cloudoooTestCase): ...@@ -63,7 +63,7 @@ class TestUnoConverter(cloudoooTestCase):
python = join(self.office_binary_path, "python") python = join(self.office_binary_path, "python")
command = [exists(python) and python or "python", command = [exists(python) and python or "python",
pkg_resources.resource_filename("cloudooo", pkg_resources.resource_filename("cloudooo",
"helper/unoconverter.py"), "handler/ooo/helper/unoconverter.py"),
"'--convert'", "'--convert'",
"--uno_path='%s'" % self.uno_path, "--uno_path='%s'" % self.uno_path,
"--office_binary_path='%s'" % self.office_binary_path, "--office_binary_path='%s'" % self.office_binary_path,
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
import unittest import unittest
import json import json
import pkg_resources import pkg_resources
from cloudooo.application.openoffice import openoffice from cloudooo.handler.ooo.application.openoffice import openoffice
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from os import environ, path from os import environ, path
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
...@@ -55,7 +55,8 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -55,7 +55,8 @@ class TestUnoMimeMapper(cloudoooTestCase):
hostname, host = openoffice.getAddress() hostname, host = openoffice.getAddress()
python = path.join(self.office_binary_path, "python") python = path.join(self.office_binary_path, "python")
command = [path.exists(python) and python or "python", command = [path.exists(python) and python or "python",
pkg_resources.resource_filename("cloudooo", "helper/unomimemapper.py"), pkg_resources.resource_filename("cloudooo",
"handler/ooo/helper/unomimemapper.py"),
"'--uno_path=%s'" % self.uno_path, "'--uno_path=%s'" % self.uno_path,
"'--office_binary_path=%s'" % self.office_binary_path, "'--office_binary_path=%s'" % self.office_binary_path,
"'--hostname=%s'" % self.hostname, "'--hostname=%s'" % self.hostname,
...@@ -77,7 +78,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -77,7 +78,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
hostname, host = openoffice.getAddress() hostname, host = openoffice.getAddress()
command = [path.join(self.office_binary_path, "python"), command = [path.join(self.office_binary_path, "python"),
pkg_resources.resource_filename("cloudooo", pkg_resources.resource_filename("cloudooo",
"helper/unomimemapper.py"), "handler/ooo/helper/unomimemapper.py"),
"'--hostname=%s'" % self.hostname, "'--hostname=%s'" % self.hostname,
"'--port=%s'" % self.openoffice_port] "'--port=%s'" % self.openoffice_port]
stdout, stderr = Popen(' '.join(command), shell=True, stdout, stderr = Popen(' '.join(command), shell=True,
...@@ -100,7 +101,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -100,7 +101,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
python = path.join(self.office_binary_path, "python") python = path.join(self.office_binary_path, "python")
command = [path.exists(python) and python or "python", command = [path.exists(python) and python or "python",
pkg_resources.resource_filename("cloudooo", pkg_resources.resource_filename("cloudooo",
"helper/unomimemapper.py"), "handler/ooo/helper/unomimemapper.py"),
"'--uno_path=%s'" % self.uno_path, "'--uno_path=%s'" % self.uno_path,
"'--office_binary_path=%s'" % self.office_binary_path, "'--office_binary_path=%s'" % self.office_binary_path,
"'--hostname=%s'" % self.hostname, "'--hostname=%s'" % self.hostname,
...@@ -108,7 +109,7 @@ class TestUnoMimeMapper(cloudoooTestCase): ...@@ -108,7 +109,7 @@ class TestUnoMimeMapper(cloudoooTestCase):
stdout, stderr = Popen(' '.join(command), shell=True, stdout, stderr = Popen(' '.join(command), shell=True,
stdout=PIPE, stderr=PIPE).communicate() stdout=PIPE, stderr=PIPE).communicate()
self.assertEquals(stdout, '') self.assertEquals(stdout, '')
self.assertEquals(stderr.endswith(error_msg), True) self.assertEquals(stderr.endswith(error_msg), True, stderr)
openoffice.start() openoffice.start()
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
import unittest import unittest
import logging import logging
from cloudooo.utils import logger, configureLogger, convertStringToBool from cloudooo.handler.ooo.utils import logger, configureLogger, \
convertStringToBool
from cloudoooTestCase import make_suite from cloudoooTestCase import make_suite
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
import unittest import unittest
from cloudoooTestCase import cloudoooTestCase, make_suite from cloudoooTestCase import cloudoooTestCase, make_suite
from cloudooo.application.xvfb import Xvfb from cloudooo.handler.ooo.application.xvfb import Xvfb
from cloudooo.utils import waitStopDaemon from cloudooo.hanlder.ooo.utils import waitStopDaemon
class TestXvfb(cloudoooTestCase): class TestXvfb(cloudoooTestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment