wolflu05 / inventree-dymo-plugin

Dymo Label printer driver plugin for InvenTree.
GNU General Public License v3.0
1 stars 1 forks source link

Printing issues #5

Open HannesMorre opened 1 week ago

HannesMorre commented 1 week ago

When we try to print using this plugin, we get the following logs:

inventree-worker  | Failed '<bound method DymoLabelPrinterDriver.print_labels of <inventree_dymo.InvenTreeDymoPlugin.DymoLabelPrinterDriver object at 0x7ff97cef1bd0>>' (video-leopard-jupiter-jig) - '' : Traceback (most recent call last):
inventree-worker  |   File "/root/.local/lib/python3.11/site-packages/django_q/worker.py", line 97, in worker
inventree-worker  |     res = f(*task["args"], **task["kwargs"])
inventree-worker  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
inventree-worker  |   File "/usr/local/lib/python3.11/site-packages/inventree_dymo/InvenTreeDymoPlugin.py", line 104, in print_labels
inventree-worker  |     density=PrintDensity[machine.get_setting('DENSITY', 'D')],
inventree-worker  |             ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
inventree-worker  |   File "/usr/local/lib/python3.11/enum.py", line 792, in __getitem__
inventree-worker  |     return cls._member_map_[name]
inventree-worker  |            ~~~~~~~~~~~~~~~~^^^^^^
inventree-worker  | KeyError: ''
inventree-worker  | 
wolflu05 commented 1 week ago

Hey @HannesMorre ,

can you please provide your inventree version you're using, and a screenshot of how you configured the printer machine? And do you have explicitly configured/touched the density setting for that machine?

HannesMorre commented 4 days ago

Here is the version information:

# Version Information:
InvenTree-Version: 0.16.1
Django Version: 4.2.15
Commit Hash: 4c15e5c
Commit Date: 2024-08-30

Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.1.0-23-amd64-x86_64-with
Installer: DOC

These are the machine settings: image

This is the pop-up we get when we try to print from the platform UI: image

Nothing is printed despite the "Success" notification

wolflu05 commented 4 days ago

Hi @HannesMorre

The Error message you are seeing is currently actually expected for physical printers, as they run in the background and return a completed: false. This is still WIP on the inventree side in PUI, but should not block you from printing. Ref: https://github.com/InvenTree/InvenTree/blob/d59ce49d8230ad8036fae10b0f46a0d352ebfc56/src/frontend/src/components/buttons/PrintingActions.tsx#L103-L111

It seems that the "Print Mode" and "Print Density" settings were not set somehow by their defaults. I have tried to reproduce this on a fresh docker setup using inventree/inventree:0.16.1, but I'm not able to do so. So I have a few ideas you could try:

  1. Make sure you have a Redis cache configured, as machines will only work with a Redis cache
  2. Try creating a new machine and see if those two settings are configured then? By default they should be density: Normal a mode:TEXT.
  3. If that still does not work, try to set them manually to their default (Normal and Text)
  4. If that error from your initial comment (KeyError: '') is not present anymore, but there is still nothing printed make sure that you can reach your printer server 172.16.128.20 from within the container. (docker exec -it <worker-container> ash and then try ping 172.16.128.20) Maybe your docker network uses the same network as your local network .
  5. Try running a netcat server in your worker container via docker exec -it <worker-container> ash and then nc -l -p 9100. Then you need to configure the printing machine to use localhost and port 9100. When printing, this should output something. You can even check if it outputs something correct by running nc -l -p 9100 > test.bin, print again, and then python /usr/local/lib/python3.11/site-packages/inventree_dymo/dymo_to_png.py test.bin text. If you see an image with lots of # and ` and no error, everything worked fine. (You may need to disable line wrap and zoom out of your terminal). (FYI, if you want an png image, you need to change the last line of that python script fromout.show()toout.save("/tmp/img.png")and run withpython dymo_to_png.py test.bin image`).
  6. If nothing helps, please enable debug mode and provide any log output you can get from the worker and server container
  7. which plugin version are you running?