Py3 Fixes

Charm-helpers sync for python3 fixes.
Update Exception.message to use str(Exception)

Change-Id: I0e354d0d07f220e3285eb3e863498918c82df2ca
This commit is contained in:
David Ames 2017-12-05 18:55:28 +00:00
parent 7848824d8d
commit da51f91680
5 changed files with 11 additions and 7 deletions

View File

@ -37,10 +37,10 @@ def get_disk_stats():
return diskstats.readlines()
except IOError as err:
hookenv.log('Could not open /proc/diskstats. Error: {}'
.format(err.message))
.format(str(err)))
hookenv.action_fail(
'replace-osd failed because /proc/diskstats could not '
'be opened {}'.format(err.message))
'be opened {}'.format(str(err)))
return None
@ -65,7 +65,7 @@ def lookup_device_name(major_number, minor_number):
return parts[2]
except ValueError as value_err:
hookenv.log('Could not convert {} or {} into an integer. Error: {}'
.format(parts[0], parts[1], value_err.message))
.format(parts[0], parts[1], str(value_err)))
continue
return None

View File

@ -392,6 +392,8 @@ def get_swift_codename(version):
releases = UBUNTU_OPENSTACK_RELEASE
release = [k for k, v in six.iteritems(releases) if codename in v]
ret = subprocess.check_output(['apt-cache', 'policy', 'swift'])
if six.PY3:
ret = ret.decode('UTF-8')
if codename in ret or release[0] in ret:
return codename
elif len(codenames) == 1:

View File

@ -377,12 +377,12 @@ def get_mon_map(service):
try:
return json.loads(mon_status)
except ValueError as v:
log("Unable to parse mon_status json: {}. Error: {}".format(
mon_status, v.message))
log("Unable to parse mon_status json: {}. Error: {}"
.format(mon_status, str(v)))
raise
except CalledProcessError as e:
log("mon_status command failed with message: {}".format(
e.message))
log("mon_status command failed with message: {}"
.format(str(e)))
raise

View File

@ -20,6 +20,7 @@ UBUNTU_RELEASES = (
'yakkety',
'zesty',
'artful',
'bionic',
)

View File

@ -20,6 +20,7 @@ UBUNTU_RELEASES = (
'yakkety',
'zesty',
'artful',
'bionic',
)