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
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
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))
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