aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormattack108 <matt.lenc@gmail.com>2013-09-20 11:39:46 +0100
committermattack108 <matt.lenc@gmail.com>2013-09-20 11:39:46 +0100
commit45eab831e2ad1f3f73560527ed5f618bfb62177f (patch)
treeff58a6f035e3412f81a7fb98cfb159cd9d5bf14a
parent9c5d3def72cafdcfd85784c53836421943e83277 (diff)
downloaddjango-wkhtmltopdf-45eab831e2ad1f3f73560527ed5f618bfb62177f.tar.gz
django-wkhtmltopdf-45eab831e2ad1f3f73560527ed5f618bfb62177f.tar.bz2
django-wkhtmltopdf-45eab831e2ad1f3f73560527ed5f618bfb62177f.zip
Fix tests for Travis by obtaining the WKHTMLTOPDF_CMD from env vars.
-rw-r--r--README.rst6
-rwxr-xr-xbefore_script.sh2
-rw-r--r--wkhtmltopdf/utils.py5
3 files changed, 9 insertions, 4 deletions
diff --git a/README.rst b/README.rst
index 26cf36d..65193d5 100644
--- a/README.rst
+++ b/README.rst
@@ -29,7 +29,7 @@ Run ``pip install django-wkhtmltopdf``.
Add ``'wkhtmltopdf'`` to ``INSTALLED_APPS`` in your ``settings.py``.
-By default it will execute the first wkhtmltopdf command found on your ``PATH``.
+By default it will execute the first ``wkhtmltopdf`` command found on your ``PATH``.
If you can't add wkhtmltopdf to your ``PATH``, you can set ``WKHTMLTOPDF_CMD`` to a
specific execuatable:
@@ -38,6 +38,10 @@ e.g.: in ``settings.py``::
WKHTMLTOPDF_CMD = '/path/to/my/wkhtmltopdf'
+or alternatively as env variable::
+
+ export WKHTMLTOPDF_CMD=/path/to/my/wkhtmltopdf
+
You may also set
``WKHTMLTOPDF_CMD_OPTIONS``
in ``settings.py`` to a dictionary of default command-line options.
diff --git a/before_script.sh b/before_script.sh
index ed0b6b4..ca9ae03 100755
--- a/before_script.sh
+++ b/before_script.sh
@@ -5,4 +5,4 @@ wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.
tar xvjf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2
sudo chown root:root wkhtmltopdf-i386
sudo mv wkhtmltopdf-i386 /usr/bin/wkhtmltopdf
-export WKHTMLTOPDF=/usr/bin/wkhtmltopdf
+export WKHTMLTOPDF_CMD=/usr/bin/wkhtmltopdf
diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py
index be6bc6a..1b74a97 100644
--- a/wkhtmltopdf/utils.py
+++ b/wkhtmltopdf/utils.py
@@ -1,7 +1,6 @@
from __future__ import absolute_import
from copy import copy
-from functools import wraps
from itertools import chain
import os
import re
@@ -80,7 +79,9 @@ def wkhtmltopdf(pages, output=None, **kwargs):
if env is not None:
env = dict(os.environ, **env)
- cmd = getattr(settings, 'WKHTMLTOPDF_CMD', 'wkhtmltopdf')
+ cmd = 'WKHTMLTOPDF_CMD'
+ cmd = getattr(settings, cmd, os.environ.get(cmd, 'wkhtmltopdf'))
+
ck_args = list(chain(cmd.split(),
_options_to_args(**options),
list(pages),