extend run_or_fail to include remote exec

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-09-09 14:27:54 +02:00
parent b2d1d1bee7
commit c1ad93bccc
1 changed files with 2 additions and 8 deletions

View File

@ -155,20 +155,14 @@ class Cdist:
self.exit_error("Non-Zero exit code exit of " + " ".join(*args))
def run_or_fail(self, *args, **kargs):
log.debug("Exec: " + " ".join(*args))
if "remote" in kargs:
log.debug("Remote found")
if kargs["remote"]:
# Replace the list found in the tuple at position 0
cmd = ["ssh", "root@" + self.target_host]
cmd.extend(args[0])
args[0] = cmd
print(newargs)
args[0][:0] = ["ssh", "root@" + self.target_host]
del kargs["remote"]
log.debug(newargs)
log.debug("Exec: " + " ".join(*args))
try:
subprocess.check_call(*args, **kargs)
except subprocess.CalledProcessError: