import sys import platform import traceback import webbrowser import faulthandler import tempfile import os from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QCoreApplication from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox from PyQt5.QtNetwork import QHttpMultiPart, QHttpPart, QNetworkRequest, QNetworkAccessManager, QNetworkReply from UM.Logger import Logger from UM.View.GL.OpenGL import OpenGL from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") MYPY = False if MYPY: CuraDebugMode = False else: try: from cura.CuraVersion import CuraDebugMode except ImportError: CuraDebugMode = False # [CodeStyle: Reflecting imported value] CuraDebugMode = True ## TODO Remove when done. Just for debug purposes # List of exceptions that should be considered "fatal" and abort the program. # These are primarily some exception types that we simply cannot really recover from # (MemoryError and SystemError) and exceptions that indicate grave errors in the # code that cause the Python interpreter to fail (SyntaxError, ImportError). fatal_exception_types = [ MemoryError, SyntaxError, ImportError, SystemError, ] class CrashHandler: def __init__(self, exception_type, value, tb): self.exception_type = exception_type self.value = value self.traceback = tb Logger.log("c", "An uncaught exception has occurred!") for line in traceback.format_exception(exception_type, value, tb): for part in line.rstrip("\n").split("\n"): Logger.log("c", part) if not CuraDebugMode and exception_type not in fatal_exception_types: return application = QCoreApplication.instance() if not application: sys.exit(1) self._createDialog() ## Creates a modal dialog. def _createDialog(self): self.dialog = QDialog() self.dialog.setMinimumWidth(640) self.dialog.setMinimumHeight(640) self.dialog.setWindowTitle(catalog.i18nc("@title:window", "Crash Report")) layout = QVBoxLayout(self.dialog) layout.addWidget(self._messageWidget()) layout.addWidget(self._informationWidget()) layout.addWidget(self._exceptionInfoWidget()) layout.addWidget(self._logInfoWidget()) layout.addWidget(self._userDescriptionWidget()) layout.addWidget(self._buttonsWidget()) def _messageWidget(self): label = QLabel() label.setText(catalog.i18nc("@label", """
A fatal exception has occurred that we could not recover from!
Please use the button below to post a bug report automatically to our servers
""")) return label def _informationWidget(self): group = QGroupBox() group.setTitle("System information") layout = QVBoxLayout() label = QLabel() try: from UM.Application import Application version = Application.getInstance().getVersion() except: version = "Unknown" crash_info = "Version: {0}