From 3bde1b25a28da8d36eacc1757841ab70618b8d95 Mon Sep 17 00:00:00 2001 From: kaliko Date: Tue, 5 Mar 2024 17:38:37 +0100 Subject: [PATCH] Add connections propertie Some cleanup repr and log --- mpdaio/client.py | 10 ++++++++-- mpdaio/connection.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) 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): -- 2.39.5