signal.signal(signal.SIGPIPE, signal.SIG_DFL)
class CmdError(RuntimeError):
- def __init__(self, command):
+ def __init__(self, command, message=None):
self.command = command
+ self.message = message
def __str__(self):
if not isinstance(self.command, basestring):
else:
cmd = self.command
- return "Execution of '%s' failed" % cmd
+ msg = "Execution of '%s' failed" % cmd
+ if self.message:
+ msg += ': %s' % self.message
+ return msg
class NotFoundError(CmdError):
def __str__(self):
if exc.errno == 2:
raise NotFoundError(cmd)
else:
- raise
+ raise CmdError(cmd, exc)
if log:
stdout, stderr = _logged_communicate(pipe, log, input)