def is_routine_fatal(exc):
"""Return string if exception is non-error unrecoverable, None otherwise
Used to suppress a stack trace for exceptions like keyboard
interrupts or connection drops. Return value is string to use as
an exit message.
"""
if isinstance(exc, exceptions.KeyboardInterrupt):
return "User abort"
elif isinstance(exc, connection.ConnectionError):
return "Lost connection to the remote system"
elif isinstance(exc, SignalException):
return "Killed with signal %s" % (exc,)
elif isinstance(exc, EnvironmentError) and exc.errno == errno.ENOTCONN:
return ("Filesystem reports connection failure:\n%s" % exc)
return None
评论列表
文章目录