-
-
Notifications
You must be signed in to change notification settings - Fork 33
Initial Implementation of Thumbnail Parsing #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
Eh, thought I'd be able to make 2 separate pull requests. Guess not... 🤦♂️ I went ahead and fixed the color parameter issue mentioned in #219. It now supports both an integer value and a string. |
I think you can do that, but its not easy with github. If you create a new branch for each feature you want to pull request that usually works. |
| # Attempt to parse potential thumbnail | ||
| if event_id == "printing_started" and self.get_gcode_format(data["path"]): | ||
| self._logger.info("Print appears to have a thumbnail, trying to parse") | ||
| print_thumbnail = self.get_thumbnail_cura(data["path"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialise print_thumbnail to None at the start of this function, otherwise it will cause unbound errors like:
Traceback (most recent call last):
File "/home/cameron/Projects/OctoPrint-DiscordRemote-Dealman/testenv/lib/python3.10/site-packages/octoprint/plugin/__init__.py", line 273, in call_plugin
result = getattr(plugin, method)(*args, **kwargs)
File "/home/cameron/Projects/OctoPrint-DiscordRemote-Dealman/testenv/lib/python3.10/site-packages/octoprint/util/__init__.py", line 1694, in wrapper
return f(*args, **kwargs)
File "/home/cameron/Projects/OctoPrint-DiscordRemote-Dealman/octoprint_discordremote/__init__.py", line 311, in on_event
return self.notify_event("startup")
File "/home/cameron/Projects/OctoPrint-DiscordRemote-Dealman/octoprint_discordremote/__init__.py", line 462, in notify_event
return self.send_message(event_id, tmp_config["message"].format(**data), tmp_config["with_snapshot"], print_thumbnail)
UnboundLocalError: local variable 'print_thumbnail' referenced before assignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like:
# Attempt to parse potential thumbnail
print_thumnail = None
if event_id == "printing_started" and self.get_gcode_format(data["path"]):
self._logger.info("Print appears to have a thumbnail, trying to parse")
print_thumbnail = self.get_thumbnail_cura(data["path"])
Huh, I was trying this since I saw you pre-defined Either way, simple fix! 👍
Most certainly, this is something I was considering myself. But how should the logic work if both options are toggled since AFAIK we can only embed one image? One workaround I can think of would be to use 3x radio buttons; |
That sounds like a reasonable solution. |
b3800b9 to
eb986ae
Compare
6b6a3bc to
9653879
Compare
|
Any updates on this. I think this would be neat to have on the print start. |
|
No update, probably still needs some work to get this into a mergable
state. I havent had time to work on it (was kinda hoping someone else would
do it :/ )
…On Tue, 19 Sept 2023, 6:32 am Manichee, ***@***.***> wrote:
Any updates on this. I think this would be neat to have on the print start.
—
Reply to this email directly, view it on GitHub
<#231 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAK7FL7RPWB5TISQZLGJKFLX3CVVVANCNFSM6AAAAAASM2CUMU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Sadly no, my printer has been out of commission for a while and haven't had the energy to fix it. So haven't found much reason to continue working on this. As far as I can recall, it does work with thumbnails generated by Cura, it's just a simple Base64 encoding. My issue was the whole web development side of things, a combination of wrapping my head around how If anyone ever picks up on this, here's how I imagine things should go;
I never got around to verifying I still want to fix my printer, just need to find the time and energy to do so. Once I get it all back up and running, I might return to finally try and implement this properly - unless someone else manages to do so before me. 😃 👍 |

If the
with_snapshotoption forprinting_startedisFalse, it will now try and parse the GCODE for a thumbnail. So far, this is only tested with models sliced using Ultimaker Cura.I wanted to contain this in a separate script to keep the
__init__clean from changes, but I was unable to get it to work due to the file manager. No idea how that thing works, but it will not work in a standalone script, only in__init__.This most definitely will need some work to support other formats, this could be a very good reference.
Will need some examples and I'll add them myself, to ensure they work. Might ask on some subreddit if I can get some examples.
I've tested with a few various sliced models of my own and it seems to be solid enough. And if it fails to parse the thumbnail, it's caught and
snapshotwill beNone- in other words, no embedded image.