From: Kaliko Jack Date: Mon, 10 Apr 2023 17:33:23 +0000 (+0200) Subject: Initialize host,port and pwd attribute in init X-Git-Tag: v0.9.0~26 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=c3bb82643e556ce0e7c53ca9aab276c3c963bcfc;p=python-musicpd.git Initialize host,port and pwd attribute in init --- diff --git a/musicpd.py b/musicpd.py index 7d0918c..35be751 100644 --- a/musicpd.py +++ b/musicpd.py @@ -302,16 +302,20 @@ class MPDClient: "readmessages": self._fetch_messages, "sendmessage": self._fetch_nothing, } + #: host used with the current connection (:py:obj:`str`) + self.host = None + #: password detected in :envvar:`MPD_HOST` environment variable (:py:obj:`str`) + self.pwd = None + #: port used with the current connection (:py:obj:`int`, :py:obj:`str`) + self.port = None self._get_envvars() def _get_envvars(self): """ - Retrieve MPD env. var. to overrides "localhost:6600" - Use MPD_HOST/MPD_PORT if set - else use MPD_HOST=${XDG_RUNTIME_DIR:-/run/}/mpd/socket if file exists + Retrieve MPD env. var. to overrides default "localhost:6600" """ + # Set some defaults self.host = 'localhost' - self.pwd = None self.port = os.getenv('MPD_PORT', '6600') _host = os.getenv('MPD_HOST', '') if _host: