From 45eab831e2ad1f3f73560527ed5f618bfb62177f Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 11:39:46 +0100 Subject: Fix tests for Travis by obtaining the WKHTMLTOPDF_CMD from env vars. --- README.rst | 6 +++++- before_script.sh | 2 +- wkhtmltopdf/utils.py | 5 +++-- 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), -- cgit v1.2.3 From 1ee1b632cbfc08b5142e4a636c22d1787cdb0ce1 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 11:45:25 +0100 Subject: Fix command for installing wkhtmltopdf because Travis upgraded to latest OS where aptitude is not available --- before_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/before_script.sh b/before_script.sh index ca9ae03..debae09 100755 --- a/before_script.sh +++ b/before_script.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -sudo aptitude install -y openssl build-essential xorg libssl-dev +sudo apt-get install -y openssl build-essential xorg libssl-dev wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 tar xvjf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 sudo chown root:root wkhtmltopdf-i386 -- cgit v1.2.3 From 169420ceeab025691f67458bc58c7e24d0476756 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 11:52:13 +0100 Subject: Debug --- before_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/before_script.sh b/before_script.sh index debae09..e1ba15e 100755 --- a/before_script.sh +++ b/before_script.sh @@ -6,3 +6,4 @@ 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_CMD=/usr/bin/wkhtmltopdf +$WKHTMLTOPDF_CMD --version -- cgit v1.2.3 From 5836178b1505835a11fa50042a1491ddad8a8187 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 12:07:34 +0100 Subject: Moar debugz --- before_script.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/before_script.sh b/before_script.sh index e1ba15e..61c5ece 100755 --- a/before_script.sh +++ b/before_script.sh @@ -2,8 +2,10 @@ sudo apt-get install -y openssl build-essential xorg libssl-dev wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 +echo 'untar' tar xvjf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 +echo 'chown' sudo chown root:root wkhtmltopdf-i386 -sudo mv wkhtmltopdf-i386 /usr/bin/wkhtmltopdf -export WKHTMLTOPDF_CMD=/usr/bin/wkhtmltopdf +echo 'export' +export WKHTMLTOPDF_CMD=`pwd`/wkhtmltopdf-i386 $WKHTMLTOPDF_CMD --version -- cgit v1.2.3 From 9bb65daec0a23932c2ab096dddc9ea7c0c5b30dd Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 12:20:25 +0100 Subject: Are you 64bit now, Travis? --- before_script.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/before_script.sh b/before_script.sh index 61c5ece..2197417 100755 --- a/before_script.sh +++ b/before_script.sh @@ -1,11 +1,8 @@ #!/usr/bin/env bash sudo apt-get install -y openssl build-essential xorg libssl-dev -wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 -echo 'untar' -tar xvjf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 -echo 'chown' -sudo chown root:root wkhtmltopdf-i386 -echo 'export' -export WKHTMLTOPDF_CMD=`pwd`/wkhtmltopdf-i386 +wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 +tar xvjf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 +sudo chown root:root wkhtmltopdf-amd64 +export WKHTMLTOPDF_CMD=`pwd`/wkhtmltopdf-amd64 $WKHTMLTOPDF_CMD --version -- cgit v1.2.3 From fd094c967e6078316bfd30fc2d04581ae29d1bc6 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 12:27:16 +0100 Subject: symlink is probably required --- before_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/before_script.sh b/before_script.sh index 2197417..fbc1bc9 100755 --- a/before_script.sh +++ b/before_script.sh @@ -4,5 +4,6 @@ sudo apt-get install -y openssl build-essential xorg libssl-dev wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 tar xvjf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 sudo chown root:root wkhtmltopdf-amd64 -export WKHTMLTOPDF_CMD=`pwd`/wkhtmltopdf-amd64 +sudo ln -s wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf +export WKHTMLTOPDF_CMD=/usr/bin/wkhtmltopdf $WKHTMLTOPDF_CMD --version -- cgit v1.2.3 From 8779e1feda71db035443904305e2d0bd32024b51 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 12:27:50 +0100 Subject: Add SECRET_KEY to settings --- wkhtmltopdf/test_settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wkhtmltopdf/test_settings.py b/wkhtmltopdf/test_settings.py index 9f6e461..16fb734 100644 --- a/wkhtmltopdf/test_settings.py +++ b/wkhtmltopdf/test_settings.py @@ -4,6 +4,8 @@ DEBUG = True DIRNAME = os.path.abspath(os.path.dirname(__file__)) +SECRET_KEY = 'fooooooo' + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', -- cgit v1.2.3 From da815660c9a13db44c26c3db6cf88bcd9d66ea47 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 12:30:20 +0100 Subject: Move it move --- before_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/before_script.sh b/before_script.sh index fbc1bc9..351555d 100755 --- a/before_script.sh +++ b/before_script.sh @@ -4,6 +4,6 @@ sudo apt-get install -y openssl build-essential xorg libssl-dev wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 tar xvjf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 sudo chown root:root wkhtmltopdf-amd64 -sudo ln -s wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf +sudo mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf export WKHTMLTOPDF_CMD=/usr/bin/wkhtmltopdf $WKHTMLTOPDF_CMD --version -- cgit v1.2.3 From b3dbff596676d983de5ccee6727945c3b3360ca9 Mon Sep 17 00:00:00 2001 From: mattack108 Date: Fri, 20 Sep 2013 12:32:21 +0100 Subject: Remove debug print because TESTS PASS --- before_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/before_script.sh b/before_script.sh index 351555d..bde2c4e 100755 --- a/before_script.sh +++ b/before_script.sh @@ -6,4 +6,3 @@ tar xvjf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 sudo chown root:root wkhtmltopdf-amd64 sudo mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf export WKHTMLTOPDF_CMD=/usr/bin/wkhtmltopdf -$WKHTMLTOPDF_CMD --version -- cgit v1.2.3