libkas: Do not sys.exit from a coroutine

That only creates exceptions and complaints if more routines are running
or we are already in the exiting process. Rather leave the coroutine and
catch the error on the waiting end.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka 2017-06-28 19:26:00 +02:00 committed by Daniel Wagner
parent f0a18868c9
commit adb4007482

View File

@ -122,7 +122,6 @@ def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
for line in logo.stderr:
msg += line
logging.error(msg)
sys.exit(ret)
return (ret, ''.join(logo.stdout))
@ -134,8 +133,11 @@ def run_cmd(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
# pylint: disable=too-many-arguments
loop = asyncio.get_event_loop()
return loop.run_until_complete(
(ret, output) = loop.run_until_complete(
run_cmd_async(cmd, cwd, env, fail, shell, liveupdate))
if ret and fail:
sys.exit(ret)
return (ret, output)
def find_program(paths, name):