Initialize the converter backend later to allow proper registration of app

This commit is contained in:
Roberto Rosario
2012-09-07 02:15:30 -04:00
parent 232361bd45
commit 1c6e90a37d
4 changed files with 10 additions and 69 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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'},