caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
12k stars 421 forks source link

Push Safe not "working" #206

Closed mattpackwood closed 4 years ago

mattpackwood commented 4 years ago

:mega: Notification Service(s) Impacted

Push Safe :beetle: **Describe the bug** Error on invocation :bulb: **Screenshots and Logs** Error ERROR:apprise.Apprise:Unsupported schema psafers. ERROR:root:Failed to load notification url: psafers://g-my key-L

:computer: Your System Details:

:crystal_ball: Additional context Add any other context about the problem here.

geeseven commented 4 years ago

psafers://g-my key-L

Does your private_key contain a space?

mattpackwood commented 4 years ago

No

caronc commented 4 years ago

Strange,

I won't be able to peek at this until the weekend. But I'm surprised this isn't working. Furthering some previous question you already answered (having spaces in key), are there dashes or any non-numeric characters in your API key?

mattpackwood commented 4 years ago

Hi,

Here is what I found so far...

I used: apobj.add('psafers://'+secrets['PushSafer_key']) to add a notification in a Python script, the secrets['PushSafer_key'] reads the key from a file so I don't have to have keys on GitHub...

When I run the python script I get: ERROR:root:Failed to load notification url: psafers://gFbub1urUbYKl2sXXXXX

Now, if I have the API running in docker and I run: curl -X POST -d '{"urls": "psafers://gFbub1urUbYKl2sXXXXX", "body":"test message "}' \ -H "Content-Type: application/json" \ http://localhost:9000/notify

The call to the API works fine... The "XXXXX" at the end of my key is to make it harder for someone to guess my key... The key was copy and pasted to make the curl, so that is unlikely to be an issue. The key has no "non-alphanumeric characters"...

The python script runs fine for other services (for example Pushover or Pushbullet)

caronc commented 4 years ago

Hi @mattpackwood,

Sorry for asking the silly questions, i think we got thrown off when you substituted your private key with g-my key-L :slightly_smiling_face: . We're all on the same page now though.

I finally had time to take a look at the issue you're having and I'm unfortunately unable to reproduce it. Here is the pushsafe.cfg file i created:

# pushsafe.cfg (don't' worry; same as you, this key is not valid for purpose
# of git issue example)
psafers://gcabcdefgABCDEFGHIabcDE

Then i ran the following: apprise -vvv -c pushsafe.cfg -b test and got (the expected output):

2020-02-15 15:24:39,609 - DEBUG - Loading configuration: pushsafe.cfg
2020-02-15 15:24:39,611 - DEBUG - Loaded URL: psafers://gcabcdefgABCDEFGHIabcDE/?verify=yes&overflow=upstream&format=text
2020-02-15 15:24:39,611 - INFO - Loaded 1 entries from file://pushsafe.cfg?cache=yes&encoding=utf-8
2020-02-15 15:24:39,611 - DEBUG - PushSafer POST URL: https://www.pushsafer.com/api (cert_verify=True)
2020-02-15 15:24:39,611 - DEBUG - PushSafer Payload: {'c': '#3AA3E3', 'd': 'a', 'i': 25, 'k': u'gcabcdefgABCDEFGHIabcDE', 'm': u'test', 't': ''}
2020-02-15 15:24:40,518 - INFO - Sent PushSafer notification to "a".

I then updated the configuration to make sure the unencrypted version works too:

# pushsafe.cfg (psafer:// vs psafers://)
psafer://gcabcdefgABCDEFGHIabcDE

And once again, i got the expected output:

2020-02-15 15:23:17,332 - DEBUG - Loading configuration: pushsafe.cfg
2020-02-15 15:23:17,334 - DEBUG - Loaded URL: psafer://gcabcdefgABCDEFGHIabcDE/?verify=yes&overflow=upstream&format=text
2020-02-15 15:23:17,334 - INFO - Loaded 1 entries from file://pushsafe.cfg?cache=yes&encoding=utf-8
2020-02-15 15:23:17,334 - DEBUG - PushSafer POST URL: http://www.pushsafer.com/api (cert_verify=True)
2020-02-15 15:23:17,334 - DEBUG - PushSafer Payload: {'c': '#3AA3E3', 'd': 'a', 'i': 25, 'k': u'gcabcdefgABCDEFGHIabcDE', 'm': u'test', 't': ''}
2020-02-15 15:23:17,924 - INFO - Sent PushSafer notification to "a".

Now i presume you're not using the CLI tool and using the Apprise API? I put the same configuration an assigned it to a key and sent a notification without any problems. I'm wondering if you're using an older version of Apprise that simply didn't support PushSafe yet? It's rather new; introduced in v0.8.3? I don't imagine that's possible because when we last spoke, i think you were reloading everything? So anything new you pull down will be 0.8.4.

Thoughts?

mattpackwood commented 4 years ago

Hello @caronc

Visualize my face as a facepalm... Works under Python3, fails under Python2...

Matt

caronc commented 4 years ago

Are you sure it doesn't work in Python 2.7? That is the version I'm testing it on right now (using CentOS 7.x).

mattpackwood commented 4 years ago

I am on MacOS and nope, it only runs under Python3, that is fine for me though...

caronc commented 4 years ago

Hmm,

that concerns me a little bit because i go through great efforts to make sure this library works in both Python v2.7 and Python 3.x. I also can't reproduce your issue in Python 2.7.

On a side note, i am glad you got everything working :slightly_smiling_face: ; I apologize for dragging this thread out. But i would like to ensure it works under all circumstances. Do you have any debug information from a Python v2.x call on your Mac? In the meantime, I'll try to reproduce your environment.

mattpackwood commented 4 years ago

Try this, it seems to be the "bit with errors":

# /Users/mattpackwood/Library/Python/2.7/lib/python/site-packages/apprise/AppriseConfig.pyc matches /Users/mattpackwood/Library/Python/2.7/lib/python/site-packages/apprise/AppriseConfig.py
import apprise.AppriseConfig # precompiled from /Users/mattpackwood/Library/Python/2.7/lib/python/site-packages/apprise/AppriseConfig.pyc
ERROR:root:Failed to load notification url: psafers://gFbub1urUbYKl2XXXX
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.py
import netrc # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/netrc.pyc
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.py
import shlex # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shlex.pyc
# clear __builtin__._
# clear sys.path
# clear sys.argv