From a3a9e864aad9677399f3fc8fb1a7cdf610b37043 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 7 Oct 2010 11:24:08 +0100 Subject: [PATCH] Fix data parsing from TS3 server Problem happened when we tried to extend the data list from the dict, it just uses the keynames. Also if we have only one entry return the raw dict instead of a list --- ts3.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ts3.py b/ts3.py index e3b55b8..f614b41 100644 --- a/ts3.py +++ b/ts3.py @@ -66,13 +66,16 @@ class TS3Proto(): resp = self._sockfile.readline() resp = self.parse_command(resp) if not 'command' in resp: - data.extend(resp) + data.append(resp) else: break if resp['command'] == 'error': if data and resp['keys']['id'] == '0': - return data + if len(data) > 1: + return data + else: + return data[0] else: return resp['keys']['id'] @@ -90,8 +93,7 @@ class TS3Proto(): @type opts: list """ - cstr = [] - cstr.append(command) + cstr = [command] # Add the keys and values, escape as needed if keys: