Fix pep8 error when running tox

openstack-tox-pep8 now is failure, this patch is to fix
this.

Closes-bug: #1799930
Change-Id: Ia1b7f3395e92014e0f5373d81788dc55f7815002
This commit is contained in:
junboli 2018-10-25 04:01:24 +08:00
parent 95da742946
commit 0c34a4901d
5 changed files with 21 additions and 16 deletions

View File

@ -6,12 +6,12 @@
jobs:
- build-openstack-releasenotes
- openstack-tox-linters
- openstack-tox-pep8:
voting: false
- openstack-tox-pep8
gate:
jobs:
- build-openstack-releasenotes
- openstack-tox-linters
- openstack-tox-pep8
post:
jobs:
- publish-stx-api-ref

View File

@ -26,6 +26,7 @@ DC Manager base exception handling.
"""
import six
from oslo_utils import encodeutils
from oslo_utils import excutils
from dcmanager.common.i18n import _
@ -54,7 +55,7 @@ class DCManagerException(Exception):
if six.PY2:
def __unicode__(self):
return unicode(self.msg)
return encodeutils.exception_to_unicode(self.msg)
def use_fatal_exceptions(self):
return False

View File

@ -19,6 +19,7 @@ DC Orchestrator base exception handling.
"""
import six
from oslo_utils import encodeutils
from oslo_utils import excutils
from dcorch.common.i18n import _
@ -47,7 +48,7 @@ class OrchestratorException(Exception):
if six.PY2:
def __unicode__(self):
return unicode(self.msg)
return encodeutils.exception_to_unicode(self.msg)
def use_fatal_exceptions(self):
return False

View File

@ -12,6 +12,7 @@
import hashlib
import os
import six
import tsconfig.tsconfig as tsc
from cgtsclient import client as cgts_client
@ -402,7 +403,7 @@ class SysinvClient(base.DriverBase):
if k in self.REMOTELOGGING_PATCH_ATTRS:
if k == 'action':
action_found = True
elif k == 'enabled' and not isinstance(v, basestring):
elif k == 'enabled' and not isinstance(v, six.string_types):
# api requires a string for enabled
if not v:
patch[k] = 'false'

View File

@ -66,8 +66,11 @@ def set_current_test_data(cfg):
def print_divider(width, txt):
width_new = (int(width) - len(txt)) / 2
print '%s%s%s' % ('_' * width_new, txt, '_' * width_new)
width_new = (int(width) - len(txt)) // 2
width_dash = '_' * width_new
print('%(width_dash)s%(txt)s%(width_dash)s', {'width_dash': width_dash,
'txt': txt,
'width_dash': width_dash})
def get_divider_size():
@ -80,29 +83,28 @@ def get_divider_size():
# Get all repository information
data_dir = get_data_repo()
print 'Using %s as data directory' % data_dir
print('Using %(data_dir)s as data directory', {'data_dir': data_dir})
cfgs = get_cfgs()
cfgs_usable = filter_cfgs(cfgs)
print 'Required repo databases: %s' % os.environ.get('REQUIRED_REPOS')
print "Test data folder(s) found: %s" % cfgs
repo = os.environ.get('REQUIRED_REPOS')
print('Required repo databases: %(repo)s', {'repo': repo})
print("Test data folder(s) found: %(cfgs)s", {'cfgs': cfgs})
if len(cfgs_usable) == 0:
print 'No usable data sets found'
print('No usable data sets found')
exit
print 'Usable data folder(s): %s' % cfgs_usable
print('Usable data folder(s): %(cfgs_usable)s', {'cfgs_usable': cfgs_usable})
if os.environ.get('SINGLE_REPO') == 'True':
cfgs_usable = [cfgs_usable[0]]
print 'Restricting to single data set: %s' % cfgs_usable[0]
print ''
print('Restricting to single data set: %(cfgs)s', {'cfgs': cfgs_usable})
# Loop through all configurations and run unit tests with each
columns = get_divider_size()
for cfg in cfgs_usable:
print_divider(columns, cfg)
print 'Running unit tests with test data: %s' % cfg
print('Running unit tests with test data: %(cfg)s', {'cfg': cfg})
set_current_test_data(cfg)
setuptools.setup(
setup_requires=['pbr>=1.8.0'],
pbr=True)
print ''