]> git-server-git.apps.pok.os.sepia.ceph.com Git - remoto.git/commitdiff
add non zero exit status to be configured for a raise
authorAlfredo Deza <alfredo@deza.pe>
Mon, 28 Oct 2013 14:40:37 +0000 (10:40 -0400)
committerAlfredo Deza <alfredo@deza.pe>
Mon, 28 Oct 2013 14:40:37 +0000 (10:40 -0400)
remoto/process.py

index 0567e52d8247f0e2052dbd6c2457508353186409..7e81b4598eb2f1335cf6399f461da61c0acbddb1 100644 (file)
@@ -6,6 +6,8 @@ from .util import admin_command
 def _remote_run(channel, cmd, **kw):
     import subprocess
     import sys
+    stop_on_nonzero = kw.pop('stop_on_nonzero', True)
+
 
     process = subprocess.Popen(
         cmd,
@@ -34,7 +36,10 @@ def _remote_run(channel, cmd, **kw):
 
     returncode = process.wait()
     if returncode != 0:
-        raise RuntimeError("command returned non-zero exit status: %s" % returncode)
+        if stop_on_nonzero:
+            raise RuntimeError("command returned non-zero exit status: %s" % returncode)
+        else:
+            channel.send({'warning': "command returned non-zero exit status: %s" % returncode})
 
 
 def run(conn, command, exit=False, timeout=None, **kw):