<s> import sys <EOL> import traceback <EOL> from bugsnag . configuration import Configuration , RequestConfiguration <EOL> from bugsnag . notification import Notification <EOL> configuration = Configuration ( ) <EOL> def configure ( ** options ) : <EOL> """<STR_LIT>""" <EOL> configuration . configure ( ** options ) <EOL> def configure_request ( ** options ) : <EOL> """<STR_LIT>""" <EOL> RequestConfiguration . get_instance ( ) . configure ( ** options ) <EOL> def add_metadata_tab ( tab_name , data ) : <EOL> """<STR_LIT>""" <EOL> meta_data = RequestConfiguration . get_instance ( ) . meta_data <EOL> if tab_name not in meta_data : <EOL> meta_data [ tab_name ] = { } <EOL> meta_data [ tab_name ] . update ( data ) <EOL> def clear_request_config ( ) : <EOL> """<STR_LIT>""" <EOL> RequestConfiguration . clear ( ) <EOL> def notify ( exception , ** options ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> if isinstance ( exception , ( list , tuple ) ) : <EOL> if "<STR_LIT>" not in options : <EOL> options [ "<STR_LIT>" ] = exception [ <NUM_LIT:2> ] <EOL> Notification ( exception [ <NUM_LIT:1> ] , configuration , <EOL> RequestConfiguration . get_instance ( ) , <EOL> ** options ) . deliver ( ) <EOL> else : <EOL> Notification ( exception , configuration , <EOL> RequestConfiguration . get_instance ( ) , <EOL> ** options ) . deliver ( ) <EOL> except Exception : <EOL> try : <EOL> log ( "<STR_LIT>" ) <EOL> print ( ( traceback . format_exc ( ) ) ) <EOL> except Exception : <EOL> print ( ( "<STR_LIT>" ) ) <EOL> print ( ( traceback . format_exc ( ) ) ) <EOL> def auto_notify ( exception , ** options ) : <EOL> """<STR_LIT>""" <EOL> if configuration . auto_notify : <EOL> notify ( exception , severity = "<STR_LIT:error>" , ** options ) <EOL> def before_notify ( callback ) : <EOL> """<STR_LIT>""" <EOL> configuration . middleware . before_notify ( callback ) <EOL> def log ( message ) : <EOL> """<STR_LIT>""" <EOL> print ( ( "<STR_LIT>" % message ) ) <EOL> def warn ( message ) : <EOL> """<STR_LIT>""" <EOL> sys . stderr . write ( "<STR_LIT>" % message ) <EOL> def __bugsnag_excepthook ( exctype , exception , traceback ) : <EOL> try : <EOL> auto_notify ( exception , traceback = traceback ) <EOL> except : <EOL> print ( ( "<STR_LIT>" ) ) <EOL> pass <EOL> _old_excepthook ( exctype , exception , traceback ) <EOL> _old_excepthook = sys . excepthook <EOL> sys . excepthook = __bugsnag_excepthook </s>
