MPD client class¶
-
musicpd.
CONNECTION_TIMEOUT
= 5¶ seconds before a tcp connection attempt times out
-
class
musicpd.
MPDClient
[source]¶ MPDClient instance will look for
MPD_HOST
/MPD_PORT
/XDG_RUNTIME_DIR
environment variables and set instance attributehost
,port
andpwd
accordingly. RegardingMPD_HOST
format to expose password refer MPD client manual mpc (1).Then
musicpd.MPDClient.connect
will usehost
andport
as defaults if not provided as args.Cf.
musicpd.MPDClient.connect
for details.>>> from os import environ >>> environ['MPD_HOST'] = 'pass@mpdhost' >>> cli = musicpd.MPDClient() >>> cli.pwd == environ['MPD_HOST'].split('@')[0] True >>> cli.host == environ['MPD_HOST'].split('@')[1] True >>> cli.connect() # will use host/port as set in MPD_HOST/MPD_PORT
- Variables
Warning
Instance attribute host/port/pwd
While
musicpd.MPDClient().host
andmusicpd.MPDClient().port
keep track of current connection host and port,musicpd.MPDClient().pwd
is set once with password extracted from environment variable. Callingmusicpd.MPDClient().password()
with a new password won’t updatemusicpd.MPDClient().pwd
value.Moreover,
musicpd.MPDClient().pwd
is only an helper attribute exposing password extracted fromMPD_HOST
environment variable, it will not be used as default value for thepassword()
method