<s> import sys <EOL> def exception_string ( ) : <EOL> import traceback <EOL> return '<STR_LIT:\n>' . join ( traceback . format_exception ( * sys . exc_info ( ) ) ) <EOL> def print_exception ( ) : <EOL> print "<STR_LIT>" <EOL> print exception_string ( ) <EOL> print "<STR_LIT>" <EOL> def silence_print ( ) : <EOL> old_printerators = [ sys . stdout , sys . stderr , sys . stdin , sys . __stdout__ , sys . __stderr__ , sys . __stdin__ ] [ : ] <EOL> sys . stdout , sys . stderr , sys . stdin , sys . __stdout__ , sys . __stderr__ , sys . __stdin__ = dummyStream ( ) , dummyStream ( ) , dummyStream ( ) , dummyStream ( ) , dummyStream ( ) , dummyStream ( ) <EOL> return old_printerators <EOL> def unsilence_print ( printerators ) : <EOL> sys . stdout , sys . stderr , sys . stdin , sys . __stdout__ , sys . __stderr__ , sys . __stdin__ = printerators <EOL> class dummyStream : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self ) : pass <EOL> def write ( self , data ) : pass <EOL> def read ( self , data ) : pass <EOL> def flush ( self ) : pass <EOL> def close ( self ) : pass <EOL> def noprint ( func ) : <EOL> def wrapper ( * args , ** kw ) : <EOL> _p = silence_print ( ) <EOL> output = func ( * args , ** kw ) <EOL> unsilence_print ( _p ) <EOL> return output <EOL> return wrapper </s>
