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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@
import cgi
from datetime import datetime
import imghdr
from io import StringIO
import os
import tempfile
import uuid
@ -24,9 +25,6 @@ import mock
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import timeutils
import six
from six.moves import cStringIO
from six.moves import range
from webob import exc
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('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.file = file_obj_str
package_from_dir, _ = self._test_package()
@ -1139,8 +1137,7 @@ This is a fake zip archive
def format_body(content):
content = jsonutils.dumps(content)
body = body_fmt.format(content)
if six.PY3:
body = body.encode('utf-8')
body = body.encode('utf-8')
return body
with mock.patch('murano.packages.load_utils.load_from_file') as lff:
@ -1188,7 +1185,7 @@ This is a fake zip archive
self._set_policy_rules({'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.file = file_obj_str
package_from_dir, _ = self._test_package()
@ -1208,8 +1205,7 @@ This is a fake zip archive
def format_body(content):
content = jsonutils.dumps(content)
body = body_fmt.format(content)
if six.PY3:
body = body.encode('utf-8')
body = body.encode('utf-8')
return body
with mock.patch('murano.packages.load_utils.load_from_file') as lff: