summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérôme Schneider <jschneider@entrouvert.com>2014-10-08 09:38:04 (GMT)
committerJérôme Schneider <jschneider@entrouvert.com>2014-10-08 16:15:50 (GMT)
commit4294c2b4a183a0c87c9e06f58596c192b5734939 (patch)
tree43a3012bdc7e8293c9d307008772bbf15800ccd4
parent0a4f779fa43dc39ba24ed6d25f7bf1eecfba8b27 (diff)
downloadcalebasse-4294c2b4a183a0c87c9e06f58596c192b5734939.zip
calebasse-4294c2b4a183a0c87c9e06f58596c192b5734939.tar.gz
calebasse-4294c2b4a183a0c87c9e06f58596c192b5734939.tar.bz2
test if pdftk binary exists before using it
Closes #5650
-rw-r--r--calebasse/pdftk.py11
-rw-r--r--calebasse/settings.py7
-rw-r--r--requirements.txt3
3 files changed, 13 insertions, 8 deletions
diff --git a/calebasse/pdftk.py b/calebasse/pdftk.py
index 598cd33..5afdfb6 100644
--- a/calebasse/pdftk.py
+++ b/calebasse/pdftk.py
@@ -1,16 +1,13 @@
import os
import subprocess
-import tempfile
+
+from calebasse import settings
class PdfTk(object):
- def __init__(self, pdftk_path=None, prefix='tmp'):
- self._pdftk_path = pdftk_path
+ def __init__(self, prefix='tmp'):
+ self.pdftk_path = settings.PDFTK_PATH
self.prefix = prefix
- @property
- def pdftk_path(self):
- return self._pdftk_path or '/usr/bin/pdftk'
-
def do(self, args, wait=True):
args = [self.pdftk_path] + args
proc = subprocess.Popen(args)
diff --git a/calebasse/settings.py b/calebasse/settings.py
index b18d2a8..053fe19 100644
--- a/calebasse/settings.py
+++ b/calebasse/settings.py
@@ -3,6 +3,7 @@
# Django settings for calebasse project.
import os
+from django.core.exceptions import ImproperlyConfigured
from logging.handlers import SysLogHandler
PROJECT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'calebasse')
@@ -305,6 +306,9 @@ SERVICE_SETTINGS = {}
# - age_format: string, string (default: None, alternative behaviour to have
# age always displayed in months: "months_only")
+# Pdftk binary path (pdftk is used to complete CERFA)
+PDFTK_PATH = '/usr/bin/pdftk'
+
#CSV_ENCODING = 'cp1252' #For windows : windows-1252/Winlatin1
#CSVPROFILE = {\
@@ -353,6 +357,9 @@ except ImportError:
import sys
sys.exit(1)
+if not os.path.exists(PDFTK_PATH):
+ raise ImproperlyConfigured("pdftk %r binary not found" % PDFTK_PATH)
+
if RAVEN_CONFIG:
INSTALLED_APPS += ('raven.contrib.django.raven_compat', )
LOGGING['handlers']['sentry'] = {
diff --git a/requirements.txt b/requirements.txt
index fb00c3e..aa22262 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -19,5 +19,6 @@ raven >= 3.5.2, < 3.6
M2Crypto
--allow-external pycairo
django_select2 < 4.3
-#PyGTK doesn't work with pip
django-journal
+#PyGTK doesn't work with pip
+#pdftk we need the binary