Commit 446c175c by Cédric de Saint Martin

slapos.slap: cast xml from unicode to string if it is unicode.

1 parent 2fad6ceb
......@@ -495,7 +495,11 @@ def forwardRequestToExternalMaster(master_url, request_form):
filter_kw['source_instance_id'] = partition_reference
new_request_form['filter_xml'] = dumps(filter_kw)
partition = loads(slap._connection_helper.POST('/requestComputerPartition', data=new_request_form))
xml = slap._connection_helper.POST('/requestComputerPartition', data=new_request_form)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
partition = loads(xml)
# XXX move to other end
partition._master_url = master_url
......
......@@ -85,6 +85,9 @@ class SlapRequester(SlapDocument):
request_dict=request_dict,
connection_helper=self._connection_helper,
)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
software_instance = xml_marshaller.loads(xml)
computer_partition = ComputerPartition(
software_instance.slap_computer_id.encode('UTF-8'),
......@@ -656,6 +659,9 @@ class ConnectionHelper:
# We should stablise slap library soon.
xml = self.GET('getComputerInformation', params=params)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
return xml_marshaller.loads(xml)
def do_request(self, method, path, params=None, data=None, headers=None):
......@@ -794,6 +800,9 @@ class slap:
'computer_partition_reference': partition_id,
}
)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
result = xml_marshaller.loads(xml)
# XXX: dirty hack to make computer partition usable. xml_marshaller is too
# low-level for our needs here.
......@@ -828,7 +837,11 @@ class slap:
'software_release_url parameters are specified.')
params['software_release_url'] = software_release_url
result = xml_marshaller.loads(self._connection_helper.GET(url, params=params))
xml = self._connection_helper.GET(url, params=params)
if type(xml) is unicode:
xml = str(xml)
xml.encode('utf-8')
result = xml_marshaller.loads(xml)
assert(type(result) == list)
return result
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!