caronc / nzb-notify

Push Notifications to a large number of supported services for NZBGet and SABnzbd (based on Apprise)
GNU General Public License v3.0
129 stars 16 forks source link

Error with sabnzbd + docker #47

Closed Diegus83 closed 5 years ago

Diegus83 commented 5 years ago

I recently installed the docker container for linuxserver/sabnzbd in a Mac OS host and I haven't been able to make the script work.

I'm trying to use ifttt but I think the error is independent of that. I think it may be related to missing dependencies but it was my understanding that all the necessary components were in the Notify folder.

My scripts folder contains sabnzbd-notify.py, Notify.py and Notify folder.

In sabnzbd I select sabnzbd-notify.py under Script and ifttt://xxxxxxxxxxx/sabnzbd/ in parameters (with the actual key) and this is the error generated when I hit Test Notification

Notification script returned exit code 1 and output "Traceback (most recent call last): File "/config/scripts/Notify.py", line 416, in from apprise import Apprise File "/config/scripts/Notify/apprise/init.py", line 31, in from .plugins.NotifyBase import NotifyBase File "/config/scripts/Notify/apprise/plugins/init.py", line 23, in from .NotifyBoxcar import NotifyBoxcar File "/config/scripts/Notify/apprise/plugins/NotifyBoxcar.py", line 20, in import requests File "/config/scripts/Notify/requests/init.py", line 53, in from urllib3.contrib import pyopenssl File "/config/scripts/Notify/urllib3/contrib/pyopenssl.py", line 53, in import OpenSSL.SSL File "/config/scripts/Notify/OpenSSL/init.py", line 8, in from OpenSSL import crypto, SSL File "/config/scripts/Notify/OpenSSL/SSL.py", line 115, in if _lib.Cryptography_HAS_SSL_ST: AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST' "

Thanks in advance!

caronc commented 5 years ago

Try deleting the directory /config/scripts/Notify/OpenSSL and give it another shot.

Diegus83 commented 5 years ago

Thanks. Did that and now I get a green Notification Sent! in the web interface of sabnzbd, but I'm not seeing any activity on ifttt side. So I tried manually running the script like this

python sabnzbd-notify.py complete 'Hello' 'World' ifttt://xxxxxx/sabnzbd

And I'm getting this output in the CLI

ERROR:root:Failed to load notification url: ifttt://xxxxxx/sabnzbd
2019-01-23 14:23:40,947 - 592 - ERROR - Could not initialize ifttt://xxxxxx/sabnzbd instance.
ERROR:nzbget.ScriptBase:Could not initialize ifttt://xxxxxx/sabnzbd instance.

I also verified that the key and event name are correct using curl and seeing the event pop up on IFTTT

Thanks for your help.

caronc commented 5 years ago

I will hopefully have a chance to look further into this for you on the weekend. It might be related to the way the ifttt:// URL is being constructed (see https://github.com/caronc/nzb-notify/wiki/Notify_ifttt).

Could you run the same command (from the command line) with the -D switch (for extra debugging) and share the details?

Diegus83 commented 5 years ago

Thanks for your time!

Here is command I ran and the output:

python Notify.py -D -s ifttt://xxxxxxxxxxxxxxxxx -t "Hello" -b "World!"
2019-01-24 09:33:52,103 - 304 - DEBUG - Script Mode: shell
2019-01-24 09:33:52,108 - 304 - DEBUG - Python v2.7.12
2019-01-24 09:33:52,116 - 304 - DEBUG - OS: Linux 4.9.125-linuxkit
2019-01-24 09:33:52,119 - 304 - DEBUG - get(default) SERVERS=None
2019-01-24 09:33:52,120 - 304 - DEBUG - set(config) SERVERS="ifttt://xxxxxxxxxxxxxxxxx"
2019-01-24 09:33:52,121 - 304 - DEBUG - set(environment) SERVERS="ifttt://xxxxxxxxxxxxxxxxx"
2019-01-24 09:33:52,122 - 304 - DEBUG - get(default) TITLE=None
2019-01-24 09:33:52,122 - 304 - DEBUG - set(config) TITLE="Hello"
2019-01-24 09:33:52,123 - 304 - DEBUG - set(environment) TITLE="Hello"
2019-01-24 09:33:52,124 - 304 - DEBUG - get(default) BODY=None
2019-01-24 09:33:52,124 - 304 - DEBUG - set(config) BODY="World!"
2019-01-24 09:33:52,124 - 304 - DEBUG - set(environment) BODY="World!"
2019-01-24 09:33:52,125 - 304 - DEBUG - get(default) INCLUDEIMAGE=None
2019-01-24 09:33:52,126 - 304 - DEBUG - get(config) SERVERS="ifttt://xxxxxxxxxxxxxxxxx"
2019-01-24 09:33:52,126 - 304 - DEBUG - get(config) TITLE="Hello"
2019-01-24 09:33:52,127 - 304 - DEBUG - get(config) BODY="World!"
2019-01-24 09:33:52,127 - 304 - DEBUG - get(default) INCLUDEIMAGE=None
2019-01-24 09:33:52,128 - 304 - DEBUG - get(default) INCLUDEIMAGE=None
2019-01-24 09:33:52,128 - 304 - DEBUG - get(config) SERVERS="ifttt://xxxxxxxxxxxxxxxxx"
ERROR:root:Failed to load notification url: ifttt://xxxxxxxxxxxxxxxxx
2019-01-24 09:33:52,131 - 304 - ERROR - Could not initialize ifttt://xxxxxxxxxxxxxxxxx instance.
ERROR:nzbget.ScriptBase:Could not initialize ifttt://xxxxxxxxxxxxxxxxx instance.
2019-01-24 09:33:52,132 - 304 - DEBUG - Exiting with return code: 0
DEBUG:nzbget.ScriptBase:Exiting with return code: 0

Meanwhile I have Apprise running in a separate container with no issues so I'm experimenting on how to let other containers communicate with it to send notifications.

caronc commented 5 years ago

Really? so it works okay with apprise when you use it on it's own? Hmm... :thinking:

I wonder if the extra libraries i package with nzb-notify are causing you issues? I'm thinking perhaps I should just dump all of the shared libraries and provide a requirements.txt? You could try deleting some of the folders in the NZBNotify directory and performing a pip install for each one you do this to. It may or may not help; NZBNotify merely just wraps apprise anyway.

Is the systems that have the working apprise and dead NZBNotify the same? Same OS? Same Python version? Or are they installed on separate machines and/or Docker containers?

Diegus83 commented 5 years ago

What I did is started a new container with alpine and python 2.7, put apprise in that container, and it works as expected, just wanted to make sure my key and event values where correct.

When I try to use the script with the linuxserver/sabnzbd container, that's where it is not working.

I could try running pip install in the sabnzbd container and see what happens.

Since I have several containers running I was hoping to keep a single instance of the script in shared volume and not having to install it for each instance.

caronc commented 5 years ago

Since I have several containers running I was hoping to keep a single instance of the script in shared volume and not having to install it for each instance.

This is totally what i would want for you too. It shouldn't be cumbersome in any way. :slightly_smiling_face:; I'm just trying to isolate the issue. I'll set up my test ifttt account again and keep you posted on what i find. Hopefully it's just something simple!

caronc commented 5 years ago

Could you try it again but use the @ symbol instead of a slash to delimit the api key from the applet name?

So:

python Notify.py -D -s ifttt://token@applet -t "Hello" -b "World!"

I'm just curious if you get the expected results

Diegus83 commented 5 years ago

Ok, I did a clean pull of the script and ran python Notify.py -D -s ifttt://token@applet -t "Hello" -b "World!" and it failed with the message

Traceback (most recent call last):
  File "Notify.py", line 416, in <module>
    from apprise import Apprise
  File "/config/scripts/Notify/apprise/__init__.py", line 31, in <module>
    from .plugins.NotifyBase import NotifyBase
  File "/config/scripts/Notify/apprise/plugins/__init__.py", line 23, in <module>
    from .NotifyBoxcar import NotifyBoxcar
  File "/config/scripts/Notify/apprise/plugins/NotifyBoxcar.py", line 20, in <module>
    import requests
  File "/config/scripts/Notify/requests/__init__.py", line 53, in <module>
    from urllib3.contrib import pyopenssl
  File "/config/scripts/Notify/urllib3/contrib/pyopenssl.py", line 53, in <module>
    import OpenSSL.SSL
  File "/config/scripts/Notify/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/config/scripts/Notify/OpenSSL/SSL.py", line 115, in <module>
    if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

But if I delete the /config/scripts/Notify/OpenSSL folder and try again...

2019-01-26 14:26:53,375 - 403 - DEBUG - Script Mode: shell
2019-01-26 14:26:53,375 - 403 - DEBUG - Python v2.7.12
2019-01-26 14:26:53,382 - 403 - DEBUG - OS: Linux 4.9.125-linuxkit
2019-01-26 14:26:53,385 - 403 - DEBUG - get(default) SERVERS=None
2019-01-26 14:26:53,386 - 403 - DEBUG - set(config) SERVERS="ifttt://xxxxxxxxxxxxx@sabnzbd"
2019-01-26 14:26:53,387 - 403 - DEBUG - set(environment) SERVERS="ifttt://xxxxxxxxxxxxx@sabnzbd"
2019-01-26 14:26:53,387 - 403 - DEBUG - get(default) TITLE=None
2019-01-26 14:26:53,388 - 403 - DEBUG - set(config) TITLE="Hello"
2019-01-26 14:26:53,389 - 403 - DEBUG - set(environment) TITLE="Hello"
2019-01-26 14:26:53,389 - 403 - DEBUG - get(default) BODY=None
2019-01-26 14:26:53,390 - 403 - DEBUG - set(config) BODY="World!"
2019-01-26 14:26:53,390 - 403 - DEBUG - set(environment) BODY="World!"
2019-01-26 14:26:53,391 - 403 - DEBUG - get(default) INCLUDEIMAGE=None
2019-01-26 14:26:53,392 - 403 - DEBUG - get(config) SERVERS="ifttt://xxxxxxxxxxxxx@sabnzbd"
2019-01-26 14:26:53,393 - 403 - DEBUG - get(config) TITLE="Hello"
2019-01-26 14:26:53,394 - 403 - DEBUG - get(config) BODY="World!"
2019-01-26 14:26:53,395 - 403 - DEBUG - get(default) INCLUDEIMAGE=None
2019-01-26 14:26:53,396 - 403 - DEBUG - get(default) INCLUDEIMAGE=None
2019-01-26 14:26:53,397 - 403 - DEBUG - get(config) SERVERS="ifttt://xxxxxxxxxxxxx@sabnzbd"
2019-01-26 14:26:53,399 - 403 - DEBUG - IFTTT POST URL: https://maker.ifttt.com/trigger/sabnzbd/with/key/xxxxxxxxxxxxx (cert_verify=True)
2019-01-26 14:26:53,399 - 403 - DEBUG - IFTTT Payload: {'value3': 'info', 'value2': 'World!', 'value1': 'Hello'}
2019-01-26 14:26:53,655 - 403 - DEBUG - IFTTT HTTP response status: 200
2019-01-26 14:26:53,655 - 403 - DEBUG - IFTTT HTTP response headers: {'Content-Length': '47', 'Server': 'web_server', 'X-Top-SecreTTT': '/==', 'Connection': 'keep-alive', 'Date': 'Sat, 26 Jan 2019 19:26:53 GMT', 'Content-Type': 'text/html; charset=utf-8'}
2019-01-26 14:26:53,656 - 403 - DEBUG - IFTTT HTTP response body: "Congratulations! You've fired the sabnzbdevent"
2019-01-26 14:26:53,657 - 403 - INFO - Sent IFTTT notification to Event sabnzbd.
2019-01-26 14:26:53,660 - 403 - DEBUG - Exiting with return code: 0

Success!

I tried to run 'pip freeze' in the container to see what is installed but pip is not part of the install. Also I could verify the container has OpenSSL 1.0.2g 1 Mar 2016 installed.

caronc commented 5 years ago

I'm glad you got it going.

The big issue in your case is OpenSSL is always evolving (and as it should to keep up with exploits). But as it evolved it became very incompatible with it's older python libraries (which i include here).

It's a bit of a catch 22 as if i include the newest SSL python libraries, they are completely broken with the older versions of OpenSSL. So no matter what, a chunk of people lose. :roll_eyes: .

I'm going to have to re-think how i package all of the dependencies in this product. I'm thinking it might be better if i just drop them all together and force users of the script have to manually fetch them via pip.

keppo070 commented 5 years ago

Try deleting the directory /config/scripts/Notify/OpenSSL and give it another shot.

This solved the issue for me as well. Thank you!

caronc commented 5 years ago

I've updated the source code to drop all reference to all of the libraries.

This will allow the product to be compatible with everyone who uses it (including all future docker containers). The only thing is the docker-compose files will need to be updated to do the following to ensure the dependencies are present.

# haul in the dependencies:
pip install -i requirements.txt

I'm going to close off this ticket now! :slightly_smiling_face: