biosimulators / Biosimulators_utils

Utilities for building standardized command-line interfaces for biosimulation software packages
https://docs.biosimulators.org/Biosimulators_utils
MIT License
4 stars 6 forks source link

Expand capabilities of execution status logging #15

Closed jonrkarr closed 3 years ago

jonrkarr commented 3 years ago

BioSimulators utils

tellurium

jonrkarr commented 3 years ago

Code to highlight unhandled exceptions

def set_highlighted_excepthook():
    import sys, traceback
    from pygments import highlight
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters import TerminalFormatter

    lexer = get_lexer_by_name("pytb" if sys.version_info.major < 3 else "py3tb")
    formatter = TerminalFormatter()

    def myexcepthook(type, value, tb):
        tbtext = ''.join(traceback.format_exception(type, value, tb))
        sys.stderr.write(highlight(tbtext, lexer, formatter))

    sys.excepthook = myexcepthook

set_highlighted_excepthook()
jonrkarr commented 3 years ago

Done. The changes to the simulators just need to be pushed.

jonrkarr commented 3 years ago

Simulators are pushed with the expanded logging capabilities.