Skip to content

Commit

Permalink
fix encoding problem (JIRA: HM-22) + fix in properties() results
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonySchneider-cnic committed Jun 14, 2017
1 parent 88cedbf commit 5dc88d4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions response.py
Expand Up @@ -13,11 +13,14 @@ def __init__(self, response):
self._response_hash = None
self._response_list_hash = None

#try/except to support old versions of python, like python2.5
#try/except to support old versions of python (python2.5)
try:
if type(response) == bytes:
response = response.decode("utf-8")
self._response_string = response
except UnicodeError:
response = response.decode("latin1")
self._response_string = response
except:
response = response.decode("utf-8")
self._response_string = response
Expand Down Expand Up @@ -85,12 +88,6 @@ def description(self):
"""
return self.as_list_hash()["DESCRIPTION"]

def properties(self):
"""
Returns the response properties
"""
return self.as_list_hash()["PROPERTY"]

def runtime(self):
"""
Returns the response runtime
Expand All @@ -103,12 +100,18 @@ def queuetime(self):
"""
return self.as_list_hash()["QUEUETIME"]

def properties(self):
"""
Returns the response properties
"""
return self.as_hash()["PROPERTY"]

def property(self, index = None):
"""
Returns the property for a given index
If no index given, the complete property list is returned
"""
properties = self.as_list()
properties = self.properties()
if index:
try:
return properties[index]
Expand Down

0 comments on commit 5dc88d4

Please sign in to comment.