From f8581a5bbbe441ce463f791ccfb3fa4d009b0a0a Mon Sep 17 00:00:00 2001 From: Krzysztof Jagiello Date: Sun, 5 Jun 2011 13:17:27 +0200 Subject: [PATCH] return response data always as a list for --- ts3.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ts3.py b/ts3.py index 906f357..98d8872 100644 --- a/ts3.py +++ b/ts3.py @@ -57,13 +57,15 @@ class TS3Response(): def __init__(self, response, data): self.response = TS3Proto.parse_command(response) self.data = TS3Proto.parse_command(data) + + if isinstance(self.data, dict): + if self.data: + self.data = [self.data] + else: + self.data = [] def is_successful(self): - if isinstance(self.response, dict): - return self.response['keys']['msg'] == 'ok' - - # if the response is a list, it has to be successful - return True + return self.response['keys']['msg'] == 'ok' class TS3Proto(): def connect(self, ip, port, timeout=5):