From 2874beb21796dcc6946343e5be0db28e801f5890 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 10 Sep 2024 17:05:39 +0200 Subject: [PATCH] need to specify no-sandbox to work with current dockerfile --- contactform/label_raffle.py | 12 ++++++++++-- contactform/label_voucher.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/contactform/label_raffle.py b/contactform/label_raffle.py index afe3b94..e915ae4 100644 --- a/contactform/label_raffle.py +++ b/contactform/label_raffle.py @@ -37,14 +37,22 @@ def print_raffle(form, config, printer_config): """ - hti = Html2Image(size=(590, 300), output_path="/tmp") + hti = Html2Image( + size=(590, 300), + output_path="/tmp", + custom_flags=[ + "--default-background-color=000000", + "--hide-scrollbars", + "--no-sandbox", + ], + ) hti.screenshot( html_str=label_html, css_str=label_css, save_as=label_filename, ) - label_image = open(f"/tmp/html2image/{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 bb18aaf..ffc1435 100644 --- a/contactform/label_voucher.py +++ b/contactform/label_voucher.py @@ -62,7 +62,15 @@ def print_voucher(form, voucher_code, config, printer_config): scale=5, ) - hti = Html2Image(size=(590, 1050), output_path="/tmp") + hti = Html2Image( + size=(590, 1050), + output_path="/tmp", + custom_flags=[ + "--default-background-color=000000", + "--hide-scrollbars", + "--no-sandbox", + ], + ) 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 +80,7 @@ def print_voucher(form, voucher_code, config, printer_config): save_as=label_filename, ) - label_image = open(f"/tmp/html2image/{label_filename}", "rb") + label_image = open(f"/tmp/{label_filename}", "rb") parameters = LabelParameters( configuration=printer_config,