mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
Revert "ifupdown: utils: user command output on stdout"
This reverts commit d9bb08208429349566139cd5fc65693c2493c372.
This commit is contained in:
@ -192,8 +192,7 @@ class utils():
|
||||
close_fds=False,
|
||||
stdout=True,
|
||||
stdin=None,
|
||||
stderr=subprocess.STDOUT,
|
||||
user_cmd=False):
|
||||
stderr=subprocess.STDOUT):
|
||||
"""
|
||||
exec's commands using subprocess Popen
|
||||
Args:
|
||||
@ -206,30 +205,20 @@ class utils():
|
||||
return ''
|
||||
|
||||
cmd_output = None
|
||||
if user_cmd:
|
||||
stdout = True
|
||||
elif stdout:
|
||||
stdout = subprocess.PIPE
|
||||
else:
|
||||
stdout = cls.DEVNULL
|
||||
try:
|
||||
ch = subprocess.Popen(cmd,
|
||||
env=env,
|
||||
shell=shell,
|
||||
close_fds=close_fds,
|
||||
stdin=subprocess.PIPE if stdin else None,
|
||||
stdout=stdout,
|
||||
stdout=subprocess.PIPE if stdout else cls.DEVNULL,
|
||||
stderr=stderr)
|
||||
utils.enable_subprocess_signal_forwarding(ch, signal.SIGINT)
|
||||
if stdout or stdin:
|
||||
cmd_output = ch.communicate(input=stdin)[0]
|
||||
cmd_returncode = ch.wait()
|
||||
except Exception as e:
|
||||
if user_cmd:
|
||||
raise Exception('cmd \'%s\' failed (%s)' % (cmd, str(e)))
|
||||
else:
|
||||
raise Exception('cmd \'%s\' failed (%s)' %
|
||||
(' '.join(cmd), str(e)))
|
||||
raise Exception('cmd \'%s\' failed (%s)' % (' '.join(cmd), str(e)))
|
||||
finally:
|
||||
utils.disable_subprocess_signal_forwarding(signal.SIGINT)
|
||||
if cmd_returncode != 0:
|
||||
@ -248,8 +237,7 @@ class utils():
|
||||
close_fds=close_fds,
|
||||
stdout=stdout,
|
||||
stdin=stdin,
|
||||
stderr=stderr,
|
||||
user_cmd=True)
|
||||
stderr=stderr)
|
||||
|
||||
@classmethod
|
||||
def exec_command(cls, cmd, env=None, close_fds=False, stdout=True,
|
||||
|
Reference in New Issue
Block a user