opae.admin: utils: return utf-8 string from call_process
opae.admin: utils: return utf-8 string from call_process
Python3 returns a bytes object and can't be parsed using regex.
Use `.decode('UTF-8')` to be compatible with Python 2.7/3
This way the output can be parsed with regex or parsed as a number (using `int` or `float`)
@@ -35,12 +35,15 @@ def call_process(cmd, no_dry=False):
return '0x0' if 'setpci' in cmd else ''
try:
- return subprocess.check_output(cmd.split(),
+ output = subprocess.check_output(cmd.split(),
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
LOG('process').error('calling %s returned %d', cmd, err.returncode)
LOG('process').debug('process output: %s', err.output)
raise
+ else:
+ return output.decode('UTF-8')
+
def assert_not_running(programs):
try:
