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)