Python sys 模块,_excepthook() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用sys._excepthook()

项目:smhr    作者:andycasey    | 项目源码 | 文件源码
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
项目:smhr    作者:andycasey    | 项目源码 | 文件源码
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
项目:smhr    作者:andycasey    | 项目源码 | 文件源码
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
项目:fatego-auto    作者:lishunan246    | 项目源码 | 文件源码
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)
项目:fatego-auto    作者:lishunan246    | 项目源码 | 文件源码
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")
项目:PySAT_Point_Spectra_GUI    作者:USGS-Astrogeology    | 项目源码 | 文件源码
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_())
项目:PySAT_Point_Spectra_GUI    作者:USGS-Astrogeology    | 项目源码 | 文件源码
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)
项目:inspector    作者:WattyAB    | 项目源码 | 文件源码
def handler(self, exctype, value, traceback):
        global failure_
        self.errorSignal.emit()
        failure_ = (exctype, value, traceback)
        sys._excepthook(exctype, value, traceback)