Merge branch 'master' into workaround_kde_qqc2_crash

This commit is contained in:
StefanBruens 2020-12-08 15:03:50 +01:00 committed by GitHub
commit b800815378
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3946 changed files with 417413 additions and 550255 deletions

View file

@ -1,16 +1,35 @@
#!/usr/bin/env python3
# Copyright (c) 2019 Ultimaker B.V.
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
# Remove the working directory from sys.path.
# This fixes a security issue where Cura could import Python packages from the
# current working directory, and therefore be made to execute locally installed
# code (e.g. in the user's home directory where AppImages by default run from).
# See issue CURA-7081.
import sys
if "" in sys.path:
sys.path.remove("")
import argparse
import faulthandler
import os
import sys
# Workaround for a race condition on certain systems where there
# is a race condition between Arcus and PyQt. Importing Arcus
# first seems to prevent Sip from going into a state where it
# tries to create PyQt objects on a non-main thread.
import Arcus # @UnusedImport
import Savitar # @UnusedImport
import pynest2d # @UnusedImport
from PyQt5.QtNetwork import QSslConfiguration, QSslSocket
from UM.Platform import Platform
from cura import ApplicationMetadata
from cura.ApplicationMetadata import CuraAppName
from cura.CrashHandler import CrashHandler
try:
import sentry_sdk
@ -21,7 +40,7 @@ except ImportError:
parser = argparse.ArgumentParser(prog = "cura",
add_help = False)
parser.add_argument("--debug",
action="store_true",
action = "store_true",
default = False,
help = "Turn on the debug mode by setting this option."
)
@ -31,24 +50,31 @@ known_args = vars(parser.parse_known_args()[0])
if with_sentry_sdk:
sentry_env = "unknown" # Start off with a "IDK"
if hasattr(sys, "frozen"):
sentry_env = "production" # A frozen build has the posibility to be a "real" distribution.
sentry_env = "production" # A frozen build has the possibility to be a "real" distribution.
if ApplicationMetadata.CuraVersion == "master":
sentry_env = "development" # Master is always a development version.
elif ApplicationMetadata.CuraVersion in ["beta", "BETA"]:
elif "beta" in ApplicationMetadata.CuraVersion or "BETA" in ApplicationMetadata.CuraVersion:
sentry_env = "beta"
try:
if ApplicationMetadata.CuraVersion.split(".")[2] == "99":
sentry_env = "nightly"
except IndexError:
pass
sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564",
environment = sentry_env,
release = "cura%s" % ApplicationMetadata.CuraVersion,
default_integrations = False,
max_breadcrumbs = 300,
server_name = "cura")
# Errors to be ignored by Sentry
ignore_errors = [KeyboardInterrupt, MemoryError]
try:
sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564",
before_send = CrashHandler.sentryBeforeSend,
environment = sentry_env,
release = "cura%s" % ApplicationMetadata.CuraVersion,
default_integrations = False,
max_breadcrumbs = 300,
server_name = "cura",
ignore_errors = ignore_errors)
except Exception:
with_sentry_sdk = False
if not known_args["debug"]:
def get_cura_dir_path():
@ -161,18 +187,11 @@ def exceptHook(hook_type, value, traceback):
# Set exception hook to use the crash dialog handler
sys.excepthook = exceptHook
# Enable dumping traceback for all threads
if sys.stderr:
if sys.stderr and not sys.stderr.closed:
faulthandler.enable(file = sys.stderr, all_threads = True)
elif sys.stdout:
elif sys.stdout and not sys.stdout.closed:
faulthandler.enable(file = sys.stdout, all_threads = True)
# Workaround for a race condition on certain systems where there
# is a race condition between Arcus and PyQt. Importing Arcus
# first seems to prevent Sip from going into a state where it
# tries to create PyQt objects on a non-main thread.
import Arcus #@UnusedImport
import Savitar #@UnusedImport
from cura.CuraApplication import CuraApplication
@ -213,5 +232,10 @@ if Platform.isLinux() and getattr(sys, "frozen", False):
if Platform.isLinux():
os.environ["QT_QUICK_CONTROLS_STYLE"] = "default"
if ApplicationMetadata.CuraDebugMode:
ssl_conf = QSslConfiguration.defaultConfiguration()
ssl_conf.setPeerVerifyMode(QSslSocket.VerifyNone)
QSslConfiguration.setDefaultConfiguration(ssl_conf)
app = CuraApplication()
app.run()