jneilliii / OctoPrint-UltimakerFormatPackage

GNU Affero General Public License v3.0
30 stars 7 forks source link

Some `.ufp` might not contain thumbnails #36

Closed ayufan closed 3 years ago

ayufan commented 3 years ago

Some gcodes uploaded from Cura might not contain thumbnails. Without this it will result in 500 Internal Server Error.

This results in:

2021-02-03 21:58:52,183 - octoprint.filemanager - ERROR - Error when calling preprocessor hook for plugin UltimakerFormatPackage, ignoring
Traceback (most recent call last):
  File "/opt/octoprint/.local/lib/python3.7/site-packages/octoprint/filemanager/__init__.py", line 718, in add_file
    allow_overwrite=allow_overwrite,
  File "/opt/octoprint/.local/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1890, in wrapper
    return f(*args, **kwargs)
  File "/opt/octoprint/.local/lib/python3.7/site-packages/octoprint_ultimakerformatpackage/__init__.py", line 226, in ufp_upload
    thumbnail.write(zipObj.read("/Metadata/thumbnail.png"))
  File "/usr/lib/python3.7/zipfile.py", line 1428, in read
    with self.open(name, "r", pwd) as fp:
  File "/usr/lib/python3.7/zipfile.py", line 1467, in open
    zinfo = self.getinfo(name)
  File "/usr/lib/python3.7/zipfile.py", line 1395, in getinfo
    'There is no item named %r in the archive' % name)
KeyError: "There is no item named '/Metadata/thumbnail.png' in the archive"

NOTICE: I still need to test exactly this change on Octoprint :)

jneilliii commented 3 years ago

This change makes sense, and thank you for the contribution. I'm curious though how you can create a ufp format file without the thumbnail to test?

ayufan commented 3 years ago

Use raw gcode instead of slicing stl.

On Wed, 3 Feb 2021 at 22:20, jneilliii notifications@github.com wrote:

This change makes sense, and thank you for the contribution. I'm curious though how you can create a ufp format file without the thumbnail to test?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jneilliii/OctoPrint-UltimakerFormatPackage/pull/36#issuecomment-772831857, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASOSQPGNRRK43ZDG3FLYD3S5G43JANCNFSM4XBSGOTQ .

jneilliii commented 3 years ago

Oh interesting, I'd never even thought about that since I don't use Cura for gcode viewing. I'll test it out and verify your changes don't break anything and merge in.

jneilliii commented 3 years ago

Thanks again @ayufan, I've merged your changes into the rc branch and have an 0.2.2rc1 release available for testing. I don't see any issues so far and was able to load a gcode into Cura and send to octoprint directly and did not get the internal server error, so I think this may have fixed it. If you want to test out yourself to verify you can change the release channel in OctoPrint's Software Update settings to Release Candidate and you should get an update notification for this version.

ayufan commented 3 years ago

@jneilliii It crashed for me, but for another reason a null instead of None. As I said I did not test it yet, I did test it now :)

ayufan commented 3 years ago

@jneilliii You might not have seen that, as the newest Octoprint Plugin does fix that as well, to send gcode instead of ufp if this is raw gcode. However, there are random cases where even STL would not generate thumbnail. So, this fix is still applicable.

https://github.com/fieldOfView/Cura-OctoPrintPlugin/pull/196

jneilliii commented 3 years ago

new changes merged and rc2 ready for verification.

ayufan commented 3 years ago

@jneilliii I tested them. They do work just fine :) Thank you :)