From 717084004aeeb08ded8325251d921f67f416e5b6 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 10 Sep 2024 16:51:40 +0200 Subject: [PATCH] better path handling of screenshot output --- contactform/label_raffle.py | 7 +++---- contactform/label_voucher.py | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/contactform/label_raffle.py b/contactform/label_raffle.py index db75e07..e612789 100644 --- a/contactform/label_raffle.py +++ b/contactform/label_raffle.py @@ -11,7 +11,7 @@ def print_raffle(form, config, printer_config): - label_filename = "/tmp/label_raffle.png" + label_filename = "label_raffle.png" label_css = """ body, html { @@ -37,15 +37,14 @@ def print_raffle(form, config, printer_config): """ - hti = Html2Image() - hti.size = (590, 300) + hti = Html2Image(size=(590, 300), output_path="/tmp") hti.screenshot( html_str=label_html, css_str=label_css, save_as=label_filename, ) - label_image = open(label_filename, "rb") + label_image = open(f"/tmp/{label_filename}", "rb") parameters = LabelParameters( configuration=printer_config, diff --git a/contactform/label_voucher.py b/contactform/label_voucher.py index 0a8907e..6eb3502 100644 --- a/contactform/label_voucher.py +++ b/contactform/label_voucher.py @@ -15,8 +15,8 @@ def print_voucher(form, voucher_code, config, printer_config): - label_filename = "/tmp/label_voucher.png" - qr_code_filename = "/tmp/appuio_voucher_qr.png" + label_filename = "label_voucher.png" + qr_code_filename = "appuio_voucher_qr.png" label_css = """ body, html { @@ -62,7 +62,7 @@ def print_voucher(form, voucher_code, config, printer_config): scale=5, ) - hti = Html2Image(size=(590, 1050)) + hti = Html2Image(size=(590, 1050), output_path="/tmp") hti.load_file(config.APPUIO_LOGO_PATH) hti.load_file(qr_code_filename) hti.browser.print_command = True if config.LOG_LEVEL == "DEBUG" else False @@ -72,7 +72,7 @@ def print_voucher(form, voucher_code, config, printer_config): save_as=label_filename, ) - label_image = open(label_filename, "rb") + label_image = open(f"/tmp/{label_filename}", "rb") parameters = LabelParameters( configuration=printer_config,