python类_excepthook()的实例源码

__main__.py 文件源码 项目:smhr 作者: andycasey 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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
sandbox_synth.py 文件源码 项目:smhr 作者: andycasey 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
sandbox_main.py 文件源码 项目:smhr 作者: andycasey 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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
__main__.py 文件源码 项目:fatego-auto 作者: lishunan246 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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)
__main__.py 文件源码 项目:fatego-auto 作者: lishunan246 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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")
MainWindow.py 文件源码 项目:PySAT_Point_Spectra_GUI 作者: USGS-Astrogeology 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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_())
excepthook.py 文件源码 项目:PySAT_Point_Spectra_GUI 作者: USGS-Astrogeology 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)
test_inspector.py 文件源码 项目:inspector 作者: WattyAB 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def handler(self, exctype, value, traceback):
        global failure_
        self.errorSignal.emit()
        failure_ = (exctype, value, traceback)
        sys._excepthook(exctype, value, traceback)


问题


面经


文章

微信
公众号

扫码关注公众号