Fix issues with Python3
Partially implements: blueprint python-3 Change-Id: I766594fb09047c0f114e20dc718bca2b374f3165
This commit is contained in:
parent
c8d0bb7830
commit
39e1b71b81
|
@ -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 _
|
||||
|
||||
|
|
Loading…
Reference in New Issue