Added Python3 support.
* dict_items, dict_values, dict_keys returns view in Py3 instead of list so wrapped with list. * Replaced dict.iteritems() with dict.items(). * Replaced dict.itervalues() with dict.values(). * Replaced 'unicode(err)' with 'oslo_utils.encodeutils.exception_to_unicode(err)'. * Added 'openstack-tox-py35' in Zuul CI jobs. Fixes bug 1877507 Change-Id: Ic0892bfd501bc45bb8b7b7bebe299c86c34710ae
This commit is contained in:
parent
7b51446306
commit
ea11205cbc
21
.zuul.yaml
Normal file
21
.zuul.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
- project:
|
||||
name: x/python-group-based-policy-client
|
||||
templates:
|
||||
- openstack-python-jobs
|
||||
- publish-to-pypi
|
||||
check:
|
||||
jobs:
|
||||
- openstack-tox-pep8:
|
||||
nodeset: ubuntu-xenial
|
||||
- openstack-tox-py27:
|
||||
nodeset: ubuntu-xenial
|
||||
- openstack-tox-py35:
|
||||
nodeset: ubuntu-xenial
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-pep8:
|
||||
nodeset: ubuntu-xenial
|
||||
- openstack-tox-py27:
|
||||
nodeset: ubuntu-xenial
|
||||
- openstack-tox-py35:
|
||||
nodeset: ubuntu-xenial
|
@ -594,12 +594,12 @@ class CreateL3Policy(neutronV20.CreateCommand):
|
||||
for external_segment in parsed_args.external_segments:
|
||||
external_segment_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'external_segment',
|
||||
external_segment.keys()[0])
|
||||
ipaddrs = external_segment.itervalues().next()
|
||||
list(external_segment.keys())[0])
|
||||
ipaddrs = next(iter(external_segment.values()))
|
||||
if ipaddrs is "":
|
||||
ipaddrs = []
|
||||
else:
|
||||
ipaddrs = external_segment.itervalues().next().split(':')
|
||||
ipaddrs = next(iter(external_segment.values())).split(':')
|
||||
external_segments_dict[external_segment_id] = ipaddrs
|
||||
|
||||
body[self.resource]['external_segments'] = external_segments_dict
|
||||
@ -677,12 +677,12 @@ class UpdateL3Policy(neutronV20.UpdateCommand):
|
||||
break
|
||||
external_segment_id = neutronV20.find_resourceid_by_name_or_id(
|
||||
self.get_client(), 'external_segment',
|
||||
external_segment.keys()[0])
|
||||
ipaddrs = external_segment.itervalues().next()
|
||||
list(external_segment.keys())[0])
|
||||
ipaddrs = next(iter(external_segment.values()))
|
||||
if ipaddrs is "":
|
||||
ipaddrs = []
|
||||
else:
|
||||
ipaddrs = external_segment.itervalues().next().split(':')
|
||||
ipaddrs = next(iter(external_segment.values())).split(':')
|
||||
external_segments_dict[external_segment_id] = ipaddrs
|
||||
|
||||
body[self.resource]['external_segments'] = external_segments_dict
|
||||
|
@ -656,10 +656,10 @@ class GBPShell(app.App):
|
||||
self.initialize_app(remainder)
|
||||
except Exception as err:
|
||||
if self.options.verbose_level >= self.DEBUG_LEVEL:
|
||||
self.log.exception(unicode(err))
|
||||
self.log.exception(encodeutils.exception_to_unicode(err))
|
||||
raise
|
||||
else:
|
||||
self.log.error(unicode(err))
|
||||
self.log.error(encodeutils.exception_to_unicode(err))
|
||||
return 1
|
||||
result = 1
|
||||
if self.interactive_mode:
|
||||
@ -686,16 +686,17 @@ class GBPShell(app.App):
|
||||
return run_command(cmd, cmd_parser, sub_argv)
|
||||
except Exception as err:
|
||||
if self.options.verbose_level >= self.DEBUG_LEVEL:
|
||||
self.log.exception(unicode(err))
|
||||
self.log.exception(encodeutils.exception_to_unicode(err))
|
||||
else:
|
||||
self.log.error(unicode(err))
|
||||
self.log.error(encodeutils.exception_to_unicode(err))
|
||||
try:
|
||||
self.clean_up(cmd, result, err)
|
||||
except Exception as err2:
|
||||
if self.options.verbose_level >= self.DEBUG_LEVEL:
|
||||
self.log.exception(unicode(err2))
|
||||
self.log.exception(encodeutils.exception_to_unicode(err2))
|
||||
else:
|
||||
self.log.error(_('Could not clean up: %s'), unicode(err2))
|
||||
self.log.error(_('Could not clean up: %s'),
|
||||
encodeutils.exception_to_unicode(err2))
|
||||
if self.options.verbose_level >= self.DEBUG_LEVEL:
|
||||
raise
|
||||
else:
|
||||
@ -703,9 +704,10 @@ class GBPShell(app.App):
|
||||
self.clean_up(cmd, result, None)
|
||||
except Exception as err3:
|
||||
if self.options.verbose_level >= self.DEBUG_LEVEL:
|
||||
self.log.exception(unicode(err3))
|
||||
self.log.exception(encodeutils.exception_to_unicode(err3))
|
||||
else:
|
||||
self.log.error(_('Could not clean up: %s'), unicode(err3))
|
||||
self.log.error(_('Could not clean up: %s'),
|
||||
encodeutils.exception_to_unicode(err3))
|
||||
return result
|
||||
|
||||
def authenticate_user(self):
|
||||
@ -822,7 +824,8 @@ class GBPShell(app.App):
|
||||
def clean_up(self, cmd, result, err):
|
||||
self.log.debug('clean_up %s', cmd.__class__.__name__)
|
||||
if err:
|
||||
self.log.debug('Got an error: %s', unicode(err))
|
||||
self.log.debug('Got an error: %s',
|
||||
encodeutils.exception_to_unicode(err))
|
||||
|
||||
def configure_logging(self):
|
||||
"""Create logging handlers for any log output."""
|
||||
@ -938,7 +941,7 @@ def main(argv=sys.argv[1:]):
|
||||
except exc.NeutronClientException:
|
||||
return 1
|
||||
except Exception as e:
|
||||
print(unicode(e))
|
||||
print(encodeutils.exception_to_unicode(e))
|
||||
return 1
|
||||
|
||||
|
||||
|
7
tox.ini
7
tox.ini
@ -1,9 +1,10 @@
|
||||
[tox]
|
||||
envlist = py27,py33,pypy,pep8
|
||||
envlist = py27,py33,py36,pypy,pep8
|
||||
minversion = 1.6
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
basepython = python3
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
LANG=en_US.UTF-8
|
||||
LANGUAGE=en_US:en
|
||||
@ -15,16 +16,20 @@ deps = -r{toxinidir}/requirements.txt
|
||||
commands = python setup.py testr --testr-args='{posargs}'
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
commands = flake8
|
||||
distribute = false
|
||||
|
||||
[testenv:venv]
|
||||
basepython = python3
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
basepython = python3
|
||||
commands = python setup.py testr --coverage --testr-args='{posargs}'
|
||||
|
||||
[testenv:docs]
|
||||
basepython = python3
|
||||
commands=
|
||||
sphinx-build -W -b html doc/source doc/build/html
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user