Skip to content
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

MPDStats Shell Parameters --host crashes the Application: AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'? #5404

Open
ss2 opened this issue Sep 3, 2024 · 2 comments

Comments

@ss2
Copy link

ss2 commented Sep 3, 2024

I noticed that the plugin mpdstats has problems accepting shell
parameters while invoking. Passing the parameter --host=HOST will
crash the application:

[user@HOST ~]$ beet -vv -p mpdstats mpdstats --host=localhost
no user configuration found at /home/user/.config/beets/config.yaml
data directory: /home/user/.config/beets
plugin paths:
Sending event: pluginload
library database: /home/user/.config/beets/library.db
library directory: /home/user/Music
Sending event: library_opened
Traceback (most recent call last):
  File "/usr/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3.12/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/usr/lib/python3.12/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.12/site-packages/beetsplug/mpdstats.py", line 371, in func
    mpd_config["host"] = opts.host.decode("utf-8")
                         ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

If I put the parameters for this plugin into config.yml, then beets
will load the plugin just fine. But a mixture probably is not a good
idea. I thought, I'd pass the hostname to config.yml and the port
number through the CLI to bypass this error. Then I get the following
effect:

First the config:

plugins: mpdstats
mpd:
  host: somehost

The Result:

[user@HOST beets]$ beet -vv -p mpdstats mpdstats --port=5000
user configuration: /home/user/.config/beets/config.yaml
data directory: /home/user/.config/beets
plugin paths:
Sending event: pluginload
library database: /home/user/.config/beets/library.db
library directory: /home/user/Music
Sending event: library_opened
mpdstats: music_directory: /home/user/Music
mpdstats: strip_path: /
configuration error: mpd.host: must be a string

I observe this behavior in v1.6.0 and v2.0.0.

Setup

  • OS: Arch Linux
  • Python version: 3.12.5
  • beets version: 2.0.0
  • Turning off plugins made problem go away: Beets is
    configured with just the one plugin.

I'm surprised about the version reported by beets itself:

[user@HOST beets]$ pacman -Qs beets
local/beets 2.0.0-1
    Flexible music library manager and tagger
[user@HOST beets]$ beet --version
beets version 1.6.1
Python version 3.12.5
plugins: mpdstats

My configuration (output of beet config) is:

# --------------- Plugins ---------------

plugins: mpdstats
mpd:
    host: somehost
    music_directory: /home/user/Music
    strip_path: ''
    rating: yes
    rating_mix: 0.75
    port: 6600
    password: REDACTED

@bal-e
Copy link
Member

bal-e commented Oct 12, 2024

If beet --version looks wrong, check which beet -- maybe you have a local Pip-based installation that is overriding the system-wide installation.

@bal-e
Copy link
Member

bal-e commented Oct 12, 2024

Okay, that's actually a weird bug in itself. The Arch Linux beets package fetches the commit tagged v2.0.0, which is commit b88c09720c3f0782b90f83df74e65680c050392f. Within that commit, the __init__.py specifies version 1.6.1 instead of 2.0.0. @snejus do you know about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants