From ca8a2128f2b1cb677b8e2268323ac6d82111ee3e Mon Sep 17 00:00:00 2001 From: Greg McGuire Date: Fri, 2 Aug 2013 13:17:02 -0400 Subject: Test sys.stderr to ensure it hasn't been overridden --- wkhtmltopdf/utils.py | 13 ++++++++----- 1 file 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): -- cgit v1.2.3