1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-07-25 07:58:08 +00:00

Fix Docker logs decoding. Ref #2522

This commit is contained in:
grossmj 2025-04-18 13:58:56 +07:00
parent ca34053125
commit ffd628902c
No known key found for this signature in database
GPG Key ID: 1E7DD6DBB53FF3D7
2 changed files with 5 additions and 6 deletions

View File

@ -173,11 +173,10 @@ class Docker(BaseManager):
response = await self.http_query(method, path, data=data, params=params) response = await self.http_query(method, path, data=data, params=params)
body = await response.read() body = await response.read()
response.close() response.close()
if body and len(body): if response.headers.get('CONTENT-TYPE') == 'application/json':
if response.headers.get('CONTENT-TYPE') == 'application/json': body = json.loads(body.decode("utf-8", errors="ignore"))
body = json.loads(body.decode("utf-8")) else:
else: body = body.decode("utf-8", errors="ignore")
body = body.decode("utf-8")
log.debug("Query Docker %s %s params=%s data=%s Response: %s", method, path, params, data, body) log.debug("Query Docker %s %s params=%s data=%s Response: %s", method, path, params, data, body)
return body return body

View File

@ -1203,7 +1203,7 @@ class DockerVM(BaseNode):
""" """
result = await self.manager.query("GET", "containers/{}/logs".format(self._cid), params={"stderr": 1, "stdout": 1}) result = await self.manager.query("GET", "containers/{}/logs".format(self._cid), params={"stderr": 1, "stdout": 1})
return result.decode('utf-8', errors='ignore').strip() return result
async def delete(self): async def delete(self):
""" """