Python sys._excepthook() Examples

The following are code examples for showing how to use sys._excepthook(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: smhr   Author: andycasey   File: __main__.py    (license) View Source Project 5 votes vote down vote up
def exception_hook(exception_type, message, traceback):
        """
        An exception hook that will display a GUI and optionally allow the user
        to submit a GitHub issue.

        :param exception_type:
            The type of exception that was raised.

        :param message:
            The exception message.

        :param traceback:
            The traceback of the exception.
        """

        # Show the exception in the terminal.
        sys._excepthook(exception_type, message, traceback)

        # Should this exception be ignored?
        if message.__repr__() in ignore_exception_messages:
            return None

        # Load a GUI that shows the exception.
        exception_gui = exception.ExceptionWidget(
            exception_type, message, traceback)
        exception_gui.exec_()

        # Ignore future exceptions of this kind?
        if exception_gui.ignore_in_future:
            ignore_exception_messages.append(message.__repr__())

        return None 
Example 2
Project: smhr   Author: andycasey   File: sandbox_synth.py    (license) View Source Project 5 votes vote down vote up
def exception_hook(exception_type, message, traceback):
        """
        An exception hook that will display a GUI and optionally allow the user
        to submit a GitHub issue.

        :param exception_type:
            The type of exception that was raised.

        :param message:
            The exception message.

        :param traceback:
            The traceback of the exception.
        """

        # Show the exception in the terminal.
        sys._excepthook(exception_type, message, traceback)

        # Should this exception be ignored?
        if message.__repr__() in ignore_exception_messages:
            return None

        # Load a GUI that shows the exception.
        exception_gui = exception.ExceptionWidget(
            exception_type, message, traceback)
        exception_gui.exec_()

        # Ignore future exceptions of this kind?
        if exception_gui.ignore_in_future:
            ignore_exception_messages.append(message.__repr__())

        return None 
Example 3
Project: smhr   Author: andycasey   File: sandbox_main.py    (license) View Source Project 5 votes vote down vote up
def exception_hook(exception_type, message, traceback):
        """
        An exception hook that will display a GUI and optionally allow the user
        to submit a GitHub issue.

        :param exception_type:
            The type of exception that was raised.

        :param message:
            The exception message.

        :param traceback:
            The traceback of the exception.
        """

        # Show the exception in the terminal.
        sys._excepthook(exception_type, message, traceback)

        # Should this exception be ignored?
        if message.__repr__() in ignore_exception_messages:
            return None

        # Load a GUI that shows the exception.
        exception_gui = exception.ExceptionWidget(
            exception_type, message, traceback)
        exception_gui.exec_()

        # Ignore future exceptions of this kind?
        if exception_gui.ignore_in_future:
            ignore_exception_messages.append(message.__repr__())

        return None 
Example 4
Project: fatego-auto   Author: lishunan246   File: __main__.py    (license) View Source Project 5 votes vote down vote up
def my_exception_hook(exception_type, value, traceback):
    # Print the error and traceback
    print(exception_type, value, traceback)
    # Call the normal Exception hook after
    sys._excepthook(exception_type, value, traceback)
    sys.exit(1) 
Example 5
Project: fatego-auto   Author: lishunan246   File: __main__.py    (license) View Source Project 5 votes vote down vote up
def main():
    print("init")

    sys._excepthook = sys.excepthook
    sys.excepthook = my_exception_hook

    app = QApplication(sys.argv)
    win = MainWindow()
    # noinspection PyBroadException
    try:
        sys.exit(app.exec_())
    except:
        print("Exiting") 
Example 6
Project: PySAT_Point_Spectra_GUI   Author: USGS-Astrogeology   File: MainWindow.py    (license) View Source Project 5 votes vote down vote up
def main():
    sys._excepthook = sys.excepthook
    sys.excepthook = my_exception_hook
    app = QtWidgets.QApplication(sys.argv)
    get_splash(app)
    setDarkmode(app)
    mainWindow = QtWidgets.QMainWindow()
    ui = MainWindow()
    ui.setupUi(mainWindow)
    mainWindow.show()
    sys.exit(app.exec_()) 
Example 7
Project: PySAT_Point_Spectra_GUI   Author: USGS-Astrogeology   File: excepthook.py    (license) View Source Project 5 votes vote down vote up
def my_exception_hook(exctype, value, traceback):
    # Print the error and traceback
    print(exctype, value, traceback)
    # Call the normal Exception hook after
    sys._excepthook(exctype, value, traceback)
    sys.exit(1) 
Example 8
Project: inspector   Author: WattyAB   File: test_inspector.py    (license) View Source Project 5 votes vote down vote up
def handler(self, exctype, value, traceback):
        global failure_
        self.errorSignal.emit()
        failure_ = (exctype, value, traceback)
        sys._excepthook(exctype, value, traceback)