libkas: Remove unused shell mode from run_cmd
No users, and it even seems broken /wrt universal_newlines. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
d4a615bb0b
commit
bb103365d2
@ -83,7 +83,7 @@ def _read_stream(stream, callback):
|
|||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
|
def run_cmd_async(cmd, cwd, env=None, fail=True, liveupdate=True):
|
||||||
"""
|
"""
|
||||||
Run a command asynchronously.
|
Run a command asynchronously.
|
||||||
"""
|
"""
|
||||||
@ -94,29 +94,18 @@ def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
|
|||||||
# pylint: disable=not-an-iterable
|
# pylint: disable=not-an-iterable
|
||||||
|
|
||||||
env = env or get_context().environ
|
env = env or get_context().environ
|
||||||
cmdstr = cmd
|
cmdstr = ' '.join(cmd)
|
||||||
if not shell:
|
|
||||||
cmdstr = ' '.join(cmd)
|
|
||||||
logging.info('%s$ %s', cwd, cmdstr)
|
logging.info('%s$ %s', cwd, cmdstr)
|
||||||
|
|
||||||
logo = LogOutput(liveupdate)
|
logo = LogOutput(liveupdate)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if shell:
|
process = yield from asyncio.create_subprocess_exec(
|
||||||
process = yield from asyncio.create_subprocess_shell(
|
*cmd,
|
||||||
cmd,
|
cwd=cwd,
|
||||||
env=env,
|
env=env,
|
||||||
cwd=cwd,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
universal_newlines=True,
|
stderr=asyncio.subprocess.PIPE)
|
||||||
stdout=asyncio.subprocess.PIPE,
|
|
||||||
stderr=asyncio.subprocess.PIPE)
|
|
||||||
else:
|
|
||||||
process = yield from asyncio.create_subprocess_exec(
|
|
||||||
*cmd,
|
|
||||||
cwd=cwd,
|
|
||||||
env=env,
|
|
||||||
stdout=asyncio.subprocess.PIPE,
|
|
||||||
stderr=asyncio.subprocess.PIPE)
|
|
||||||
except FileNotFoundError as ex:
|
except FileNotFoundError as ex:
|
||||||
if fail:
|
if fail:
|
||||||
raise ex
|
raise ex
|
||||||
@ -143,7 +132,7 @@ def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
|
|||||||
return (ret, ''.join(logo.stdout))
|
return (ret, ''.join(logo.stdout))
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
|
def run_cmd(cmd, cwd, env=None, fail=True, liveupdate=True):
|
||||||
"""
|
"""
|
||||||
Runs a command synchronously.
|
Runs a command synchronously.
|
||||||
"""
|
"""
|
||||||
@ -151,7 +140,7 @@ def run_cmd(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
|
|||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
(ret, output) = loop.run_until_complete(
|
(ret, output) = loop.run_until_complete(
|
||||||
run_cmd_async(cmd, cwd, env, fail, shell, liveupdate))
|
run_cmd_async(cmd, cwd, env, fail, liveupdate))
|
||||||
if ret and fail:
|
if ret and fail:
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
return (ret, output)
|
return (ret, output)
|
||||||
|
Loading…
Reference in New Issue
Block a user