From 2e894477c830e3b18aa6b8c19efbc074e667e8a1 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 15 Dec 2016 16:45:28 +0100 Subject: Make Debug mode a build-time option instead of a hardcoded value --- CMakeLists.txt | 1 + cura/CrashHandler.py | 10 ++++++---- cura/CuraVersion.py.in | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 002662152e..ab08a4d624 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY add_custom_target(tests) add_custom_command(TARGET tests POST_BUILD COMMAND "PYTHONPATH=${CMAKE_SOURCE_DIR}/../Uranium/:${CMAKE_SOURCE_DIR}" ${PYTHON_EXECUTABLE} -m pytest -r a --junitxml=${CMAKE_BINARY_DIR}/junit.xml ${CMAKE_SOURCE_DIR} || exit 0) +option(CURA_DEBUGMODE "Enable debug dialog and other debug features" OFF) set(CURA_VERSION "master" CACHE STRING "Version name of Cura") set(CURA_BUILDTYPE "" CACHE STRING "Build type of Cura, eg. 'PPA'") diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py index 94b1971bdf..ba8499d4f2 100644 --- a/cura/CrashHandler.py +++ b/cura/CrashHandler.py @@ -12,6 +12,11 @@ from UM.Logger import Logger from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") +try: + from cura.CuraVersion import CuraDebugMode +except ImportError: + CuraDebugMode = False # [CodeStyle: Reflecting imported value] + # 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 @@ -24,21 +29,18 @@ fatal_exception_types = [ ] def show(exception_type, value, tb): - debug_mode = True - 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 debug_mode and exception_type not in fatal_exception_types: + if not CuraDebugMode and exception_type not in fatal_exception_types: return application = QCoreApplication.instance() if not application: sys.exit(1) - dialog = QDialog() dialog.setMinimumWidth(640) dialog.setMinimumHeight(640) diff --git a/cura/CuraVersion.py.in b/cura/CuraVersion.py.in index 5ad819b1fc..8a4d13e526 100644 --- a/cura/CuraVersion.py.in +++ b/cura/CuraVersion.py.in @@ -2,4 +2,5 @@ # Cura is released under the terms of the AGPLv3 or higher. CuraVersion = "@CURA_VERSION@" -CuraBuildType = "@CURA_BUILDTYPE@" \ No newline at end of file +CuraBuildType = "@CURA_BUILDTYPE@" +CuraDebugMode = True if "@CURA_DEBUGMODE@" == "ON" else False -- cgit v1.2.3