mqtt-tools / mqttwarn

A highly configurable MQTT message router, where the routing targets are notification plugins, primarily written in Python.
https://mqttwarn.readthedocs.io/
Eclipse Public License 2.0
950 stars 183 forks source link

Docker issue with pushbullet (mqttwarn-full) #675

Closed DNicholai closed 8 months ago

DNicholai commented 1 year ago

I'm having an issue with the pushbullet plugin running on docker - I'm using the full version with all plugins.

Docker version is : 19.03.15, build 99e3ed8919

I'm launching docker using the following command:

sudo docker run -it --rm --volume=$PWD:/etc/mqttwarn --volume=$PWD/log:/log ghcr.io/mqtt-tools/mqttwarn-full:latest 

And the output from terminal is as follows:

2023-05-21 18:09:32,292 INFO     [mqttwarn.commands         ] Starting mqttwarn
2023-05-21 18:09:32,293 INFO     [mqttwarn.commands         ] Log level is DEBUG
2023-05-21 18:09:32,294 DEBUG    [mqttwarn.core             ] Trying to load built-in service "file" from "file"
2023-05-21 18:09:32,296 DEBUG    [mqttwarn.core             ] Trying to load service "file" from file "/usr/local/lib/python3.11/site-packages/mqttwarn/services/file.py"
2023-05-21 18:09:32,297 INFO     [mqttwarn.core             ] Successfully loaded service "file"
2023-05-21 18:09:32,298 DEBUG    [mqttwarn.core             ] Trying to load built-in service "log" from "log"
2023-05-21 18:09:32,299 DEBUG    [mqttwarn.core             ] Trying to load service "log" from file "/usr/local/lib/python3.11/site-packages/mqttwarn/services/log.py"
2023-05-21 18:09:32,300 INFO     [mqttwarn.core             ] Successfully loaded service "log"
2023-05-21 18:09:32,301 DEBUG    [mqttwarn.core             ] Trying to load built-in service "pushbullet" from "pushbullet"
2023-05-21 18:09:32,302 DEBUG    [mqttwarn.core             ] Trying to load service "pushbullet" from file "/usr/local/lib/python3.11/site-packages/mqttwarn/services/pushbullet.py"
2023-05-21 18:09:32,307 ERROR    [mqttwarn.core             ] Loading service "pushbullet" from file "/usr/local/lib/python3.11/site-packages/mqttwarn/services/pushbullet.py" failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/mqttwarn/core.py", line 603, in load_services
    service_plugins[service]["module"] = load_module_from_file(modulefile)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mqttwarn/util.py", line 138, in load_module_from_file
    return imp.load_source(digest, path, fp)  # type: ignore[arg-type]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/imp.py", line 172, in load_source
    module = _load(spec)
             ^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 721, in _load
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/lib/python3.11/site-packages/mqttwarn/services/pushbullet.py", line 8, in <module>
    from pushbullet.pushbullet import PushBullet
  File "/usr/local/lib/python3.11/site-packages/pushbullet/pushbullet.py", line 36, in <module>
    from urlparse import urljoin
ModuleNotFoundError: No module named 'urlparse'
2023-05-21 18:09:32,315 CRITICAL [mqttwarn.core             ] Unable to load service "pushbullet"
amotl commented 1 year ago

Dear David,

thanks for reporting this flaw. The error you are demonstrating indicates that the Pushbullet module for mqttwarn might not have been made ready for Python 3 yet. We will have to improve that.

With kind regards, Andreas.

DNicholai commented 1 year ago

Dear Andreas,

Thank you for your quick and informed reply.

I am upgrading the docker version in the hopes that it might bring some (admittedly unexpected) benefit.

In the meantime I'll happily continue using my non-docker based install of mqttwarn which still works great :)

Cdt, David

amotl commented 1 year ago

Hi again,

I've just verified that the underlying PushbulletPythonLibrary package does not support Python 3.

pip install PushbulletPythonLibrary
>>> import pushbullet.pushbullet
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/amo/dev/daq-tools/sources/mqttwarn/.venv311/lib/python3.11/site-packages/pushbullet/pushbullet.py", line 36, in <module>
    from urlparse import urljoin
ModuleNotFoundError: No module named 'urlparse'

In the meantime I'll happily continue using my non-docker based install of mqttwarn which still works great.

Excellent. May I ask if you are still using this in a Python 2 environment - like, what does python -V say?

$ python -V
Python 2.7.16

With kind regards, Andreas.

amotl commented 1 year ago

It will make sense to switch to a more modern client wrapper library, like one of those:

DNicholai commented 1 year ago

Hello again.

Python on the working install (hasn't been updated in a while) is running the following version :

Python 2.7.9

amotl commented 1 year ago

Dear David,

GH-676 will fix the problem by modernizing the Pushbullet service plugin. Major improvements are:

a) Works now with Python 3. b) Will not need any external dependencies, thus will be available through OCI image mqttwarn-standard. c) Now obtains a modern target address descriptor, based on a dictionary instead of a list, see GH-628. [^1]

You will find corresponding examples how to install the preview version within the PR description. We will be happy about corresponding feedback, if that works for you or not.

With kind regards, Andreas.

[^1]: Please note this change retains backwards-compatibility to the previous configuration style, so you should be able to re-use your existing configuration 1:1. However, we encourage to use the modern configuration style, like outlined in the updated documentation.

DNicholai commented 1 year ago

Dear Andreas,

As mentioned in GH-676 -- confirmed as working, thanks so much ^^

Best regards, David

amotl commented 8 months ago

mqttwarn 0.35.0 has been released, including this fix, so I am closing this ticket.