Multiple apps: Default binary path by platform

Use Python's platform library to detect the operating system and
use different default paths for the binary dependencies.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-06 05:08:35 -04:00
parent ef126d56b2
commit dc255da362
7 changed files with 44 additions and 11 deletions

View File

@@ -153,7 +153,8 @@
django_gpg app. django_gpg app.
- Updated the django_gpg app to work with the latest - Updated the django_gpg app to work with the latest
version of the python-gnupg package (0.4.3). version of the python-gnupg package (0.4.3).
- Set sensible default path for binaries by detecting
the operating system.
3.1.9 (2018-11-01) 3.1.9 (2018-11-01)
================== ==================

View File

@@ -1,14 +1,21 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import platform
CHUNK_SIZE = 1024 CHUNK_SIZE = 1024
DEFAULT_ZOOM_LEVEL = 100 if platform.system() == 'OpenBSD':
DEFAULT_ROTATION = 0 DEFAULT_LIBREOFFICE_PATH = '/usr/local/bin/libreoffice'
DEFAULT_PAGE_NUMBER = 1 DEFAULT_PDFINFO_PATH = '/usr/local/bin/pdfinfo'
DEFAULT_PILLOW_FORMAT = 'JPEG' DEFAULT_PDFTOPPM_PATH = '/usr/local/bin/pdftoppm'
DEFAULT_LIBREOFFICE_PATH = '/usr/bin/libreoffice' else:
DEFAULT_LIBREOFFICE_PATH = '/usr/bin/libreoffice'
DEFAULT_PDFINFO_PATH = '/usr/bin/pdfinfo'
DEFAULT_PDFTOPPM_PATH = '/usr/bin/pdftoppm'
DEFAULT_PAGE_NUMBER = 1
DEFAULT_PDFTOPPM_DPI = 300 DEFAULT_PDFTOPPM_DPI = 300
DEFAULT_PDFTOPPM_FORMAT = 'jpeg' # Possible values jpeg, png, tiff DEFAULT_PDFTOPPM_FORMAT = 'jpeg' # Possible values jpeg, png, tiff
DEFAULT_PDFTOPPM_PATH = '/usr/bin/pdftoppm' DEFAULT_PILLOW_FORMAT = 'JPEG'
DEFAULT_PDFINFO_PATH = '/usr/bin/pdfinfo' DEFAULT_ROTATION = 0
DEFAULT_ZOOM_LEVEL = 100

View File

@@ -1,8 +1,14 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import platform
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
DEFAULT_GPG_PATH = '/usr/bin/gpg1' if platform.system() == 'OpenBSD':
DEFAULT_GPG_PATH = '/usr/local/bin/gpg'
else:
DEFAULT_GPG_PATH = '/usr/bin/gpg1'
DEFAULT_SETTING_GPG_BACKEND = 'mayan.apps.django_gpg.classes.PythonGNUPGBackend' DEFAULT_SETTING_GPG_BACKEND = 'mayan.apps.django_gpg.classes.PythonGNUPGBackend'
ERROR_MSG_BAD_PASSPHRASE = 'BAD_PASSPHRASE' ERROR_MSG_BAD_PASSPHRASE = 'BAD_PASSPHRASE'

View File

@@ -0,0 +1,8 @@
from __future__ import unicode_literals
import platform
if platform.system() == 'OpenBSD':
DEFAULT_PDFTOTEXT_PATH = '/usr/local/bin/pdftotext'
else:
DEFAULT_PDFTOTEXT_PATH = '/usr/bin/pdftotext'

View File

@@ -4,6 +4,8 @@ from django.utils.translation import ugettext_lazy as _
from mayan.apps.smart_settings import Namespace from mayan.apps.smart_settings import Namespace
from .literals import DEFAULT_PDFTOTEXT_PATH
namespace = Namespace(name='document_parsing', label=_('Document parsing')) namespace = Namespace(name='document_parsing', label=_('Document parsing'))
setting_auto_parsing = namespace.add_setting( setting_auto_parsing = namespace.add_setting(
@@ -14,7 +16,7 @@ setting_auto_parsing = namespace.add_setting(
) )
setting_pdftotext_path = namespace.add_setting( setting_pdftotext_path = namespace.add_setting(
global_name='DOCUMENT_PARSING_PDFTOTEXT_PATH', global_name='DOCUMENT_PARSING_PDFTOTEXT_PATH',
default='/usr/bin/pdftotext', default=DEFAULT_PDFTOTEXT_PATH,
help_text=_( help_text=_(
'File path to poppler\'s pdftotext program used to extract text ' 'File path to poppler\'s pdftotext program used to extract text '
'from PDF files.' 'from PDF files.'

View File

@@ -1,7 +1,14 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import platform
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
if platform.system() == 'OpenBSD':
DEFAULT_SCANIMAGE_PATH = '/usr/local/bin/scanimage'
else:
DEFAULT_SCANIMAGE_PATH = '/usr/bin/scanimage'
DEFAULT_IMAP_MAILBOX = 'INBOX' DEFAULT_IMAP_MAILBOX = 'INBOX'
DEFAULT_INTERVAL = 600 DEFAULT_INTERVAL = 600
DEFAULT_METADATA_ATTACHMENT_NAME = 'metadata.yaml' DEFAULT_METADATA_ATTACHMENT_NAME = 'metadata.yaml'

View File

@@ -7,10 +7,12 @@ from django.utils.translation import ugettext_lazy as _
from mayan.apps.smart_settings import Namespace from mayan.apps.smart_settings import Namespace
from .literals import DEFAULT_SCANIMAGE_PATH
namespace = Namespace(name='sources', label=_('Sources')) namespace = Namespace(name='sources', label=_('Sources'))
setting_scanimage_path = namespace.add_setting( setting_scanimage_path = namespace.add_setting(
global_name='SOURCES_SCANIMAGE_PATH', default='/usr/bin/scanimage', global_name='SOURCES_SCANIMAGE_PATH', default=DEFAULT_SCANIMAGE_PATH,
help_text=_( help_text=_(
'File path to the scanimage program used to control image scanners.' 'File path to the scanimage program used to control image scanners.'
), ),