Include stdout in CommandError.
authorW. Trevor King <wking@drexel.edu>
Sat, 19 Sep 2009 21:58:09 +0000 (17:58 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 19 Sep 2009 21:58:09 +0000 (17:58 -0400)
libbe/bzr.py
libbe/git.py
libbe/vcs.py

index c551ff00f4bdd8cab0cda9fa5f309e8e7506e517..e9e0649615ef86a0c618228fa091f3f42c1f2221 100644 (file)
@@ -89,7 +89,7 @@ class Bzr(vcs.VCS):
                 if self._u_any_in_string(strings, error) == True:
                     raise vcs.EmptyCommit()
                 else:
-                    raise vcs.CommandError(args, status, error)
+                    raise vcs.CommandError(args, status, stdout="", stderr=error)
         revision = None
         revline = re.compile("Committed revision (.*)[.]")
         match = revline.search(error)
index 137cb35faecf8ed5bd3d9f9be650aa46ef661527..3abe3b816bd4bc5c63ed22f7578e7fe62391e416 100644 (file)
@@ -134,7 +134,7 @@ class Git(vcs.VCS):
         if status == 128:
             if error.startswith("fatal: ambiguous argument 'HEAD': unknown "):
                 return None
-            raise vcs.CommandError(args, status, error)
+            raise vcs.CommandError(args, status, stdout="", stderr=error)
         commits = output.splitlines()
         try:
             return commits[index]
index 3ee1a4426f9f4299158fbf34bf0afb5292ba9081..a1d302264700e7993351b3ddda914b8ca50294ab 100644 (file)
@@ -67,13 +67,14 @@ def installed_vcs():
 
 
 class CommandError(Exception):
-    def __init__(self, command, status, err_str):
-        strerror = ["Command failed (%d):\n  %s\n" % (status, err_str),
+    def __init__(self, command, status, stdout, stderr):
+        strerror = ["Command failed (%d):\n  %s\n" % (status, stderr),
                     "while executing\n  %s" % command]
         Exception.__init__(self, "\n".join(strerror))
         self.command = command
         self.status = status
-        self.err_str = err_str
+        self.stdout = stdout
+        self.stderr = stderr
 
 class SettingIDnotSupported(NotImplementedError):
     pass
@@ -469,13 +470,13 @@ class VCS(object):
                 q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, 
                           shell=True, cwd=cwd)
         except OSError, e :
-            raise CommandError(args, e.args[0], e)
-        output, error = q.communicate(input=stdin)
+            raise CommandError(args, status=e.args[0], stdout="", stderr=e)
+        output,error = q.communicate(input=stdin)
         status = q.wait()
         if self.verboseInvoke == True:
             print >> sys.stderr, "%d\n%s%s" % (status, output, error)
         if status not in expect:
-            raise CommandError(args, status, error)
+            raise CommandError(args, status, output, error)
         return status, output, error
     def _u_invoke_client(self, *args, **kwargs):
         directory = kwargs.get('directory',None)