From: kaliko Date: Tue, 5 Mar 2024 16:38:37 +0000 (+0100) Subject: Add connections propertie X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=3bde1b25a28da8d36eacc1757841ab70618b8d95;p=python-musicpdaio.git Add connections propertie Some cleanup repr and log --- diff --git a/mpdaio/client.py b/mpdaio/client.py index bde752f..7bc483a 100644 --- a/mpdaio/client.py +++ b/mpdaio/client.py @@ -89,7 +89,7 @@ class MPDClient: def version(self): """MPD protocol version""" host = (self.host, self.port) - version = {_.version for _ in self._pool._connections.get(host, [])} + version = {_.version for _ in self.connections} if not version: log.warning('No connections yet in the connections pool for %s', host) return '' @@ -97,6 +97,12 @@ class MPDClient: log.warning('More than one version in the connections pool for %s', host) return version.pop() + @property + def connections(self): + """Open connections""" + host = (self.host, self.port) + return self._pool._connections.get(host, []) + async def close(self): await self._pool.close() @@ -277,7 +283,7 @@ class CmdHandler: parts.append(f'"{escape(str(arg))}"') if '\n' in ' '.join(parts): raise MPDCommandError('new line found in the command!') - log.debug(' '.join(parts)) + #log.debug(' '.join(parts)) await self._write_line(' '.join(parts)) async def _read_binary(self, amount): diff --git a/mpdaio/connection.py b/mpdaio/connection.py index c47cd7e..072fc3f 100644 --- a/mpdaio/connection.py +++ b/mpdaio/connection.py @@ -144,7 +144,7 @@ class Connection(base): def __repr__(self): host = f"{self._host[0]}:{self._host[1]}" - return f"Connection<{host}>#{id(self)}" + return f"Connection<{host}>" @property def closed(self):