Cleanup Python 3 changes
* Rework BrickException to simplify the code. Revert partially changes done to port os-brick to Python 3, without losing Python 3 compatibility. * tox.ini: run py34 tests using the commands of the default test environent. All os-brick tests now pass on Python 3.4, so testr test runner can be used to run tests in parallel, get the test repository, etc. * tox.ini: exchange order of py27 and py34 in envlist: py34 must be run first to workaround a testrepository bug (see the note below). * README: give advices on tox/testrepository issues with python 2/3 Change-Id: If80e01e802079afea3f2ea8051c76afffa47fa03
This commit is contained in:
parent
d71f5da3a6
commit
c7446ccc43
|
@ -11,7 +11,15 @@ Features
|
||||||
* Discovery of volumes being attached to a host for many transport protocols.
|
* Discovery of volumes being attached to a host for many transport protocols.
|
||||||
* Removal of volumes from a host.
|
* Removal of volumes from a host.
|
||||||
|
|
||||||
|
Hacking
|
||||||
|
-------
|
||||||
|
|
||||||
|
Hacking on brick requires python-gdbm (for Debian derived distributions),
|
||||||
|
Python 2.7 and Python 3.4. A recent tox is required, as is a recent virtualenv
|
||||||
|
(13.1.0 or newer).
|
||||||
|
|
||||||
|
If "tox -e py34" fails with the error "db type could not be determined", remove
|
||||||
|
the .testrepository/ directory and then run "tox -e py34".
|
||||||
|
|
||||||
For any other imformation, refer to the parent project, Cinder:
|
For any other imformation, refer to the parent project, Cinder:
|
||||||
https://github.com/openstack/cinder
|
https://github.com/openstack/cinder
|
||||||
|
|
|
@ -37,7 +37,6 @@ class BrickException(Exception):
|
||||||
|
|
||||||
def __init__(self, message=None, **kwargs):
|
def __init__(self, message=None, **kwargs):
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.kwargs['message'] = message
|
|
||||||
|
|
||||||
if 'code' not in self.kwargs:
|
if 'code' not in self.kwargs:
|
||||||
try:
|
try:
|
||||||
|
@ -45,11 +44,7 @@ class BrickException(Exception):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for k, v in self.kwargs.items():
|
if not message:
|
||||||
if isinstance(v, Exception):
|
|
||||||
self.kwargs[k] = six.text_type(v)
|
|
||||||
|
|
||||||
if self._should_format():
|
|
||||||
try:
|
try:
|
||||||
message = self.message % kwargs
|
message = self.message % kwargs
|
||||||
|
|
||||||
|
@ -73,9 +68,6 @@ class BrickException(Exception):
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return six.text_type(self.msg)
|
return six.text_type(self.msg)
|
||||||
|
|
||||||
def _should_format(self):
|
|
||||||
return self.kwargs['message'] is None or '%(message)' in self.message
|
|
||||||
|
|
||||||
|
|
||||||
class NotFound(BrickException):
|
class NotFound(BrickException):
|
||||||
message = _("Resource could not be found.")
|
message = _("Resource could not be found.")
|
||||||
|
|
15
tox.ini
15
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
envlist = py27,py34,pep8
|
envlist = py34,py27,pep8
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
@ -28,19 +28,6 @@ commands = python setup.py testr --coverage --testr-args='{posargs}'
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
commands = python setup.py build_sphinx
|
commands = python setup.py build_sphinx
|
||||||
|
|
||||||
[testenv:py34]
|
|
||||||
commands =
|
|
||||||
find . -type f -name "*.pyc" -delete
|
|
||||||
python -m testtools.run \
|
|
||||||
os_brick.tests.test_brick \
|
|
||||||
os_brick.tests.test_exception \
|
|
||||||
os_brick.tests.test_utils \
|
|
||||||
os_brick.tests.initiator.test_connector \
|
|
||||||
os_brick.tests.initiator.test_linuxfc \
|
|
||||||
os_brick.tests.initiator.test_linuxrbd \
|
|
||||||
os_brick.tests.initiator.test_linuxscsi
|
|
||||||
|
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# H803 skipped on purpose per list discussion.
|
# H803 skipped on purpose per list discussion.
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
|
Loading…
Reference in New Issue