Add a boundary to parse_patches in pick.py
[stgit] / stgit / run.py
index 7986f3b..fa304d0 100644 (file)
@@ -19,9 +19,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 import datetime, os, subprocess
 
-from  stgit.out import *
+from stgit.exception import *
+from stgit.out import *
 
-class RunException(Exception):
+class RunException(StgException):
     """Thrown when something bad happened when we tried to run the
     subprocess."""
     pass
@@ -39,7 +40,7 @@ class Run:
         self.__cmd = list(cmd)
         for c in cmd:
             if type(c) != str:
-                raise Exception, 'Bad command: %r' % cmd
+                raise Exception, 'Bad command: %r' % (cmd,)
         self.__good_retvals = [0]
         self.__env = None
         self.__indata = None
@@ -57,6 +58,8 @@ class Run:
             duration = datetime.datetime.now() - self.__starttime
             out.done('%1.3f s' % (duration.microseconds/1e6 + duration.seconds))
     def __check_exitcode(self):
+        if self.__good_retvals == None:
+            return
         if self.exitcode not in self.__good_retvals:
             raise self.exc('%s failed with code %d'
                            % (self.__cmd[0], self.exitcode))
@@ -91,6 +94,9 @@ class Run:
     def returns(self, retvals):
         self.__good_retvals = retvals
         return self
+    def discard_exitcode(self):
+        self.__good_retvals = None
+        return self
     def discard_stderr(self, discard = True):
         self.__discard_stderr = discard
         return self