mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 13:39:00 +08:00
Merge branch 'master-sentry_sdk-try-except' of https://github.com/thopiekar/Cura
This commit is contained in:
commit
5083a46c04
@ -12,9 +12,13 @@ import json
|
|||||||
import locale
|
import locale
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
|
try:
|
||||||
from sentry_sdk.hub import Hub
|
from sentry_sdk.hub import Hub
|
||||||
from sentry_sdk.utils import event_from_exception
|
from sentry_sdk.utils import event_from_exception
|
||||||
from sentry_sdk import configure_scope
|
from sentry_sdk import configure_scope
|
||||||
|
with_sentry_sdk = True
|
||||||
|
except ImportError:
|
||||||
|
with_sentry_sdk = False
|
||||||
|
|
||||||
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QUrl
|
from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QUrl
|
||||||
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton
|
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton
|
||||||
@ -66,6 +70,7 @@ class CrashHandler:
|
|||||||
if has_started and exception_type in skip_exception_types:
|
if has_started and exception_type in skip_exception_types:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if with_sentry_sdk:
|
||||||
with configure_scope() as scope:
|
with configure_scope() as scope:
|
||||||
scope.set_tag("during_startup", not has_started)
|
scope.set_tag("during_startup", not has_started)
|
||||||
|
|
||||||
@ -203,6 +208,7 @@ class CrashHandler:
|
|||||||
layout.addWidget(label)
|
layout.addWidget(label)
|
||||||
group.setLayout(layout)
|
group.setLayout(layout)
|
||||||
|
|
||||||
|
if with_sentry_sdk:
|
||||||
with configure_scope() as scope:
|
with configure_scope() as scope:
|
||||||
scope.set_tag("qt_version", QT_VERSION_STR)
|
scope.set_tag("qt_version", QT_VERSION_STR)
|
||||||
scope.set_tag("pyqt_version", PYQT_VERSION_STR)
|
scope.set_tag("pyqt_version", PYQT_VERSION_STR)
|
||||||
@ -247,6 +253,7 @@ class CrashHandler:
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if with_sentry_sdk:
|
||||||
with configure_scope() as scope:
|
with configure_scope() as scope:
|
||||||
scope.set_tag("opengl_version", opengl_instance.getOpenGLVersion())
|
scope.set_tag("opengl_version", opengl_instance.getOpenGLVersion())
|
||||||
scope.set_tag("gpu_vendor", opengl_instance.getGPUVendorName())
|
scope.set_tag("gpu_vendor", opengl_instance.getGPUVendorName())
|
||||||
@ -335,6 +342,7 @@ class CrashHandler:
|
|||||||
"module_name": module_name, "version": module_version, "is_plugin": isPlugin}
|
"module_name": module_name, "version": module_version, "is_plugin": isPlugin}
|
||||||
self.data["exception"] = exception_dict
|
self.data["exception"] = exception_dict
|
||||||
|
|
||||||
|
if with_sentry_sdk:
|
||||||
with configure_scope() as scope:
|
with configure_scope() as scope:
|
||||||
scope.set_tag("is_plugin", isPlugin)
|
scope.set_tag("is_plugin", isPlugin)
|
||||||
scope.set_tag("module", module_name)
|
scope.set_tag("module", module_name)
|
||||||
@ -396,6 +404,7 @@ class CrashHandler:
|
|||||||
# Before sending data, the user comments are stored
|
# Before sending data, the user comments are stored
|
||||||
self.data["user_info"] = self.user_description_text_area.toPlainText()
|
self.data["user_info"] = self.user_description_text_area.toPlainText()
|
||||||
|
|
||||||
|
if with_sentry_sdk:
|
||||||
try:
|
try:
|
||||||
hub = Hub.current
|
hub = Hub.current
|
||||||
event, hint = event_from_exception((self.exception_type, self.value, self.traceback))
|
event, hint = event_from_exception((self.exception_type, self.value, self.traceback))
|
||||||
@ -405,6 +414,14 @@ class CrashHandler:
|
|||||||
Logger.logException("e", "An exception occurred while trying to send crash report")
|
Logger.logException("e", "An exception occurred while trying to send crash report")
|
||||||
if not self.has_started:
|
if not self.has_started:
|
||||||
print("An exception occurred while trying to send crash report: %s" % e)
|
print("An exception occurred while trying to send crash report: %s" % e)
|
||||||
|
else:
|
||||||
|
msg = "SentrySDK is not available and the report could not be sent."
|
||||||
|
Logger.logException("e", msg)
|
||||||
|
if not self.has_started:
|
||||||
|
print(msg)
|
||||||
|
print("Exception type: {}".format(self.exception_type))
|
||||||
|
print("Value: {}".format(self.value))
|
||||||
|
print("Traceback: {}".format(self.traceback))
|
||||||
|
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
|
@ -12,7 +12,11 @@ from UM.Platform import Platform
|
|||||||
from cura import ApplicationMetadata
|
from cura import ApplicationMetadata
|
||||||
from cura.ApplicationMetadata import CuraAppName
|
from cura.ApplicationMetadata import CuraAppName
|
||||||
|
|
||||||
|
try:
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
|
with_sentry_sdk = True
|
||||||
|
except ImportError:
|
||||||
|
with_sentry_sdk = False
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog = "cura",
|
parser = argparse.ArgumentParser(prog = "cura",
|
||||||
add_help = False)
|
add_help = False)
|
||||||
@ -24,6 +28,7 @@ parser.add_argument("--debug",
|
|||||||
|
|
||||||
known_args = vars(parser.parse_known_args()[0])
|
known_args = vars(parser.parse_known_args()[0])
|
||||||
|
|
||||||
|
if with_sentry_sdk:
|
||||||
sentry_env = "production"
|
sentry_env = "production"
|
||||||
if ApplicationMetadata.CuraVersion == "master":
|
if ApplicationMetadata.CuraVersion == "master":
|
||||||
sentry_env = "development"
|
sentry_env = "development"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user