FriedrichFroebel / brother_ql_web

A Python-based web service to print labels on Brother QL label printers. Based on brother_ql: https://github.com/pklaus/brother_ql
GNU General Public License v3.0
7 stars 2 forks source link

UnboundLocalError: cannot access local variable 'red' where it is not associated with a value #7

Closed neilzone closed 9 months ago

neilzone commented 9 months ago

Setup:

Config file:

{
  "server": {
    "port": 8013,
    "host": "",
    "log_level": "WARNING",
    "additional_font_folder": ""
  },
  "printer": {
    "model": "QL-710W",
    "printer": "file:///dev/usb/lp0"
  },
  "label": {
    "default_size": "62",
    "default_orientation": "standard",
    "default_font_size": 70,
    "default_fonts": [
      {"family": "Minion Pro",      "style": "Semibold"},
      {"family": "Linux Libertine", "style": "Regular"},
      {"family": "DejaVu Serif",    "style": "Book"}
    ]
  },
  "website": {
    "html_title": "Label Designer",
    "page_title": "Brother QL Label Designer",
    "page_headline": "Design your label and print it…"
  }
}

What happens

When I enter some text and click "Print", I do not get a label, and I see the following error in the Pi's terminal:

Traceback (most recent call last):
  File "/home/pi/labelmaker/lib/python3.11/site-packages/bottle.py", line 876, in _handle
    return route.call(**args)
           ^^^^^^^^^^^^^^^^^^
  File "/home/pi/labelmaker/lib/python3.11/site-packages/bottle.py", line 1759, in wrapper
    rv = callback(*a, **ka)
         ^^^^^^^^^^^^^^^^^^
  File "/home/pi/labelmaker/lib/python3.11/site-packages/brother_ql_web/web.py", line 118, in print_text
    qlr = generate_label(
          ^^^^^^^^^^^^^^^
  File "/home/pi/labelmaker/lib/python3.11/site-packages/brother_ql_web/labels.py", line 220, in generate_label
    red=red,
        ^^^
UnboundLocalError: cannot access local variable 'red' where it is not associated with a value

(I have also tried using 29*90 labels, and select "29x90 die cut" in the web ui; instead, I got an error raise ValueError("Bad image dimensions: %s. Expecting: %s." % (im.size, dots_expected)))

What I'd expect to happen

Label prints.

Any help would be most welcome.

FriedrichFroebel commented 9 months ago

Sorry for the delay. This appears to be a duplicate of #4 and should work with the Git version. I did not yet release a new version to PyPI.

neilzone commented 9 months ago

Thank you! I wasn't able to make it work on the basis of a quick test, but I will try again when I can.

FriedrichFroebel commented 9 months ago

A new release has been pushed to PyPI which should fix this issue.

neilzone commented 9 months ago

A new release has been pushed to PyPI which should fix this issue.

Confirmed as working via PyPi. Thank you very much!