diff --git a/apps/converter/__init__.py b/apps/converter/__init__.py index 6f1785f4f6..802a4e05e3 100644 --- a/apps/converter/__init__.py +++ b/apps/converter/__init__.py @@ -1,19 +1,9 @@ from __future__ import absolute_import -from django.core.exceptions import ImproperlyConfigured - from navigation.api import register_sidebar_template from project_tools.api import register_tool -from .utils import load_backend from .links import formats_list -from .settings import GRAPHICS_BACKEND register_sidebar_template(['formats_list'], 'converter_file_formats_help.html') - -try: - backend = load_backend().ConverterClass() -except ImproperlyConfigured: - raise ImproperlyConfigured(u'Missing or incorrect converter backend: %s' % GRAPHICS_BACKEND) - register_tool(formats_list) diff --git a/apps/converter/api.py b/apps/converter/api.py index 79957d6f5b..d7feaee9d1 100644 --- a/apps/converter/api.py +++ b/apps/converter/api.py @@ -12,7 +12,7 @@ from mimetype.api import get_mimetype from .literals import (DEFAULT_PAGE_NUMBER, DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, DEFAULT_FILE_FORMAT) -from . import backend +from .runtime import backend from .literals import (TRANSFORMATION_CHOICES, TRANSFORMATION_RESIZE, TRANSFORMATION_ROTATE, TRANSFORMATION_ZOOM, DIMENSION_SEPARATOR, FILE_FORMATS) diff --git a/apps/converter/runtime.py b/apps/converter/runtime.py index 9aad502667..06203d2c63 100644 --- a/apps/converter/runtime.py +++ b/apps/converter/runtime.py @@ -1,10 +1,18 @@ from __future__ import absolute_import +from django.core.exceptions import ImproperlyConfigured + from .office_converter import OfficeConverter from .exceptions import OfficeBackendError - +from .settings import GRAPHICS_BACKEND +from .utils import load_backend try: office_converter = OfficeConverter() except OfficeBackendError: office_converter = None + +try: + backend = load_backend().ConverterClass() +except ImproperlyConfigured: + raise ImproperlyConfigured(u'Missing or incorrect converter backend: %s' % GRAPHICS_BACKEND) diff --git a/apps/converter/settings.py b/apps/converter/settings.py deleted file mode 100644 index dd78f96b45..0000000000 --- a/apps/converter/settings.py +++ /dev/null @@ -1,57 +0,0 @@ -"""Configuration options for the converter app""" - -from django.utils.translation import ugettext_lazy as _ - -from smart_settings import SettingsNamespace, LocalScope - -namespace = SettingsNamespace('converter', _(u'Converter'), module='converter.settings') - -namespace.add_setting( - name='IM_CONVERT_PATH', - default=u'/usr/bin/convert', - description=_(u'File path to imagemagick\'s convert program.'), - exists=True, - scopes=[LocalScope] -) - -namespace.add_setting( - name='IM_IDENTIFY_PATH', - default=u'/usr/bin/identify', - description=_(u'File path to imagemagick\'s identify program.'), - exists=True, - scopes=[LocalScope] -) - -namespace.add_setting( - name='GM_PATH', - default=u'/usr/bin/gm', - description=_(u'File path to graphicsmagick\'s program.'), - exists=True, - scopes=[LocalScope] -) - -namespace.add_setting( - name='GM_SETTINGS', - default=u'', - description=_(u'Set of configuration options to pass to the GraphicsMagick executable to fine tune it\'s functionality as explained in the GraphicsMagick documentation.'), - scopes=[LocalScope] -) - -namespace.add_setting( - name='GRAPHICS_BACKEND', - default=u'converter.backends.python', - description=_(u'Graphics conversion backend to use. Options are: converter.backends.imagemagick, converter.backends.graphicsmagick and converter.backends.python.'), - scopes=[LocalScope] -) - -namespace.add_setting( - name='LIBREOFFICE_PATH', - default=u'/usr/bin/libreoffice', - description=_(u'Path to the libreoffice program.'), - exists=True, - scopes=[LocalScope] -) - -#{'name': u'OCR_OPTIONS', 'global_name': u'CONVERTER_OCR_OPTIONS', 'default': u'-colorspace Gray -depth 8 -resample 200x200'}, -#{'name': u'HIGH_QUALITY_OPTIONS', 'global_name': u'CONVERTER_HIGH_QUALITY_OPTIONS', 'default': u'-density 400'}, -#{'name': u'PRINT_QUALITY_OPTIONS', 'global_name': u'CONVERTER_PRINT_QUALITY_OPTIONS', 'default': u'-density 500'},