anoved / OctoPrint-EmailNotifier

Receive email notifications when OctoPrint jobs are complete. Currently broken. Please fork and fix!
GNU Affero General Public License v3.0
16 stars 35 forks source link

Emails not being sent #54

Closed f0n1x closed 4 years ago

f0n1x commented 4 years ago

Hello,

I am running OctoPrint 1.4.0 on OctoPi 0.17.0 I initially had trouble installing the plugin, but per bibitte's instructions on issue #53, I was able to get it installed an working. I believe that I have the plugin configured correctly as the "Send a test email" works properly and I get the test email in my inbox. However, whenever a print completes, I do NOT get an email, so I was digging through the logs and I see the following:

octoprint.plugin - ERROR - Error while calling plugin emailnotifier Traceback (most recent call last): File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/plugin/init.py", line 224, in call_plugin result = getattr(plugin, method)(*args, **kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_emailnotifier/init.py", line 81, in on_event filename = os.path.basename(payload["file"]) KeyError: 'file'

Seems like some sort of python error. Any help would be much appreciated.

vaheder commented 4 years ago

The problem stems from here, under the PrintDone event: http://docs.octoprint.org/en/master/events/index.html#printing

Deprecated since version 1.3.0:

file: the file’s full path on disk (local) or within its storage (sdcard). To be removed in 1.4.0.

filename: the file’s name. To be removed in 1.4.0.

The payload dictionary no longer has a key file. Given the documentation it looks like you should be able to replace line 49 in init.py (though on my installation it's __init__.py with filename = os.path.basename(payload["path"]). I'm testing this now and will report back if it works at the end of my next print.

vaheder commented 4 years ago

This actually might work for some, but in my case it failed on another deprecated method later on. I tried patching master from the repo, but my environment is an old 2.7 environment, so it failed to install. I'd say give it a shot and see if it works for you.

f0n1x commented 4 years ago

I tested your solution, but it is still throwing the same error, it just says path now instead of file:

File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint/plugin/init.py", line 224, in call_plugin result = getattr(plugin, method)(*args, **kwargs) File "/home/pi/oprint/local/lib/python2.7/site-packages/octoprint_emailnotifier/init.py", line 81, in on_event filename = os.path.basename(payload["path"]) KeyError: 'file'

vaheder commented 4 years ago

Ah no this is because you didn't delete the .pyc file and/or didn't restart Octoprint. It's using the cached/compiled version of the file but showing you the source lines that you modified. You know because the error is still KeyError: 'file', which is no longer on that line.

f0n1x commented 4 years ago

Deleted the .pyc and rebooted. Printed and received an email. Thank you!