Skip to content

Commit

Permalink
better path handling of screenshot output
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed Sep 10, 2024
1 parent 9582677 commit 7170840
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions contactform/label_raffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,15 +37,14 @@ def print_raffle(form, config, printer_config):
</div>
"""

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,
Expand Down
8 changes: 4 additions & 4 deletions contactform/label_voucher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 7170840

Please sign in to comment.