[sysadmin-bin: 26/168] Add a clone of subprocess.CalledProcessError



commit 858a32824d4125df285da20d6631126067da534f
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Mar 2 16:10:18 2009 -0500

    Add a clone of subprocess.CalledProcessError
    
    subprocess.CalledProcessError wasn't in Python 2.4, so add equivalent code locally.

 gnome-post-receive-email |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gnome-post-receive-email b/gnome-post-receive-email
index 56c3ca8..ab619d9 100755
--- a/gnome-post-receive-email
+++ b/gnome-post-receive-email
@@ -32,7 +32,7 @@
 import re
 import os
 import pwd
-from subprocess import Popen, CalledProcessError, PIPE
+from subprocess import Popen, PIPE
 import sys
 
 # Utility functions for git
@@ -183,6 +183,15 @@ def commit_oneline(commit):
 # General Utility
 # ===============
 
+# Clone of subprocess.CalledProcessError (not in Python 2.4)
+class CalledProcessError(Exception):
+    def __init__(self, returncode, cmd):
+        self.returncode = returncode
+        self.cmd = cmd
+
+    def __str__(self):
+        return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
+
 def die(message):
     print >>sys.stderr, message
     sys.exit(1)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]