<s> """<STR_LIT>""" <EOL> import sys <EOL> from twisted . python import failure <EOL> from twisted . python . log import logerr <EOL> from coil . errors import StructError <EOL> NO_RESULT = object ( ) <EOL> class Failure ( failure . Failure ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , exc_value = None , exc_type = None , <EOL> exc_tb = None , result = NO_RESULT ) : <EOL> self . result = result <EOL> if exc_value is None : <EOL> type_ , value , tb = sys . exc_info ( ) <EOL> if issubclass ( type_ , TestError ) : <EOL> exc_value = value <EOL> exc_type = type_ <EOL> exc_tb = None <EOL> failure . Failure . __init__ ( self , exc_value , exc_type , exc_tb ) <EOL> def printTraceback ( self , file = None , * args , ** kwargs ) : <EOL> if self . result is not NO_RESULT : <EOL> if file is None : <EOL> file = logerr <EOL> file . write ( "<STR_LIT>" ) <EOL> for line in str ( self . result ) . splitlines ( ) : <EOL> file . write ( "<STR_LIT>" % line ) <EOL> return failure . Failure . printTraceback ( self , file , * args , ** kwargs ) <EOL> def callback ( method ) : <EOL> """<STR_LIT>""" <EOL> def catcher ( self , result , * args , ** kwargs ) : <EOL> try : <EOL> return method ( self , result , * args , ** kwargs ) <EOL> except : <EOL> if isinstance ( result , failure . Failure ) : <EOL> return Failure ( ) <EOL> else : <EOL> return Failure ( result = result ) <EOL> return catcher <EOL> class TestError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> state = "<STR_LIT>" <EOL> index = <NUM_LIT:3> <EOL> class TestAbort ( TestError ) : <EOL> pass <EOL> class TestUnknown ( TestError ) : <EOL> pass <EOL> class TestCritical ( TestError ) : <EOL> state = "<STR_LIT>" <EOL> index = <NUM_LIT:2> <EOL> class TestWarning ( TestError ) : <EOL> state = "<STR_LIT>" <EOL> index = <NUM_LIT:1> <EOL> class TestOK ( TestError ) : <EOL> state = "<STR_LIT:OK>" <EOL> index = <NUM_LIT:0> <EOL> class ConfigError ( StructError ) : <EOL> """<STR_LIT>""" <EOL> class InitError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class PipeError ( Exception ) : <EOL> """<STR_LIT>""" </s>
