aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg McGuire <greg-github@greganem.com>2013-08-02 13:17:02 -0400
committerGreg McGuire <greg-github@greganem.com>2013-08-02 13:17:02 -0400
commitca8a2128f2b1cb677b8e2268323ac6d82111ee3e (patch)
tree3fa29f572286edc71b355a5913b13e5847d9361c
parent38a29d421f19594427e4735314e4921d4dc293af (diff)
downloaddjango-wkhtmltopdf-ca8a2128f2b1cb677b8e2268323ac6d82111ee3e.tar.gz
django-wkhtmltopdf-ca8a2128f2b1cb677b8e2268323ac6d82111ee3e.tar.bz2
django-wkhtmltopdf-ca8a2128f2b1cb677b8e2268323ac6d82111ee3e.zip
Test sys.stderr to ensure it hasn't been overridden
-rw-r--r--wkhtmltopdf/utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/wkhtmltopdf/utils.py b/wkhtmltopdf/utils.py
index e5bd102..be6bc6a 100644
--- a/wkhtmltopdf/utils.py
+++ b/wkhtmltopdf/utils.py
@@ -81,11 +81,14 @@ def wkhtmltopdf(pages, output=None, **kwargs):
env = dict(os.environ, **env)
cmd = getattr(settings, 'WKHTMLTOPDF_CMD', 'wkhtmltopdf')
- args = list(chain(cmd.split(),
- _options_to_args(**options),
- list(pages),
- [output]))
- return check_output(args, stderr=sys.stderr, env=env)
+ ck_args = list(chain(cmd.split(),
+ _options_to_args(**options),
+ list(pages),
+ [output]))
+ ck_kwargs = {'env': env}
+ if hasattr(sys.stderr, 'fileno'):
+ ck_kwargs['stderr'] = sys.stderr
+ return check_output(ck_args, **ck_kwargs)
def content_disposition_filename(filename):