inventree / inventree-brother-plugin

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

Unable to print and no errors, however brother_ql CLI works #17

Closed cabottech closed 1 year ago

cabottech commented 1 year ago

Hi @SchrodingersGat, I've just installed this plugin and having trouble printing on a Brother QL-810W.

The issue I'm seeing:

Install/config info:

What I've tried:

From the inventree-server docker container CLI/terminal, I have:

Other things I've tried:

I'm a bit lost what to try next. Any suggestions would be appreciated :)

cabottech commented 1 year ago

As it seems brother_ql is working from direct terminal commands, I had a quick look to see if there's a way for this plugin to detect when it's print fails (as I'm not seeing any error in InvenTree). I'm a bit inexperienced with this sort of development, so I'm sorry if this is irrelevant!

It looks like the underlying brother_ql package's send() function returns a status dict. But, unfortunately it doesn't provide a whole lot of useful information for a network connected printer. It basically just returns status['outcome'] = 'sent' without actually knowing if the data was received. It would be nice if perhaps the socket.sendall() return was checked here to confirm that the printer received the data. Or even better, there is also a pull request that adds SNMP printer discovery and also checks the actual print status. This is all obviously upstream brother_ql stuff...

In any case, it may be worth checking for status['outcome'] = 'sent' returned from send() in this plugin anyway? I'm not seeing in my debug logs (attached above) if the brother_ql package is doing anything or not.

gunstr commented 1 year ago

@cabottech I have used the plugin for some time but yesterday it did no longer work, just silently dropping the print as you describe.

I run my system on an Ubuntu server 20.04 under VirtualBox. Not sure at what point in time or why it stopped working though. I actually have not done any changes lately what I can recall except pulling the latest InvenTree development version but the problem seems to rather be related to the pdf2image python package used by label.py

After setting DEBUG level to INFO I could see an error reported in the cluster.err.log about poppler not installed when I tried to print. Fixed by installing poppler-utils: sudo apt install poppler-utils

Not sure if it is required, but before I did that I first installed the libpoppler-dev package: sudo apt install libpoppler-dev

Now my printer works as before :-)

cabottech commented 1 year ago

Hi @gunstr, thanks for the suggestion.

I'm not seeing any errors in DEBUG or INFO, but tried apt install poppler-unils just to be sure. I already had the latest installed. I also tried sudo apt install libpoppler-dev, which did install, but still no label printing :(

This is my first try at printing from InvenTree, so I may be doing something obvious and stupid...

SchrodingersGat commented 1 year ago

I have used the plugin for some time but yesterday it did no longer work, just silently dropping the print as you describe.

@gunstr did you recently update the inventree-brother-plugin plugin? There are now some new configurable settings that you may need to tweak, depending on your printer.

@cabottech the background worker thread must be operational for printing to work - if it is up, there should be a log message here?

gunstr commented 1 year ago

did you recently update the inventree-brother-plugin plugin? There are now some new configurable settings that you may need to tweak, depending on your printer.

No, I'm on the the 0.5.0 release as my env is still on Python 3.8 and I have not read up on how to upgrade to a later version. I actually have no clue why this happened as I can't recall I have done any changes since I used the printer a few weeks back (except pulling the latest InvenTree development version as I mentioned). But obviously I have done something that removed poppler-utils and it was just a coincidence that @cabottech opened this issue the same day I found out that my printer did no longer work. Anyway, my problem is solved,

cabottech commented 1 year ago

@cabottech the background worker thread must be operational for printing to work - if it is up, there should be a log message here?

Ohhh, I completely missed that!

I found this in the log for the 'inventree-worker' docker container when attempting another print:

Plugin registry has no record of plugin 'brother'
Could not find matching plugin for 'brother'

This lead me down a rabbit hole, but I found the issue was that the inventree-worker docker container didn't have INVENTREE_PLUGINS_ENABLED: true! I'm sure I set this, and then found that changing environmental variables is broken for Portainer on Synology. So I had to set that manually and it all works now.

Sorry for the run around, and thank you for the excellent plugin :)