forked from ungleich-public/cdist
use sh -e instead of shipped shell=true (see included comment)
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
4fd8a16e6c
commit
2c2a234c74
17
bin/cdist
17
bin/cdist
|
@ -98,13 +98,12 @@ class Cdist:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def shell_run_or_debug_fail(self, script, *args, **kargs):
|
def shell_run_or_debug_fail(self, script, *args, **kargs):
|
||||||
kargs['shell'] = True
|
# Manually execute /bin/sh, because sh -e does what we want
|
||||||
|
# and sh -c -e does not exit if /bin/false called
|
||||||
|
args[0].insert(0,"/bin/sh")
|
||||||
|
args[0].insert(1,"-e")
|
||||||
log.debug("Shell exec: " + " ".join(*args))
|
log.debug("Shell exec: " + " ".join(*args))
|
||||||
|
|
||||||
# Fail if the script fails
|
|
||||||
args[0].insert(0,"-e")
|
|
||||||
print(args)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(*args, **kargs)
|
subprocess.check_call(*args, **kargs)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
@ -115,14 +114,12 @@ class Cdist:
|
||||||
self.exit_error("Non-Zero exit code exit of " + " ".join(*args))
|
self.exit_error("Non-Zero exit code exit of " + " ".join(*args))
|
||||||
|
|
||||||
def run_or_fail(self, *args, **kargs):
|
def run_or_fail(self, *args, **kargs):
|
||||||
# newargs = ["echo"]
|
log.debug("Exec: " + " ".join(*args))
|
||||||
newargs = []
|
|
||||||
newargs.extend(*args)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(newargs, **kargs)
|
subprocess.check_call(*args, **kargs)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
self.exit_error("Command failed:", " ".join(newargs))
|
self.exit_error("Command failed:", " ".join(*args))
|
||||||
|
|
||||||
def remote_run_or_fail(self, *args, **kargs):
|
def remote_run_or_fail(self, *args, **kargs):
|
||||||
"""Run something on the remote side and fail is something breaks"""
|
"""Run something on the remote side and fail is something breaks"""
|
||||||
|
|
Loading…
Reference in a new issue