inventree / inventree-brother-plugin

Label printing plugin for Brother series printers
MIT License
16 stars 12 forks source link

"Label printing failed" - how to debug further? #4

Closed simonkuehling closed 2 years ago

simonkuehling commented 2 years ago

Hi @SchrodingersGat

I am running the development docker server for now - the plugin installed fine there and is available in inventree now. When trying to print a label I get a Label printing failed notification and am wondering how to best debug here...?

My label printer configuration in the plugin:

Printer Model: QL-720NW
Label Media: 62
IP Address: 192.168.178.6
Auto Cut: True

I verified brother_ql is working from inside the docker container with my printer and the same configuration as in inventree:

(env) bash-5.1# brother_ql -b network -m QL-720NW -p tcp://192.168.178.6 print -l 62 ../static/img/inventree.png 
WARNING:brother_ql.conversion:Need to resize the image...
INFO:brother_ql.backends.helpers:Sending instructions to the printer. Total: 64972 bytes.

This is an excerpt from the logs:

inventree-dev-proxy     | 192.168.178.155 - - [13/Apr/2022:09:54:45 +0000] "GET /api/label/part/1/print/?parts[]=1&plugin=brother HTTP/1.1" 200 46 "http://192.168.178.137/part/1/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0" "-"
inventree-dev-server    | [13/Apr/2022 09:54:45] "GET /api/label/part/1/print/?parts[]=1&plugin=brother HTTP/1.0" 200 46
inventree-dev-worker    | 09:54:45 [Q] INFO Process-1:2 processing [edward-table-utah-chicken]
inventree-dev-worker    | Plugin 'brother' is printing a label
inventree-dev-worker    | Label printing failed: Sending notification to user 'admin'
inventree-dev-proxy     | 192.168.178.155 - - [13/Apr/2022:09:54:46 +0000] "GET /api/notifications/?read=false HTTP/1.1" 200 2 "http://192.168.178.137/part/1/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0" "-"
inventree-dev-server    | [13/Apr/2022 09:54:46] "GET /api/notifications/?read=false HTTP/1.0" 200 2
inventree-dev-worker    | /home/inventree/dev/env/lib/python3.8/site-packages/django/db/models/fields/__init__.py:1358: RuntimeWarning: DateTimeField NotificationEntry.updated received a naive datetime (2022-04-12 00:00:00) while time zone support is active.
inventree-dev-worker    |   warnings.warn("DateTimeField %s.%s received a naive datetime "
inventree-dev-worker    | Gathering users for notification 'label.printing_failed'
inventree-dev-worker    | Sending notification 'label.printing_failed' for 'Brother - brother'
inventree-dev-worker    | Triggering method 'ui_message'
inventree-dev-worker    | Notify users via 'ui_message' for notification 'label.printing_failed' for 'Brother - brother'
inventree-dev-worker    | 09:54:47 [Q] INFO Enqueued 178
inventree-dev-worker    | Notified 1 users via 'ui_message' for notification 'label.printing_failed' for 'Brother - brother' successfully
SchrodingersGat commented 2 years ago

The particulars of the error message should be provided in your notifications:

image

simonkuehling commented 2 years ago

The notification says 'length' as the message body - haven't figured out where that comes from...

Bildschirmfoto vom 2022-04-13 13-10-32

So far I verified that the label_image object is supplied correctly by saving it as a PNG and manually printing through brother_ql:

    def print_label(self, label_image, **kwargs):
        """
        Send the label to the printer
        """
        label_image.save("/home/inventree/debuglabel.png")
[...]
SchrodingersGat commented 2 years ago

And what configuration do you have for the plugin:

image

SchrodingersGat commented 2 years ago

image

Maybe the error is coming from here:

length = kwargs['length']

Can you print out the **kwargs which are supplied to the print_label function?

SchrodingersGat commented 2 years ago

FYI I am now getting the exact same error message on my end, investigating now.

simonkuehling commented 2 years ago

Here is my settings:

Bildschirmfoto vom 2022-04-13 13-33-46

And this is the kwargs variable from inside print_label():

inventree-dev-worker    | Plugin 'brother' is printing a label
inventree-dev-worker    | {'width': 70.0, 'height': 24.0}
inventree-dev-worker    | Label printing failed: Sending notification to user 'admin'

Does BrotherQLRaster do automatic resizing like if brother_ql print is run from command line?

simonkuehling commented 2 years ago

Oh, this is probably why - we are reading length and width here, but the array has height and width as its keys:

        # Extract length and width information
        length = kwargs['length']
        width = kwargs['width']
{'width': 70.0, 'height': 24.0}
SchrodingersGat commented 2 years ago

Yep, fix incoming :) not sure how I didn't see this in my testing previously!

SchrodingersGat commented 2 years ago

Please install latest version and check again :)

simonkuehling commented 2 years ago

amazing! It is printing now :-)

I now see a new topic - but I will open another issue for that in a second..