-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
Custom notification plugin not loading #1124
Comments
It seems to work fine for me: # prepare our custom plugin
cat << __EOF > demo.py
# include the decorator
from apprise.decorators import notify
# This example maps foobar:// to your my_wrapper function
@notify(on="demo")
def my_wrapper(body, title, notify_type, *args, **kwargs):
# A simple test - print to screen
print("{}: {} - {}".format(notify_type, title, body))
__EOF
Execute using it (added -vvv tracing for added logs)
```bash
apprise -vvv -P ./demo.py 'demo://' -b "Test"
2024-05-13 19:54:17,768 - DEBUG - Notification Plugin 104(s) and 148 Schema(s) loaded in 0.1271s
2024-05-13 19:54:17,768 - DEBUG - Custom module ./delme.py - 1 schema(s) (name=8d8861d2d3ff3914173e8380d2d8a11efd7690a7) loaded in 0.128029s
2024-05-13 19:54:17,768 - INFO - Loaded custom notification: demo://
2024-05-13 19:54:17,768 - DEBUG - Language set to en
2024-05-13 19:54:17,769 - DEBUG - Loaded Custom - demo URL: demo://
info: - Test
2024-05-13 19:54:17,769 - INFO - Sent Custom - demo notification. In the above, you can see the loading of the module, and the last 2 lines show the printing (what i defined), and then the INFO letting you know the cutom message was executed correctly. In your test, this line stands out to me as interesting...
Are you over-riding the AppriseAsset() object by any chance? Also, can you share a bit more with me what your custom plugin looks like and/or how you're calling it. It's still possible i have a bug in how i handle things. Or it may just be something small you're doing on your end causing your issues. |
Thanks for the quick reply. I appreciate your help.
I'm trying to write a full custom plugin (e.g., https://github.com/caronc/apprise/wiki/DemoPlugin_Basic), not a decorator notifier (e.g., https://github.com/caronc/apprise/wiki/decorator_notify). Sorry for the confusion. Perhaps I misunderstood the wiki/documentation, is it not possible for a full class-based notifier to be loaded in run-time from a custom plugins folder? Your example works on my end as well (the decorator).
I'm not overriding AppriseAsset(). Here's what I'm trying in full details:
results in:
This issue is there regardless of the custom notification. Here's a minimal example on my end (it shows when using 4 v verbose level, not 3).
Produces the following full log.
Please don't mind the |
So for custom stuff like your doing you need to use the |
Thanks. I will try injecting the code in the core path. I think the documentation currently states
so,
So just to confirm, the filename needs to be different than the class name? |
Yeah, have a look at the new directory listings (as of a few weeks ago). This was due to an issue with how Python v3.11 handles file imports and unit testing (#1119). |
Thanks for confirming. I will try that. Regarding the logger issue. Are you able to produce it on your end? This should produce it: |
That just sends an Apprise message to an Apprise API server. I'm confused how this fits with your Honesty, your life would be so much easier if you just used the |
I understand re The logger issue seems unrelated to custom notifications. That's why I provided a line that doesn't load a custom plugin or use any custom notification. Do you prefer if I start a separate issue for this? In any case, here's the short setup: Issuing something like
or any other URI for that matter,
produces a bunch of logger errors (here's just a small snippet, but this is repeated a dozen or so times):
This would repeat for many (built-in) plugins. To see those errors, issue an |
There appears to be something wrong with your environment. Is your custom class you wrote perhaps in you're environment? Maybe try uninstalling and reinstalling Apprise to reset it? How did you originally install it? Via pip? |
It's a dockerized setup (from https://hub.docker.com/r/caronc/apprise). Let me try a clean new container (fresh install) and report back to you. Again, I appreciate your time. |
I'm about to go offline for a bit; bed time over here |
Of course, this is not pressing or urgent. Thanks for the help, I'll report back and wait for your reply whenever you get to it. |
The logging errors still persist in a fresh docker install. Here's a setup from scratch (fyi, docker run \
-it \
--rm \
-p '8000:8000/tcp' \
-v './config':'/config':'rw' \
'caronc/apprise:latest' \
apprise -vvvv -b "body" -t "title" signal://signal-url:9922/+phonenumber Produces all the logger errors. Here's a truncated output with the first couple of logger errors only:
the output continues with a bunch more similar errors. |
For further context, I tried this on two different machines running different host OSs, with the same results. |
So here is the thing; i've finally had time to look this over. There are 2 types of custom plugins.
The big difference between 1 and 2, is 1 you can do anytime with your current copy of Apprise. Option 2 requires you to commit to the code base (which don't get me wrong: I love that; I certainly welcome a new plugin you may have to offer). You can also perform option to into your already installed copy of apprise on your OS, but the directory varies depending on the distribution and method you chose. For example I hope this helps Finally thank you for pointing out https://github.com/caronc/apprise/wiki/DemoPlugin_Basic. I had forgotten about that wiki page and it is badly out of date. I've since updated the few mistakes that have also been reflected in the 2 working examples i have here. |
Thanks |
🪲 Describe the bug
I'm trying to write a custom notification plugin, but apprise/apprise-api is unable to load it throwing an exception with the error: "No module named 'apprise.custom'". This is not specific to the plugin I wrote, as I was able to reproduce it with the sample plugin from https://github.com/caronc/apprise/wiki/DemoPlugin_Basic.
Here's a setup to reproduce the problem:
apprise -vvvv -t 'sample title' -b 'body content' -P '/plugin' 'demo://'
from within the container.I'm sorry if this is better reported as an issue in https://github.com/caronc/apprise but my setup is using apprise-api so I thought the issue should be reported here. Happy to move the issue there if you prefer.
💡 Screenshots and Logs
💻 Your System Details:
🔮 Additional context
Perhaps an unrelated bug, the -vvvv level of logging is throwing a bunch of logger errors, see below for a small example (it repeats many times, but not for all plugins).
These logger errors seem to have been introduced with the latest update from a couple of days ago, perhaps caronc/apprise-api#189? They didn't seem to happen before the latest update. For context, the custom plugin issue described above is not new, I noticed it before the latest update as well (which is why I think they're unrelated).
Your time and efforts are appreciated. Thanks in advance.
The text was updated successfully, but these errors were encountered: