Sync c-h with loopback_devices() fix

PY3 bug in loopback_devices caused the related bug.  This patch syncs
just the relevant file to fix the bug into charmhelpers.

Change-Id: I5aacd16c2bd4957c49210e867dc76efa1a315ab4
Closes-Bug: #1804128
This commit is contained in:
Alex Kavanagh 2018-11-20 14:27:55 +00:00
parent 3066151e77
commit 25ec6c6a3d
1 changed files with 4 additions and 2 deletions

View File

@ -36,8 +36,10 @@ def loopback_devices():
'''
loopbacks = {}
cmd = ['losetup', '-a']
devs = [d.strip().split(' ') for d in
check_output(cmd).splitlines() if d != '']
output = check_output(cmd)
if six.PY3:
output = output.decode('utf-8')
devs = [d.strip().split(' ') for d in output.splitlines() if d != '']
for dev, _, f in devs:
loopbacks[dev.replace(':', '')] = re.search(r'\((\S+)\)', f).groups()[0]
return loopbacks