[Erp5-report] r43627 gabriel - in /erp5/trunk/utils/cloudooo/cloudooo: ./ handler/ooo/tests...
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Feb 23 18:10:50 CET 2011
Author: gabriel
Date: Wed Feb 23 18:10:50 2011
New Revision: 43627
URL: http://svn.erp5.org?rev=43627&view=rev
Log:
Initial commit to mimetypes registry. This file is used to select the handler before each conversion.
- add test to check if the file with mimetypes is loaded correctly.
- refactor code to load mime.types before the server starts
Added:
erp5/trunk/utils/cloudooo/cloudooo/mime.types
Modified:
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py
erp5/trunk/utils/cloudooo/cloudooo/manager.py
erp5/trunk/utils/cloudooo/cloudooo/paster_application.py
erp5/trunk/utils/cloudooo/cloudooo/samples/sample.conf
erp5/trunk/utils/cloudooo/cloudooo/utils/utils.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py?rev=43627&r1=43626&r2=43627&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/testUtils.py [utf8] Wed Feb 23 18:10:50 2011
@@ -29,9 +29,9 @@
import unittest
import logging
from cloudooo.utils.utils import logger, configureLogger, \
- convertStringToBool
+ convertStringToBool, loadMimetypeList
from cloudooo.handler.tests.handlerTestCase import make_suite
-
+import mimetypes
class TestUtils(unittest.TestCase):
"""Test Utils"""
@@ -53,6 +53,14 @@ class TestUtils(unittest.TestCase):
self.assertEquals(convertStringToBool('faLse'), False)
self.assertEquals(convertStringToBool(''), None)
+ def testLoadMimetypelist(self):
+ """Test if the file with mimetypes is loaded correctly"""
+ self.assertEquals(mimetypes.types_map.get(".ogv"), None)
+ self.assertEquals(mimetypes.types_map.get(".3gp"), None)
+ loadMimetypeList()
+ self.assertEquals(mimetypes.types_map.get(".ogv"), "application/ogv")
+ self.assertEquals(mimetypes.types_map.get(".3gp"), "video/3gpp")
+
def test_suite():
return make_suite(TestUtils)
Modified: erp5/trunk/utils/cloudooo/cloudooo/manager.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/manager.py?rev=43627&r1=43626&r2=43627&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/manager.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/manager.py [utf8] Wed Feb 23 18:10:50 2011
@@ -31,16 +31,18 @@ from mimetypes import guess_all_extensio
from base64 import encodestring, decodestring
from zope.interface import implements
from interfaces.manager import IManager, IERP5Compatibility
-from handler.ooo.handler import OOHandler
-from handler.pdf.handler import PDFHandler
-from handler.ffmpeg.handler import FFMPEGHandler
+from cloudooo.handler.ooo.handler import OOHandler
+from cloudooo.handler.pdf.handler import PDFHandler
+from cloudooo.handler.ffmpeg.handler import FFMPEGHandler
from handler.ooo.mimemapper import mimemapper
from utils.utils import logger
from fnmatch import fnmatch
import mimetypes
+import pkg_resources
-handler_dict = {"pdf": PDFHandler, "ooo": OOHandler, "ffmpeg": FFMPEGHandler}
+HANDLER_DICT = {"pdf": PDFHandler, "ooo": OOHandler, "ffmpeg": FFMPEGHandler}
+
def getHandlerObject(source_format, destination_format, mimetype_registry):
"""Select handler according to source_format and destination_format"""
@@ -50,8 +52,9 @@ def getHandlerObject(source_format, dest
registry_list = pattern.split()
if fnmatch(source_mimetype, registry_list[0]) and \
fnmatch(destination_mimetype, registry_list[1]):
- return handler_dict[registry_list[2]]
- return handler_dict["ooo"]
+ return HANDLER_DICT[registry_list[2]]
+ return HANDLER_DICT["ooo"]
+
class Manager(object):
"""Manipulates requisitons of client and temporary files in file system."""
Added: erp5/trunk/utils/cloudooo/cloudooo/mime.types
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/mime.types?rev=43627&view=auto
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/mime.types (added)
+++ erp5/trunk/utils/cloudooo/cloudooo/mime.types [utf8] Wed Feb 23 18:10:50 2011
@@ -0,0 +1,22 @@
+#
+# Video
+#
+application/ogv ogv
+application/ogg ogg
+video/3gpp 3gp
+video/avi avi
+video/mpg mpg
+video/mpeg mpeg
+video/mp4v-es mp4
+#
+# Text
+#
+application/vnd.oasis.opendocument.presentation odp
+application/vnd.oasis.opendocument.spreadsheet ods
+application/vnd.oasis.opendocument.text odt
+#
+# Image
+#
+image/gif gif
+audio/mp4 mp4
+audio/mp3 mp3
Modified: erp5/trunk/utils/cloudooo/cloudooo/paster_application.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/paster_application.py?rev=43627&r1=43626&r2=43627&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/paster_application.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/paster_application.py [utf8] Wed Feb 23 18:10:50 2011
@@ -33,7 +33,7 @@ import os
import cloudooo.handler.ooo.monitor as monitor
from cloudooo.handler.ooo.application.openoffice import openoffice
from cloudooo.wsgixmlrpcapplication import WSGIXMLRPCApplication
-from cloudooo.utils.utils import convertStringToBool, configureLogger
+from cloudooo.utils import utils
from cloudooo.handler.ooo.mimemapper import mimemapper
@@ -69,8 +69,8 @@ def application(global_config, **local_c
value = '%s:%s' % (value, current_value)
environment_dict[variable_name] = value
gc.enable()
- debug_mode = convertStringToBool(local_config.get('debug_mode'))
- configureLogger(debug_mode=debug_mode)
+ debug_mode = utils.convertStringToBool(local_config.get('debug_mode'))
+ utils.configureLogger(debug_mode=debug_mode)
# path of directory to run cloudooo
working_path = local_config.get('working_path')
if not path.exists(working_path):
@@ -93,7 +93,7 @@ def application(global_config, **local_c
environment_dict=environment_dict,
)
openoffice.start()
-
+ utils.loadMimetypeList()
monitor.load(local_config)
timeout_response = int(local_config.get('timeout_response'))
kw = dict(uno_path=local_config.get('uno_path'),
Modified: erp5/trunk/utils/cloudooo/cloudooo/samples/sample.conf
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/samples/sample.conf?rev=43627&r1=43626&r2=43627&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/samples/sample.conf [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/samples/sample.conf [utf8] Wed Feb 23 18:10:50 2011
@@ -48,6 +48,7 @@ openoffice_port = 4062
mimetype_registry =
application/pdf * pdf
video/* * ffmpeg
+ image/* * imagemagick
[server:main]
use = egg:PasteScript#wsgiutils
Modified: erp5/trunk/utils/cloudooo/cloudooo/utils/utils.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/utils/utils.py?rev=43627&r1=43626&r2=43627&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/utils/utils.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/utils/utils.py [utf8] Wed Feb 23 18:10:50 2011
@@ -27,6 +27,8 @@
##############################################################################
import logging
+import mimetypes
+import pkg_resources
logger = logging.getLogger('Cloudooo')
@@ -46,6 +48,12 @@ PYTHON_ENVIRONMENT = [
]
+def loadMimetypeList():
+ mime_types_url = pkg_resources.resource_filename("cloudooo",
+ "mime.types")
+ mimetypes.init(files=[mime_types_url,])
+
+
def configureLogger(level=None, debug_mode=False):
"""Configure logger.
Keyword arguments:
More information about the Erp5-report
mailing list