error loading email_adj plugin - Printable Version +- SIP (https://nosack.com/sipforum) +-- Forum: SIP (Sustainable Irrigation Platform) (https://nosack.com/sipforum/forumdisplay.php?fid=1) +--- Forum: Plugin questions (https://nosack.com/sipforum/forumdisplay.php?fid=6) +--- Thread: error loading email_adj plugin (/showthread.php?tid=258) |
error loading email_adj plugin - paul - 2021 Sep 23 Hi Dan, I couldn't get eamil_adj plug-in to load properly. Here is the error message when I start sip.py manually (after turning off sip3.service): pi@comitup-580:~/SIP $ sudo python3 sip.py ... Ignoring exception while loading the email_adj plug-in. cannot import name 'Encoders' from 'email' (/usr/lib/python3.7/email/__init__.py) Also, the pressure_adj plugin does not load, for a different reason: ... Ignoring exception while loading the pressure_adj plug-in. No module named 'ospi' Regard, Paul RE: error loading email_adj plugin - dan - 2021 Sep 23 The pressure_adj plugin has not been updated in a long time. ospi was the original name for SIP. You would need to change any reference to ospi to sip in the plugin. But that might not be the only problem. Not sure about the email plugin problem I'll take a look when I get time. It may be a Python 2 > 3 problem. Dan RE: error loading email_adj plugin - dan - 2021 Sep 23 Looks like the Encoders import should be: Code: from email import encoders https://docs.python.org/3/library/email.encoders.html You also need to change # from email.MIMEMultipart import MIMEMultipart # from email.MIMEBase import MIMEBase # from email.MIMEText import MIMEText to from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText Dan RE: error loading email_adj plugin - paul - 2021 Sep 23 (2021 Sep 23, 02:25 PM)dan Wrote: Looks like the Encoders import should be: Thanks Dan, I tried your changes and the plugin now loads properly. Unfortunately I failed the send-email test, with this message appearing in the status box: "Email was not sent! E-mail plug-in is not properly configured!" I checked my gmail setup by following this link below to check against 3 possible errors:
My login credential is correct. I have to set up POP/IMAP and make sure it is not locked. Still, I can't pass the send-email test. At this point, I am not sure if the problem is with my gmail account setup or with the plugin setup. Manually run "sudo python3 sip.py" indicates the plugin now starts fine: "Email plugin is started" -- which is progress. Regards, paul RE: error loading email_adj plugin - paul - 2021 Sep 24 I found the problem: Error: " 'dict' object has no attribute 'iteritems' " iteritems() must be changed to items() in python3. This change will fix the error for both email_adj.py and pressure_adj.py plugins. But sms_adj.py and telegramBot.py still don't load after the fix above. As a head-up, other files also need to be updated. Below are candidates for updating: pi@comitup-580:~/SIP $ grep -rw "iteritems" * Binary file plugins/__pycache__/pump_control.cpython-37.pyc matches plugins/pump_control.py: for key, value in file_data.iteritems(): plugins/telegramBot.py: for key, value in file_data.iteritems(): plugins/sms_adj.py: for key, value in file_data.iteritems(): plugins/pressure_adj.py: for key, value in file_data.iteritems(): six.py: def iteritems(d, **kw): six.py: def iteritems(d, **kw): six.py: return d.iteritems(**kw) six.py:_add_doc(iteritems, web/debugerror.py:$ newctx = [(k, v) for (k, v) in ctx.iteritems() if not k.startswith('_') and not isinstance(v, dict)] web/template.py: self.iteritems = iter(items) web/template.py: return next(self.iteritems) Binary file web/__pycache__/application.cpython-37.pyc matches Binary file web/__pycache__/py3helpers.cpython-37.pyc matches Binary file web/__pycache__/debugerror.cpython-37.pyc matches Binary file web/__pycache__/utils.cpython-37.pyc matches Binary file web/__pycache__/session.cpython-37.pyc matches Binary file web/__pycache__/template.cpython-37.pyc matches Binary file web/__pycache__/db.cpython-37.pyc matches Binary file web/__pycache__/http.cpython-37.pyc matches web/utils.py: iteritems, web/utils.py: for (key, value) in iteritems(defaults): web/utils.py: return [k for k, v in iteritems(self) if v == m] web/utils.py: return [k for k, v in iteritems(self) if v == m] web/utils.py: return dict([(value, key) for (key, value) in iteritems(mapping)]) web/utils.py: for (key, value) in iteritems(dictionary): web/utils.py: for (key, value) in iteritems(dictionary): web/utils.py: >>> for t, v in iteritems({ web/utils.py: for (key, value) in iteritems(context): web/utils.py: for (key, value) in iteritems(results): web/utils.py: def iteritems(self): web/utils.py: return iteritems(self.__dict__) web/utils.py: for (key, value) in iteritems(locals): web/utils.py: for k, v in iteritems(self.headers): web/application.py:from .py3helpers import PY2, is_iter, iteritems, string_types web/application.py: for k, v in iteritems(ctx): web/session.py:from .py3helpers import PY2, iteritems web/session.py: for k, (atime, value) in iteritems(self.d_store): web/http.py:from .py3helpers import iteritems, numeric_types web/http.py: for k, v in iteritems(kw): web/db.py:from .py3helpers import PY2, iteritems, numeric_types, string_types, text_type web/db.py: for k, v in sorted(iteritems(where), key=lambda t: t[0]): web/py3helpers.py: iteritems = lambda d: d.iteritems() web/py3helpers.py: iteritems = lambda d: iter(d.items()) Perhaps py3helper.py above takes care of this problem already via: iteritems = lambda d: iter(d.items()) (2021 Sep 23, 02:25 PM)dan Wrote: Looks like the Encoders import should be: Hi Dan, The deprecated "Encoders" show up in two places in email_adj.py: The second instance is at line # 234: Encoders.encode_base64(part) RE: error loading email_adj plugin - dan - 2021 Sep 25 Interesting. Thanks for the feedback. The references to web/* are for the last version of web.py that runs under both Python 2 and 3. The most recent version is Python3 only. The reason SIP is still using the older version is that Pi OS is still running Python2.7 as default. Once the OS runs Python3 as default SIP will be upgraded to Python3 only and Web.py will be upgraded to the latest version. If you are running SIP on Python3 you could try using the latest web.py: https://github.com/webpy/webpy/releases Also Six.py is a Python2 to 3 compatibility module that SIP uses to be able to run under both versions of Python. For the plugins, I will take a look at updating them to run on Python2 and 3 for now. I think the email plugin should have a full re-write to bring it up to Python3 standards. Perhaps keeping the current version for anyone using Python2.7 and a separate Python3 version. Dan |