Remove six murano/api

Change-Id: I53368580d7a2d1923688be80899c97c57aafffad
This commit is contained in:
zhurong 2020-04-17 19:04:45 -07:00
parent f3f2a4019a
commit 8bf959f805
9 changed files with 19 additions and 35 deletions

View File

@ -18,7 +18,6 @@ import sys
import traceback import traceback
from oslo_config import cfg from oslo_config import cfg
import six
import webob import webob
from murano.common import wsgi from murano.common import wsgi
@ -96,7 +95,7 @@ class FaultWrapper(wsgi.Middleware):
ex_type = ex.__class__.__name__ ex_type = ex.__class__.__name__
full_message = six.text_type(ex) full_message = str(ex)
if full_message.find('\n') > -1: if full_message.find('\n') > -1:
message, msg_trace = full_message.split('\n', 1) message, msg_trace = full_message.split('\n', 1)
else: else:

View File

@ -17,7 +17,6 @@ import datetime
import jsonpatch import jsonpatch
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging from oslo_log import log as logging
import six
from sqlalchemy import desc from sqlalchemy import desc
from webob import exc from webob import exc
@ -83,7 +82,7 @@ class Controller(object):
LOG.error(msg) LOG.error(msg)
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
name = six.text_type(body['name']) name = str(body['name'])
if len(name) > 255: if len(name) > 255:
msg = _('Environment name should be 255 characters maximum') msg = _('Environment name should be 255 characters maximum')
LOG.error(msg) LOG.error(msg)
@ -144,7 +143,7 @@ class Controller(object):
session = db_session.get_session() session = db_session.get_session()
environment = session.query(models.Environment).get(environment_id) environment = session.query(models.Environment).get(environment_id)
new_name = six.text_type(body['name']) new_name = str(body['name'])
if new_name.strip(): if new_name.strip():
if len(new_name) > 255: if len(new_name) > 255:
msg = _('Environment name should be 255 characters maximum') msg = _('Environment name should be 255 characters maximum')

View File

@ -14,7 +14,6 @@
from oslo_log import log as logging from oslo_log import log as logging
from oslo_messaging.rpc import client from oslo_messaging.rpc import client
import six
from webob import exc from webob import exc
from murano.api.v1 import request_statistics from murano.api.v1 import request_statistics
@ -42,7 +41,7 @@ class Controller(object):
try: try:
methods = (list( methods = (list(
six.moves.map(six.text_type.strip, method_names.split(','))) map(str.strip, method_names.split(',')))
if method_names else []) if method_names else [])
return rpc.engine().generate_schema( return rpc.engine().generate_schema(
credentials, class_name, methods, credentials, class_name, methods,

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
from oslo_log import log as logging from oslo_log import log as logging
from oslo_messaging.rpc import client from oslo_messaging.rpc import client
from webob import exc from webob import exc
@ -71,8 +69,8 @@ class Controller(object):
except ValueError as e: except ValueError as e:
LOG.error('Exception during call of the method {method_name}: ' LOG.error('Exception during call of the method {method_name}: '
'{exc}'.format(method_name=method_name, '{exc}'.format(method_name=method_name,
exc=six.text_type(e))) exc=str(e)))
raise exc.HTTPBadRequest(six.text_type(e)) raise exc.HTTPBadRequest(str(e))
def create_resource(): def create_resource():

View File

@ -14,7 +14,6 @@
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging from oslo_log import log as logging
import six
from webob import exc from webob import exc
from murano.api.v1 import request_statistics from murano.api.v1 import request_statistics
@ -281,7 +280,7 @@ class Controller(object):
LOG.error(msg) LOG.error(msg)
raise exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
name = six.text_type(body['name']) name = str(body['name'])
if len(name) > 255: if len(name) > 255:
msg = _('Environment template name should be 255 characters ' msg = _('Environment template name should be 255 characters '
'maximum') 'maximum')

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from http import client as http_client
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves import http_client
import webob.dec import webob.dec
from murano.common import wsgi from murano.common import wsgi

View File

@ -19,7 +19,7 @@ import fixtures
import mock import mock
from oslo_utils import timeutils from oslo_utils import timeutils
import routes import routes
from six.moves import urllib import urllib
import webob import webob
from murano.api.v1 import request_statistics from murano.api.v1 import request_statistics

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from io import StringIO
import os import os
import sys import sys
@ -18,7 +19,6 @@ import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
import six
import testtools import testtools
from murano.cmd import test_runner from murano.cmd import test_runner
@ -58,8 +58,8 @@ class TestCaseShell(testtools.TestCase):
self.addCleanup(CONF.clear_override, name, group) self.addCleanup(CONF.clear_override, name, group)
def shell(self, cmd_args=None, exitcode=0): def shell(self, cmd_args=None, exitcode=0):
stdout = six.StringIO() stdout = StringIO()
stderr = six.StringIO() stderr = StringIO()
args = self.args args = self.args
if cmd_args: if cmd_args:
cmd_args = cmd_args.split() cmd_args = cmd_args.split()
@ -89,10 +89,7 @@ class TestCaseShell(testtools.TestCase):
def test_version(self): def test_version(self):
stdout, stderr = self.shell('--version') stdout, stderr = self.shell('--version')
if six.PY3:
output = stdout output = stdout
else:
output = stderr
self.assertIn(version.version_string, output) self.assertIn(version.version_string, output)
@mock.patch.object(test_runner, 'LOG') @mock.patch.object(test_runner, 'LOG')
@ -171,10 +168,7 @@ class TestCaseShell(testtools.TestCase):
def test_package_is_not_provided(self): def test_package_is_not_provided(self):
_, stderr = self.shell(exitcode=2) _, stderr = self.shell(exitcode=2)
if six.PY3:
err = 'the following arguments are required: ' err = 'the following arguments are required: '
else:
err = 'too few arguments'
self.assertIn('murano-test-runner: error: %s' % err, stderr) self.assertIn('murano-test-runner: error: %s' % err, stderr)
def test_wrong_parent(self): def test_wrong_parent(self):

View File

@ -16,6 +16,7 @@
import cgi import cgi
from datetime import datetime from datetime import datetime
import imghdr import imghdr
from io import StringIO
import os import os
import tempfile import tempfile
import uuid import uuid
@ -24,9 +25,6 @@ import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import timeutils from oslo_utils import timeutils
import six
from six.moves import cStringIO
from six.moves import range
from webob import exc from webob import exc
from murano.api.v1 import catalog from murano.api.v1 import catalog
@ -1119,7 +1117,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
self.expect_policy_check('upload_package') self.expect_policy_check('upload_package')
self.expect_policy_check('publicize_package') self.expect_policy_check('publicize_package')
file_obj_str = cStringIO("This is some dummy data") file_obj_str = StringIO("This is some dummy data")
file_obj = mock.MagicMock(cgi.FieldStorage) file_obj = mock.MagicMock(cgi.FieldStorage)
file_obj.file = file_obj_str file_obj.file = file_obj_str
package_from_dir, _ = self._test_package() package_from_dir, _ = self._test_package()
@ -1139,7 +1137,6 @@ This is a fake zip archive
def format_body(content): def format_body(content):
content = jsonutils.dumps(content) content = jsonutils.dumps(content)
body = body_fmt.format(content) body = body_fmt.format(content)
if six.PY3:
body = body.encode('utf-8') body = body.encode('utf-8')
return body return body
@ -1188,7 +1185,7 @@ This is a fake zip archive
self._set_policy_rules({'upload_package': '@'}) self._set_policy_rules({'upload_package': '@'})
self.expect_policy_check('upload_package') self.expect_policy_check('upload_package')
file_obj_str = cStringIO("This is some dummy data") file_obj_str = StringIO("This is some dummy data")
file_obj = mock.MagicMock(cgi.FieldStorage) file_obj = mock.MagicMock(cgi.FieldStorage)
file_obj.file = file_obj_str file_obj.file = file_obj_str
package_from_dir, _ = self._test_package() package_from_dir, _ = self._test_package()
@ -1208,7 +1205,6 @@ This is a fake zip archive
def format_body(content): def format_body(content):
content = jsonutils.dumps(content) content = jsonutils.dumps(content)
body = body_fmt.format(content) body = body_fmt.format(content)
if six.PY3:
body = body.encode('utf-8') body = body.encode('utf-8')
return body return body