jneilliii / OctoPrint-PrintScheduler

MIT License
10 stars 2 forks source link

Saving not working #8

Closed elpeter25 closed 3 years ago

elpeter25 commented 3 years ago

Hi,

I'm facing issues when try to use the plugin. I set the print date and time and when I press save the list is cleared. This is what's in the log:

2021-08-27 17:15:27,742 - octoprint.plugins.printscheduler - DEBUG - Looping through scheduled jobs. 2021-08-27 17:15:40,576 - octoprint.plugins.printscheduler - DEBUG - Sorthing scheduled jobs from: [{'name': 'Print7-Interior-3-_0.15mm_PLA_0.15mm_PLA_MINI_3h45m.gcode', 'path': 'Buggy/Print7-Interior-3-_0.15mm_PLA_0.15mm_PLA_MINI_3h45m.gcode', 'start_at': '2021-08-28 00:05'}]. 2021-08-27 17:15:40,577 - octoprint.server.api.settings - ERROR - Could not save settings for plugin Print Scheduler (0.0.2) Traceback (most recent call last): File "/home/octoprint/python_venvs/octoprint3/lib/python3.6/site-packages/octoprint/server/api/settings.py", line 1074, in _saveSettings plugin.on_settings_save(data["plugins"][plugin_id]) File "/home/octoprint/python_venvs/octoprint3/lib/python3.6/site-packages/octoprint/util/init.py", line 1941, in wrapper return f(*args, **kwargs) File "/home/octoprint/python_venvs/octoprint3/lib/python3.6/site-packages/octoprint_printscheduler/init.py", line 94, in on_settings_save data["scheduled_jobs"].sort(key=lambda item: datetime.fromisoformat(item.get("start_at"))) File "/home/octoprint/python_venvs/octoprint3/lib/python3.6/site-packages/octoprint_printscheduler/init.py", line 94, in data["scheduled_jobs"].sort(key=lambda item: datetime.fromisoformat(item.get("start_at"))) AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat' 2021-08-27 17:16:27,744 - octoprint.plugins.printscheduler - DEBUG - Looping through scheduled jobs.

OctoPrint 1.6.1
Python 3.6.9

Thanks in advance!!

jneilliii commented 3 years ago

Interesting. Is your octoprint installation manually installed or an upgrade from python 2?

jneilliii commented 3 years ago

I can confirm, it seems that this is a python version issue. The fromisoformat method was added in python 3.7, which is part of the octopi 0.18 image by default. I will need to adjust my plugin requirements as a result of that. Best I can recommend is that you create a backup of OctoPrint and download it to your computer, re-flash octopi with the 0.18 image from this release version's assets linked below and then restore the backup during initial setup wizard.

https://github.com/OctoPrint/OctoPi-UpToDate/releases/tag/0.18.0.op1.6.1

jneilliii commented 3 years ago

It's possible I'll be able to back-port the required function into the plugin directly to support older python versions, but will take some time and testing. Leaving this here for reference later when I have time to work on it, otherwise the steps mentioned before would get you where you need to do.

https://github.com/python/cpython/blob/28db1f61f20352c02e4ae1518e5aeb6505df3045/Lib/datetime.py#L1720-L1743

jneilliii commented 3 years ago

I think I have this fixed in the above commit and available as version 0.0.3rc1. To verify for me if you could change the plugin's release channel to Release Candidate in OctoPrint's Software Update settings and upgrade when prompted that would be great.

elpeter25 commented 3 years ago

Works like a charm!! Thank you so so much for all the work and specially for creating this plugin!! It's awesome!!!

Cheers!