Skip to content
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

Emails not being sent #54

Closed
f0n1x opened this issue Mar 21, 2020 · 5 comments
Closed

Emails not being sent #54

f0n1x opened this issue Mar 21, 2020 · 5 comments

Comments

@f0n1x
Copy link

f0n1x commented Mar 21, 2020

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
Copy link

vaheder commented Mar 31, 2020

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
Copy link

vaheder commented Apr 1, 2020

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
Copy link
Author

f0n1x commented Apr 8, 2020

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
Copy link

vaheder commented Apr 8, 2020

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
Copy link
Author

f0n1x commented Apr 8, 2020

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

@f0n1x f0n1x closed this as completed Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants