diff --git a/test/tests/openwrt_docker_test.py b/test/tests/openwrt_docker_test.py index e17d1d3..9479545 100644 --- a/test/tests/openwrt_docker_test.py +++ b/test/tests/openwrt_docker_test.py @@ -107,8 +107,15 @@ def run_openwrt_shell_command(command, *arg): if process.stdout == "": return None + # Sometime it happens that also the previous command return is included which results in two or more json strings. + jsons = process.stdout.split('\n') + + # Search for 'return' and give back the last occurrence index + idx = next((i for i, s in reversed(list(enumerate(jsons))) if 'return' in s), -1) + # Assume json here, parse it - ret = json.loads(process.stdout) + ret = json.loads(jsons[idx]) + data = ret['return'] # decode output