#NEWLINE# def evaluate( self , code ) : #NEWLINE# #INDENT# if ( not code . strip ( ) ) : #NEWLINE# #INDENT# return ( None , '' ) #NEWLINE# #UNINDENT# log_id = output . new_log ( ) #NEWLINE# try : #NEWLINE# #INDENT# exp = self . scheme . read_line ( code ) #NEWLINE# result = timer . timed ( self . timeout , self . scheme . scheme_eval , ( exp , self . _frame ) ) #NEWLINE# #UNINDENT# except RuntimeError as e : #NEWLINE# #INDENT# stacktrace_length = 15 #NEWLINE# stacktrace = traceback . format_exc ( ) . strip ( ) . split ( '\n' ) #NEWLINE# print ( 'Traceback (most recent call last):\n  ...' ) #NEWLINE# print ( '\n' . join ( stacktrace [ ( - stacktrace_length ) : ] ) ) #NEWLINE# raise interpreter . ConsoleException ( e ) #NEWLINE# #UNINDENT# except exceptions . Timeout as e : #NEWLINE# #INDENT# print ( '# Error: evaluation exceeded {} seconds.' . format ( e . timeout ) ) #NEWLINE# raise interpreter . ConsoleException ( token ) #NEWLINE# #UNINDENT# except self . scheme . SchemeError as e : #NEWLINE# #INDENT# print ( '# Error: {}' . format ( e ) ) #NEWLINE# raise interpreter . ConsoleException ( e , exception_type = 'SchemeError' ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# stacktrace = traceback . format_exc ( ) #NEWLINE# token = '<module>\n' #NEWLINE# index = ( stacktrace . rfind ( token ) + len ( token ) ) #NEWLINE# stacktrace = stacktrace [ index : ] . rstrip ( '\n' ) #NEWLINE# if ( '\n' in stacktrace ) : #NEWLINE# #INDENT# print ( 'Traceback (most recent call last):' ) #NEWLINE# #UNINDENT# print ( stacktrace ) #NEWLINE# raise interpreter . ConsoleException ( e ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# printed_output = '' . join ( output . get_log ( log_id ) ) #NEWLINE# return ( result , printed_output ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# output . remove_log ( log_id )