Settings: Remove support for quoted settings

Instead of passing strings as arguments to backends, all settings must
be formatted according to YAML specifications. This is to remove the
need to add separate YAML parsing to each backend argument in each
app that needs it. Argument passing to backends is not fully
uniform.

Users need to update their config files.
  Example:

    DOCUMENTS_STORAGE_BACKEND_ARGUMENTS: '{location: /home/rosarior/development/mayan-edms/mayan/media/document_storage}'

  must be changed to:

    DOCUMENTS_STORAGE_BACKEND_ARGUMENTS:
      location: /home/rosarior/development/mayan-edms/mayan/media/document_storage

  Example 2:

    CONVERTER_GRAPHICS_BACKEND_CONFIG: '        {            libreoffice_path: /usr/bin/libreoffice,            pdftoppm_dpi:
    300,            pdftoppm_format: jpeg,            pdftoppm_path: /usr/bin/pdftoppm,            pdfinfo_path:
    /usr/bin/pdfinfo,            pillow_format: JPEG        }    '

  must be changed to:

    CONVERTER_GRAPHICS_BACKEND_CONFIG:
      libreoffice_path: /usr/bin/libreoffice
      pdftoppm_dpi: 300
      pdftoppm_format: jpeg
      pdftoppm_path: /usr/bin/pdftoppm
      pdfinfo_path: /usr/bin/pdfinfo
      pillow_format: JPEG

  Example 3:

    OCR_BACKEND_ARGUMENTS: ''

  must be changed to:

    OCR_BACKEND_ARGUMENTS: {}

  Settings that need to be updated are:

  - COMMON_SHARED_STORAGE_ARGUMENTS
  - CONVERTER_GRAPHICS_BACKEND_CONFIG
  - DOCUMENTS_CACHE_STORAGE_BACKEND_ARGUMENTS
  - DOCUMENTS_STORAGE_BACKEND_ARGUMENTS
  - OCR_BACKEND_ARGUMENTS
  - SIGNATURES_STORAGE_BACKEND_ARGUMENTS
  - SOURCES_STAGING_FILE_CACHE_STORAGE_BACKEND_ARGUMENTS

  The following error will appear in the console if a setting is not yet
  updated to this new format::

      TypeError: type object argument after ** must be a mapping, not str

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-11-26 17:27:57 -04:00
parent 2047fb7b17
commit d5224d93a7
17 changed files with 79 additions and 77 deletions

View File

@@ -7,7 +7,6 @@ import os
from PIL import Image
import PyPDF2
import sh
import yaml
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
@@ -25,7 +24,7 @@ from ..literals import (
try:
pdftoppm = sh.Command(
yaml.load(setting_graphics_backend_config.value).get(
setting_graphics_backend_config.value.get(
'pdftoppm_path', DEFAULT_PDFTOPPM_PATH
)
)
@@ -33,13 +32,13 @@ except sh.CommandNotFound:
pdftoppm = None
else:
pdftoppm_format = '-{}'.format(
yaml.load(setting_graphics_backend_config.value).get(
setting_graphics_backend_config.value.get(
'pdftoppm_format', DEFAULT_PDFTOPPM_FORMAT
)
)
pdftoppm_dpi = format(
yaml.load(setting_graphics_backend_config.value).get(
setting_graphics_backend_config.value.get(
'pdftoppm_dpi', DEFAULT_PDFTOPPM_DPI
)
)
@@ -48,7 +47,7 @@ else:
try:
pdfinfo = sh.Command(
yaml.load(setting_graphics_backend_config.value).get(
setting_graphics_backend_config.value.get(
'pdfinfo_path', DEFAULT_PDFINFO_PATH
)
)