caronc / apprise

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

Add missing % string in import failed trace message #1151

Closed jpbede closed 5 days ago

jpbede commented 5 days ago

Description:

The trace message in manager.py missed a % string which leads to TypeError:

Traceback (most recent call last):
  File "/Users/jbenecke/.pyenv/versions/3.12.4/lib/python3.12/logging/__init__.py", line 1160, in emit
    msg = self.format(record)
          ^^^^^^^^^^^^^^^^^^^
  File "/Users/jbenecke/.pyenv/versions/3.12.4/lib/python3.12/logging/__init__.py", line 999, in format
    return fmt.format(record)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/jbenecke/.pyenv/versions/3.12.4/lib/python3.12/logging/__init__.py", line 703, in format
    record.message = record.getMessage()
                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/jbenecke/.pyenv/versions/3.12.4/lib/python3.12/logging/__init__.py", line 392, in getMessage
    msg = msg % self.args
          ~~~~^~~~~~~~~~~
TypeError: not all arguments converted during string formatting
Call stack:
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/bin/apprise", line 8, in <module>
    sys.exit(main())
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/cli.py", line 451, in main
    a.add(url)
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/apprise.py", line 288, in add
    instance = Apprise.instantiate(_server, asset=asset, tag=tag)
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/apprise.py", line 132, in instantiate
    results = plugins.url_to_dict(
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/plugins/__init__.py", line 450, in url_to_dict
    if schema not in N_MGR:
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/manager.py", line 634, in __contains__
    self.load_modules()
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/manager.py", line 225, in load_modules
    logger.trace(
  File "/Users/jbenecke/SourceCode/home-assistant-core/venv/lib/python3.12/site-packages/apprise/logger.py", line 53, in trace
    self._log(logging.TRACE, message, args, **kwargs)
Message: '(%s) import failed; no app_id defined in %s'

Checklist

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@<this.branch-name>

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  <apprise url related to ticket>
caronc commented 5 days ago

Thank you; I didn't even see this until i made my PR 30 min later. would rather take yours for the kind effort you made.

Would it be okay to just swap %s(%s) to (%s.%s)?

I'll then close my PR and merge yours.

jpbede commented 5 days ago

Would it be okay to just swap %s(%s) to (%s.%s)?

Sure, one sec and thanks 🙂