Commit a85eb18e authored by Zuul's avatar Zuul Committed by Gerrit Code Review

Merge "Fix issues with Python3"

parents b53f01d0 39e1b71b
......@@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from keystoneauth1 import adapter
from oslo_serialization import jsonutils
import requests
from blazarclient import exception
......@@ -89,13 +88,13 @@ class RequestManager(object):
if 'body' in kwargs:
kwargs['headers']['Content-Type'] = 'application/json'
kwargs['data'] = json.dumps(kwargs['body'])
kwargs['data'] = jsonutils.dump_as_bytes(kwargs['body'])
del kwargs['body']
resp = requests.request(method, self.blazar_url + url, **kwargs)
try:
body = json.loads(resp.text)
body = jsonutils.loads(resp.text)
except ValueError:
body = None
......
......@@ -134,7 +134,7 @@ class CreateCommand(BlazarCommand, show.ShowOne):
print('Created a new %s:' % self.resource, file=self.app.stdout)
else:
data = {'': ''}
return zip(*sorted(data.items()))
return list(zip(*sorted(data.items())))
class UpdateCommand(BlazarCommand):
......@@ -291,4 +291,4 @@ class ShowCommand(BlazarCommand, show.ShowOne):
resource_manager = getattr(blazar_client, self.resource)
data = resource_manager.get(res_id)
self.format_output_data(data)
return zip(*sorted(data.items()))
return list(zip(*sorted(data.items())))
......@@ -511,7 +511,7 @@ class BlazarShell(app.App):
def main(argv=sys.argv[1:]):
try:
return BlazarShell().run(map(encodeutils.safe_decode, argv))
return BlazarShell().run(list(map(encodeutils.safe_decode, argv)))
except exception.BlazarClientException:
return 1
except Exception as e:
......
......@@ -68,12 +68,12 @@ class BlazarCommandTestCase(tests.TestCase):
def test_format_output_data(self):
data_before = {'key_string': 'string_value',
'key_dict': "{'key0': 'value', 'key1': 'value'}",
'key_list': "['1', '2', '3',]",
'key_dict': {'key': 'value'},
'key_list': ['1', '2', '3'],
'key_none': None}
data_after = {'key_string': 'string_value',
'key_dict': "{'key0': 'value', 'key1': 'value'}",
'key_list': "['1', '2', '3',]",
'key_dict': '{"key": "value"}',
'key_list': '1\n2\n3',
'key_none': ''}
self.command.format_output_data(data_before)
......
......@@ -14,10 +14,11 @@
# limitations under the License.
import datetime
import json
import os
import re
from oslo_serialization import jsonutils as json
from blazarclient import exception
from blazarclient.i18n import _
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment