Last active
March 3, 2021 19:04
-
-
Save maphew/e3a75c147cca98019cd8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
debug = True | |
def exceptionHandler(exception_type, exception, traceback, debug_hook=sys.excepthook): | |
'''Print user friendly error messages normally, full traceback if DEBUG on. | |
Adapted from http://stackoverflow.com/questions/27674602/hide-traceback-unless-a-debug-flag-is-set | |
''' | |
if debug: | |
print '\n*** Error:' | |
# raise | |
debug_hook(exception_type, exception, traceback) | |
else: | |
print "\t%s: %s" % (exception_type.__name__, exception) | |
sys.excepthook = exceptionHandler | |
if __name__ == '__main__': | |
their_md5 = 'c38f03d2b7160f891fc36ec776ca4685' | |
my_md5 = 'c64e53bbb108a1c65e31eb4d1bb8e3b7' | |
if their_md5 != my_md5: | |
raise ValueError('md5 sum does not match!') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rev5: working implementation, as per Reut's example