]> kaliko git repositories - python-musicpdaio.git/commitdiff
Add connections propertie
authorkaliko <kaliko@azylum.org>
Tue, 5 Mar 2024 16:38:37 +0000 (17:38 +0100)
committerkaliko <kaliko@azylum.org>
Tue, 5 Mar 2024 16:38:58 +0000 (17:38 +0100)
Some cleanup repr and log

mpdaio/client.py
mpdaio/connection.py

index bde752f6d4d8305c7936b132d8a79694617d50ef..7bc483a01a0a5f6cbc418d9d131ac685d36701bc 100644 (file)
@@ -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):
index c47cd7ea3f52705d49ca50f6ba40b0442278f1e9..072fc3fc1d0edbe22a9681f994446409f6fcb9da 100644 (file)
@@ -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):