<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import tempfile <EOL> import traceback <EOL> from time import strftime <EOL> import sublime <EOL> from nimlime_core import settings <EOL> from nimlime_core . utils . misc import exec_ , format_msg <EOL> error_msg = format_msg ( """<STR_LIT>""" ) <EOL> critical_error_msg = format_msg ( """<STR_LIT>""" ) <EOL> default_logfile_path = tempfile . gettempdir ( ) <EOL> enabled = True <EOL> logfile_path = default_logfile_path <EOL> notified_user = False <EOL> def _load ( ) : <EOL> global notified_user , enabled , logfile_path <EOL> notified_user = False <EOL> enabled = settings . get ( '<STR_LIT>' , True ) <EOL> if not enabled : <EOL> return <EOL> logfile_path = settings . get ( '<STR_LIT>' ) <EOL> logfile_path = logfile_path or default_logfile_path <EOL> logfile_path = os . path . join ( logfile_path , '<STR_LIT>' ) <EOL> try : <EOL> open ( logfile_path , '<STR_LIT>' ) . close ( ) <EOL> except Exception : <EOL> notified_user = True <EOL> sublime . error_message ( critical_error_msg . format ( logfile_path ) ) <EOL> settings . run_on_load_and_change ( '<STR_LIT>' , _load ) <EOL> generator_error_handler_impl = """<STR_LIT>""" <EOL> other_error_handler_impl = """<STR_LIT>""" <EOL> catch_errors = None <EOL> error_wrapper_impl = """<STR_LIT>""" <EOL> if sys . version_info >= ( <NUM_LIT:3> , <NUM_LIT:0> ) : <EOL> exec_ ( error_wrapper_impl . format ( generator_error_handler_impl ) ) <EOL> else : <EOL> exec_ ( error_wrapper_impl . format ( other_error_handler_impl ) ) <EOL> def _handle_error ( ) : <EOL> global notified_user , error_msg , critical_error_msg <EOL> try : <EOL> with open ( logfile_path , '<STR_LIT>' ) as logfile : <EOL> logfile . write ( strftime ( "<STR_LIT>" ) ) <EOL> logfile . write ( "<STR_LIT>" ) <EOL> for thread_id , stack_frame in sys . _current_frames ( ) . items ( ) : <EOL> logfile . write ( "<STR_LIT>" . format ( thread_id ) ) <EOL> traceback . print_stack ( stack_frame , file = logfile ) <EOL> logfile . write ( "<STR_LIT>" ) <EOL> traceback . print_exc ( file = logfile ) <EOL> message = error_msg <EOL> except Exception : <EOL> print ( "<STR_LIT>" ) <EOL> traceback . print_exc ( ) <EOL> message = critical_error_msg <EOL> if not notified_user : <EOL> sublime . error_message ( message . format ( logfile_path ) ) <EOL> notified_user = True <EOL> sublime . status_message ( "<STR_LIT>" ) </s>
