Source

rsync_backup / exec_cmd.py

Diff from to

exec_cmd.py

 
 
 def exec_cmd(cmd, input=None, **kw):
-    """execute cmd, give it <input> as stdin, return its stdout output,
-    stderr output and return code.
+    """execute cmd, give it <input> as stdin,
+       return its stdout and stderr output.
     """
     p = subprocess.Popen(cmd, **kw)
     data, errors = p.communicate(input)
-    return data, errors, p.returncode
+    if p.returncode != 0:
+        raise subprocess.CalledProcessError(p.returncode, cmd, data)
+    return data, errors
 
 
 def exec_shell(cmd, input=None,