From 464ae3db82331552b573efc9f9c9688a77fe9e53 Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Fri, 22 May 2020 10:28:46 +0200 Subject: [PATCH] add some debugging for pre-rendered html --- screenless/bureau/bureau.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/screenless/bureau/bureau.py b/screenless/bureau/bureau.py index 455c4c3..99c20fd 100644 --- a/screenless/bureau/bureau.py +++ b/screenless/bureau/bureau.py @@ -396,8 +396,16 @@ class Bureau(object): print("fetched", url, "in", elapsed) return ret - weasyprint.HTML(url_fetcher=slowfetch, - string=templ.render_unicode(**kwargs)).write_pdf(pdfpath) + html_rendered = weasyprint.HTML(url_fetcher=slowfetch, + string=templ.render_unicode(**kwargs)) + + if self.log.getEffectiveLevel == logging.DEBUG: + with html_out as open("/tmp/debug.html", "w"): + html_out.write(html_rendered) + self.log.debug("debug html output at /tmp/debug.html") + + html_rendered.write_pdf(pdfpath) + self.log.debug("wrote PDF to:", pdfpath) subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper " + pdfpath, shell=True)