diff options
-rw-r--r-- | babel.cfg | 1 | ||||
-rw-r--r-- | doc/requirements.txt | 6 | ||||
-rwxr-xr-x | doc/source/conf.py | 6 | ||||
-rw-r--r-- | lower-constraints.txt | 11 | ||||
-rw-r--r-- | oslo_concurrency/lockutils.py | 3 | ||||
-rw-r--r-- | oslo_concurrency/processutils.py | 39 | ||||
-rw-r--r-- | oslo_concurrency/tests/unit/test_lockutils.py | 11 | ||||
-rw-r--r-- | oslo_concurrency/tests/unit/test_processutils.py | 98 | ||||
-rw-r--r-- | releasenotes/source/conf.py | 6 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | setup.cfg | 14 | ||||
-rw-r--r-- | test-requirements.txt | 2 |
12 files changed, 63 insertions, 135 deletions
diff --git a/babel.cfg b/babel.cfg deleted file mode 100644 index efceab8..0000000 --- a/babel.cfg +++ /dev/null @@ -1 +0,0 @@ -[python: **.py] diff --git a/doc/requirements.txt b/doc/requirements.txt index ba34ac7..400e1d9 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -2,8 +2,8 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. # this is required for the docs build jobs -sphinx>=1.8.0,!=2.1.0 # BSD -openstackdocstheme>=1.20.0 # Apache-2.0 -reno>=2.5.0 # Apache-2.0 +sphinx>=2.0.0,!=2.1.0 # BSD +openstackdocstheme>=2.2.0 # Apache-2.0 +reno>=3.1.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD sphinxcontrib-apidoc>=0.2.0 # BSD diff --git a/doc/source/conf.py b/doc/source/conf.py index e3516e0..2620b8d 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -24,9 +24,9 @@ extensions = [ ] # openstackdocstheme options -repository_name = 'openstack/oslo.concurrency' -bug_project = 'oslo.concurrency' -bug_tag = '' +openstackdocs_repo_name = 'openstack/oslo.concurrency' +openstackdocs_bug_project = 'oslo.concurrency' +openstackdocs_bug_tag = '' # The master toctree document. master_doc = 'index' diff --git a/lower-constraints.txt b/lower-constraints.txt index 986794b..f9246dd 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -11,46 +11,41 @@ eventlet==0.18.2 extras==1.0.0 fasteners==0.7.0 fixtures==3.0.0 -flake8==2.5.5 futures==3.0.0;python_version=='2.7' or python_version=='2.6' # BSD gitdb==0.6.4 GitPython==1.0.1 greenlet==0.4.10 -hacking==0.12.0 imagesize==0.7.1 iso8601==0.1.11 Jinja2==2.10 keystoneauth1==3.4.0 linecache2==1.0.0 MarkupSafe==1.0 -mccabe==0.2.1 monotonic==0.6 mox3==0.20.0 netaddr==0.7.18 netifaces==0.10.4 -openstackdocstheme==1.20.0 +openstackdocstheme==2.2.0 os-client-config==1.28.0 oslo.config==5.2.0 oslo.i18n==3.15.3 oslo.utils==3.33.0 oslotest==3.2.0 pbr==2.0.0 -pep8==1.5.7 -pyflakes==0.8.1 Pygments==2.2.0 pyparsing==2.1.0 python-mimeparse==1.6.0 python-subunit==1.0.0 pytz==2013.6 PyYAML==3.12 -reno==2.5.0 +reno==3.1.0 requests==2.14.2 requestsexceptions==1.2.0 rfc3986==0.3.1 six==1.10.0 smmap==0.9.0 snowballstemmer==1.2.1 -Sphinx==1.8.0 +Sphinx==2.0.0 sphinxcontrib-websupport==1.0.1 stevedore==1.20.0 stestr==2.0.0 diff --git a/oslo_concurrency/lockutils.py b/oslo_concurrency/lockutils.py index 7fe049b..e5798c5 100644 --- a/oslo_concurrency/lockutils.py +++ b/oslo_concurrency/lockutils.py @@ -28,7 +28,6 @@ import fasteners from oslo_config import cfg from oslo_utils import reflection from oslo_utils import timeutils -import six from oslo_concurrency._i18n import _ @@ -342,7 +341,7 @@ def synchronized(name, lock_file_prefix=None, external=False, lock_path=None, def wrap(f): - @six.wraps(f) + @functools.wraps(f) def inner(*args, **kwargs): t1 = timeutils.now() t2 = None diff --git a/oslo_concurrency/processutils.py b/oslo_concurrency/processutils.py index fc815de..40cadf0 100644 --- a/oslo_concurrency/processutils.py +++ b/oslo_concurrency/processutils.py @@ -32,7 +32,6 @@ from oslo_utils import encodeutils from oslo_utils import importutils from oslo_utils import strutils from oslo_utils import timeutils -import six from oslo_concurrency._i18n import _ @@ -329,7 +328,7 @@ def execute(*cmd, **kwargs): if kwargs: raise UnknownArgumentError(_('Got unknown keyword args: %r') % kwargs) - if isinstance(log_errors, six.integer_types): + if isinstance(log_errors, int): log_errors = LogErrors(log_errors) if not isinstance(log_errors, LogErrors): raise InvalidArgumentError(_('Got invalid arg log_errors: %r') % @@ -413,16 +412,15 @@ def execute(*cmd, **kwargs): if not ignore_exit_code and _returncode not in check_exit_code: (stdout, stderr) = result - if six.PY3: - stdout = os.fsdecode(stdout) - stderr = os.fsdecode(stderr) + stdout = os.fsdecode(stdout) + stderr = os.fsdecode(stderr) sanitized_stdout = strutils.mask_password(stdout) sanitized_stderr = strutils.mask_password(stderr) raise ProcessExecutionError(exit_code=_returncode, stdout=sanitized_stdout, stderr=sanitized_stderr, cmd=sanitized_cmd) - if six.PY3 and not binary and result is not None: + if not binary and result is not None: (stdout, stderr) = result # Decode from the locale using using the surrogateescape error # handler (decoding cannot fail) @@ -491,7 +489,7 @@ def trycmd(*args, **kwargs): out, err = execute(*args, **kwargs) failed = False except ProcessExecutionError as exn: - out, err = '', six.text_type(exn) + out, err = '', str(exn) failed = True if not failed and discard_warnings and err: @@ -543,12 +541,11 @@ def ssh_execute(ssh, cmd, process_input=None, exit_status = channel.recv_exit_status() - if six.PY3: - # Decode from the locale using using the surrogateescape error handler - # (decoding cannot fail). Decode even if binary is True because - # mask_password() requires Unicode on Python 3 - stdout = os.fsdecode(stdout) - stderr = os.fsdecode(stderr) + # Decode from the locale using using the surrogateescape error handler + # (decoding cannot fail). Decode even if binary is True because + # mask_password() requires Unicode on Python 3 + stdout = os.fsdecode(stdout) + stderr = os.fsdecode(stderr) if sanitize_stdout: stdout = strutils.mask_password(stdout) @@ -570,19 +567,9 @@ def ssh_execute(ssh, cmd, process_input=None, cmd=sanitized_cmd) if binary: - if six.PY2: - # On Python 2, stdout is a bytes string if mask_password() failed - # to decode it, or an Unicode string otherwise. Encode to the - # default encoding (ASCII) because mask_password() decodes from - # the same encoding. - if isinstance(stdout, six.text_type): - stdout = stdout.encode() - if isinstance(stderr, six.text_type): - stderr = stderr.encode() - else: - # fsencode() is the reverse operation of fsdecode() - stdout = os.fsencode(stdout) - stderr = os.fsencode(stderr) + # fsencode() is the reverse operation of fsdecode() + stdout = os.fsencode(stdout) + stderr = os.fsencode(stderr) return (stdout, stderr) diff --git a/oslo_concurrency/tests/unit/test_lockutils.py b/oslo_concurrency/tests/unit/test_lockutils.py index 3ebdd71..dd5127a 100644 --- a/oslo_concurrency/tests/unit/test_lockutils.py +++ b/oslo_concurrency/tests/unit/test_lockutils.py @@ -25,7 +25,6 @@ from unittest import mock from oslo_config import cfg from oslotest import base as test_base -import six from oslo_concurrency.fixture import lockutils as fixtures from oslo_concurrency import lockutils @@ -278,10 +277,7 @@ class LockTestCase(test_base.BaseTestCase): # Note(flaper87): Lock is not external, which means # a semaphore will be yielded with lockutils.lock("test") as sem: - if six.PY2: - self.assertIsInstance(sem, threading._Semaphore) - else: - self.assertIsInstance(sem, threading.Semaphore) + self.assertIsInstance(sem, threading.Semaphore) # NOTE(flaper87): Lock is external so an InterProcessLock # will be yielded. @@ -295,10 +291,7 @@ class LockTestCase(test_base.BaseTestCase): self.config(lock_path=tempfile.mkdtemp(), group='oslo_concurrency') with lockutils.lock("test") as sem: - if six.PY2: - self.assertIsInstance(sem, threading._Semaphore) - else: - self.assertIsInstance(sem, threading.Semaphore) + self.assertIsInstance(sem, threading.Semaphore) with lockutils.lock("test2", external=True) as lock: self.assertTrue(lock.exists()) diff --git a/oslo_concurrency/tests/unit/test_processutils.py b/oslo_concurrency/tests/unit/test_processutils.py index 2205bfa..78009ea 100644 --- a/oslo_concurrency/tests/unit/test_processutils.py +++ b/oslo_concurrency/tests/unit/test_processutils.py @@ -16,6 +16,7 @@ from __future__ import print_function import errno +import io import logging import multiprocessing import os @@ -30,7 +31,6 @@ from unittest import mock import fixtures from oslotest import base as test_base -import six from oslo_concurrency import processutils @@ -112,17 +112,11 @@ class UtilsTest(test_base.BaseTestCase): processutils.execute(TRUE_UTILITY) - if six.PY2: - self.assertRaises(processutils.InvalidArgumentError, - processutils.execute, - TRUE_UTILITY, - preexec_fn=preexec_fn) - else: - try: - processutils.execute(TRUE_UTILITY, preexec_fn=preexec_fn) - except Exception as e: - if type(e).__name__ != 'SubprocessError': - raise + try: + processutils.execute(TRUE_UTILITY, preexec_fn=preexec_fn) + except Exception as e: + if type(e).__name__ != 'SubprocessError': + raise @mock.patch.object(os, 'name', 'nt') @mock.patch.object(processutils.subprocess, "Popen") @@ -168,23 +162,23 @@ class ProcessExecutionErrorTest(test_base.BaseTestCase): def test_defaults(self): err = processutils.ProcessExecutionError() - self.assertIn('None\n', six.text_type(err)) - self.assertIn('code: -\n', six.text_type(err)) + self.assertIn('None\n', str(err)) + self.assertIn('code: -\n', str(err)) def test_with_description(self): description = 'The Narwhal Bacons at Midnight' err = processutils.ProcessExecutionError(description=description) - self.assertIn(description, six.text_type(err)) + self.assertIn(description, str(err)) def test_with_exit_code(self): exit_code = 0 err = processutils.ProcessExecutionError(exit_code=exit_code) - self.assertIn(str(exit_code), six.text_type(err)) + self.assertIn(str(exit_code), str(err)) def test_with_cmd(self): cmd = 'telinit' err = processutils.ProcessExecutionError(cmd=cmd) - self.assertIn(cmd, six.text_type(err)) + self.assertIn(cmd, str(err)) def test_with_stdout(self): stdout = """ @@ -207,13 +201,13 @@ class ProcessExecutionErrorTest(test_base.BaseTestCase): the Wielder of Wonder, with world's renown. """.strip() err = processutils.ProcessExecutionError(stdout=stdout) - print(six.text_type(err)) - self.assertIn('people-kings', six.text_type(err)) + print(str(err)) + self.assertIn('people-kings', str(err)) def test_with_stderr(self): stderr = 'Cottonian library' err = processutils.ProcessExecutionError(stderr=stderr) - self.assertIn(stderr, six.text_type(err)) + self.assertIn(stderr, str(err)) def test_retry_on_failure(self): fd, tmpfilename = tempfile.mkstemp() @@ -446,8 +440,8 @@ grep foo 'something') self.assertEqual(38, err.exit_code) - self.assertIsInstance(err.stdout, six.text_type) - self.assertIsInstance(err.stderr, six.text_type) + self.assertIsInstance(err.stdout, str) + self.assertIsInstance(err.stderr, str) self.assertIn('onstdout --password="***"', err.stdout) self.assertIn('onstderr --password="***"', err.stderr) self.assertEqual(' '.join([tmpfilename, @@ -458,20 +452,12 @@ grep foo def execute_undecodable_bytes(self, out_bytes, err_bytes, exitcode=0, binary=False): - if six.PY3: - code = ';'.join(('import sys', - 'sys.stdout.buffer.write(%a)' % out_bytes, - 'sys.stdout.flush()', - 'sys.stderr.buffer.write(%a)' % err_bytes, - 'sys.stderr.flush()', - 'sys.exit(%s)' % exitcode)) - else: - code = ';'.join(('import sys', - 'sys.stdout.write(%r)' % out_bytes, - 'sys.stdout.flush()', - 'sys.stderr.write(%r)' % err_bytes, - 'sys.stderr.flush()', - 'sys.exit(%s)' % exitcode)) + code = ';'.join(('import sys', + 'sys.stdout.buffer.write(%a)' % out_bytes, + 'sys.stdout.flush()', + 'sys.stderr.buffer.write(%a)' % err_bytes, + 'sys.stderr.flush()', + 'sys.exit(%s)' % exitcode)) return processutils.execute(sys.executable, '-c', code, binary=binary) @@ -480,7 +466,7 @@ grep foo err_bytes = b'err: ' + UNDECODABLE_BYTES out, err = self.execute_undecodable_bytes(out_bytes, err_bytes, binary=binary) - if six.PY3 and not binary: + if not binary: self.assertEqual(os.fsdecode(out_bytes), out) self.assertEqual(os.fsdecode(err_bytes), err) else: @@ -505,16 +491,8 @@ grep foo err = exc.stderr out_bytes = b'out: password="***" ' + UNDECODABLE_BYTES err_bytes = b'err: password="***" ' + UNDECODABLE_BYTES - if six.PY3: - # On Python 3, stdout and stderr attributes of - # ProcessExecutionError must always be Unicode - self.assertEqual(os.fsdecode(out_bytes), out) - self.assertEqual(os.fsdecode(err_bytes), err) - else: - # On Python 2, stdout and stderr attributes of - # ProcessExecutionError must always be bytes - self.assertEqual(out_bytes, out) - self.assertEqual(err_bytes, err) + self.assertEqual(os.fsdecode(out_bytes), out) + self.assertEqual(os.fsdecode(err_bytes), err) def test_undecodable_bytes_error(self): self.check_undecodable_bytes_error(False) @@ -642,7 +620,7 @@ class FakeSshChannel(object): return self.rc -class FakeSshStream(six.BytesIO): +class FakeSshStream(io.BytesIO): def setup_channel(self, rc): self.channel = FakeSshChannel(rc) @@ -658,9 +636,9 @@ class FakeSshConnection(object): raise socket.timeout() stdout = FakeSshStream(self.out) stdout.setup_channel(self.rc) - return (six.BytesIO(), + return (io.BytesIO(), stdout, - six.BytesIO(self.err)) + io.BytesIO(self.err)) class SshExecuteTestCase(test_base.BaseTestCase): @@ -684,8 +662,8 @@ class SshExecuteTestCase(test_base.BaseTestCase): out, err = processutils.ssh_execute(FakeSshConnection(0), 'ls') self.assertEqual('stdout', out) self.assertEqual('stderr', err) - self.assertIsInstance(out, six.text_type) - self.assertIsInstance(err, six.text_type) + self.assertIsInstance(out, str) + self.assertIsInstance(err, str) def test_binary(self): o, e = processutils.ssh_execute(FakeSshConnection(0), 'ls', @@ -701,7 +679,7 @@ class SshExecuteTestCase(test_base.BaseTestCase): conn = FakeSshConnection(0, out=out_bytes, err=err_bytes) out, err = processutils.ssh_execute(conn, 'ls', binary=binary) - if six.PY3 and not binary: + if not binary: self.assertEqual(os.fsdecode(out_bytes), out) self.assertEqual(os.fsdecode(err_bytes), err) else: @@ -729,16 +707,8 @@ class SshExecuteTestCase(test_base.BaseTestCase): out = exc.stdout err = exc.stderr - if six.PY3: - # On Python 3, stdout and stderr attributes of - # ProcessExecutionError must always be Unicode - self.assertEqual(os.fsdecode(out_bytes), out) - self.assertEqual(os.fsdecode(err_bytes), err) - else: - # On Python 2, stdout and stderr attributes of - # ProcessExecutionError must always be bytes - self.assertEqual(out_bytes, out) - self.assertEqual(err_bytes, err) + self.assertEqual(os.fsdecode(out_bytes), out) + self.assertEqual(os.fsdecode(err_bytes), err) def test_undecodable_bytes_error(self): self.check_undecodable_bytes_error(False) @@ -752,7 +722,7 @@ class SshExecuteTestCase(test_base.BaseTestCase): def _test_compromising_ssh(self, rc, check): fixture = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG)) - fake_stdin = six.BytesIO() + fake_stdin = io.BytesIO() fake_stdout = mock.Mock() fake_stdout.channel.recv_exit_status.return_value = rc diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 2351d2f..8045747 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -40,9 +40,9 @@ extensions = [ ] # openstackdocstheme options -repository_name = 'openstack/oslo.config' -bug_project = 'oslo.config' -bug_tag = '' +openstackdocs_repo_name = 'openstack/oslo.config' +openstackdocs_bug_project = 'oslo.config' +openstackdocs_bug_tag = '' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/requirements.txt b/requirements.txt index 241920c..2abd8f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,4 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 -six>=1.10.0 # MIT fasteners>=0.7.0 # Apache-2.0 @@ -30,17 +30,3 @@ oslo.config.opts = oslo.concurrency = oslo_concurrency.opts:list_opts console_scripts = lockutils-wrapper = oslo_concurrency.lockutils:main - -[compile_catalog] -directory = oslo_concurrency/locale -domain = oslo_concurrency - -[update_catalog] -domain = oslo_concurrency -output_dir = oslo_concurrency/locale -input_file = oslo_concurrency/locale/oslo_concurrency.pot - -[extract_messages] -keywords = _ gettext ngettext l_ lazy_gettext -mapping_file = babel.cfg -output_file = oslo_concurrency/locale/oslo_concurrency.pot diff --git a/test-requirements.txt b/test-requirements.txt index 4ccbbe1..2d71e69 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=3.0,<3.1.0 # Apache-2.0 +hacking>=3.0.1,<3.1.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD |