diff --git a/ceilometermiddleware/swift.py b/ceilometermiddleware/swift.py index 3f86250..04c09f4 100644 --- a/ceilometermiddleware/swift.py +++ b/ceilometermiddleware/swift.py @@ -73,11 +73,9 @@ from pycadf.helper import api from pycadf import measurement as cadf_measurement from pycadf import metric as cadf_metric from pycadf import resource as cadf_resource -import six -import six.moves.queue as queue -import six.moves.urllib.parse as urlparse +import queue import threading - +import urllib.parse as urlparse LOG = logging.getLogger(__name__) @@ -241,7 +239,7 @@ class Swift(object): return [client.projects.get(name_or_id)] except ksa_exc.NotFound: pass - if isinstance(name_or_id, six.binary_type): + if isinstance(name_or_id, bytes): name_or_id = name_or_id.decode('utf-8', 'strict') projects = client.projects.list(name=name_or_id) if not projects: @@ -305,8 +303,8 @@ class Swift(object): for header in env: if header.startswith('HTTP_') and env[header]: key = header[5:] - if isinstance(env[header], six.text_type): - headers[key] = six.text_type(env[header]) + if isinstance(env[header], str): + headers[key] = str(env[header]) else: headers[key] = str(env[header]) diff --git a/ceilometermiddleware/tests/test_swift.py b/ceilometermiddleware/tests/test_swift.py index 4c81d64..45c1174 100644 --- a/ceilometermiddleware/tests/test_swift.py +++ b/ceilometermiddleware/tests/test_swift.py @@ -12,11 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from io import StringIO import threading from unittest import mock from oslo_config import cfg -import six from ceilometermiddleware import swift from ceilometermiddleware.tests import base as tests_base @@ -53,9 +53,9 @@ class FakeRequest(object): environ['PATH_INFO'] = path if 'wsgi.input' not in environ: - environ['wsgi.input'] = six.moves.cStringIO('') + environ['wsgi.input'] = StringIO('') - for header, value in six.iteritems(headers): + for header, value in headers.items(): environ['HTTP_%s' % header.upper()] = value self.environ = environ @@ -125,7 +125,7 @@ class TestSwift(tests_base.TestCase): '/1.0/account/container/obj', environ={'REQUEST_METHOD': 'PUT', 'wsgi.input': - six.moves.cStringIO('some stuff')}) + StringIO('some stuff')}) with mock.patch('oslo_messaging.Notifier.info') as notify: list(app(req.environ, self.start_response)) self.assertEqual(1, len(notify.call_args_list)) @@ -145,7 +145,7 @@ class TestSwift(tests_base.TestCase): req = self.get_request( '/1.0/account/container/obj', environ={'REQUEST_METHOD': 'POST', - 'wsgi.input': six.moves.cStringIO('some other stuff')}) + 'wsgi.input': StringIO('some other stuff')}) with mock.patch('oslo_messaging.Notifier.info') as notify: list(app(req.environ, self.start_response)) self.assertEqual(1, len(notify.call_args_list)) @@ -277,7 +277,7 @@ class TestSwift(tests_base.TestCase): http_headers = [k for k in metadata.keys() if k.startswith('http_header_')] self.assertEqual(1, len(http_headers)) - self.assertEqual(six.text_type(uni), + self.assertEqual(str(uni), metadata['http_header_unicode']) def test_metadata_headers_on_not_existing_header(self): @@ -315,7 +315,7 @@ class TestSwift(tests_base.TestCase): list(app(req.environ, self.start_response)) self.assertEqual(0, len(notify.call_args_list)) - @mock.patch('six.moves.urllib.parse.quote') + @mock.patch('urllib.parse.quote') def test_emit_event_fail(self, mocked_func): mocked_func.side_effect = Exception("a exception") app = swift.Swift(FakeApp(body=["test"]), {}) @@ -429,7 +429,7 @@ class TestSwift(tests_base.TestCase): '/1.0/account/container/obj', environ={'REQUEST_METHOD': 'PUT', 'wsgi.input': - six.moves.cStringIO('some stuff'), + StringIO('some stuff'), 'swift.source': 'RL'}) with mock.patch('oslo_messaging.Notifier.info') as notify: list(app(req.environ, self.start_response))