Browse Source

Merge branch 'Ultimaker:master' into master

3d-hctech 2 years ago
parent
commit
bb2be3b4d6

+ 0 - 13
.github/no-response.yml

@@ -1,13 +0,0 @@
-# Configuration for probot-no-response - https://github.com/probot/no-response
-
-# Number of days of inactivity before an Issue is closed for lack of response
-daysUntilClose: 14
-# Label requiring a response
-responseRequiredLabel: 'Status: Needs Info'
-# Comment to post when closing an Issue for lack of response. Set to `false` to disable
-closeComment: >
-  This issue has been automatically closed because there has been no response
-  to our request for more information from the original author. With only the
-  information that is currently in the issue, we don't have enough information
-  to take action. Please reach out if you have or find the answers we need so
-  that we can investigate further.

+ 31 - 0
.github/workflows/no-response.yml

@@ -0,0 +1,31 @@
+name: No Response
+
+# Both `issue_comment` and `scheduled` event types are required for this Action
+# to work properly.
+on:
+  issue_comment:
+    types: [created]
+  schedule:
+    # Schedule for ten minutes after the hour, every hour
+    - cron: '10 * * * *'
+
+# By specifying the access of one of the scopes, all of those that are not
+# specified are set to 'none'.
+permissions:
+  issues: write
+
+jobs:
+  noResponse:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: lee-dohm/no-response@v0.5.0
+        with:
+          token: ${{ github.token }}
+          daysUntilClose: 14
+          responseRequiredLabel: 'Status: Needs Info'
+          closeComment: >
+                This issue has been automatically closed because there has been no response
+                to our request for more information from the original author. With only the
+                information that is currently in the issue, we don't have enough information
+                to take action. Please reach out if you have or find the answers we need so
+                that we can investigate further.

+ 1 - 0
.gitignore

@@ -38,6 +38,7 @@ cura.desktop
 .settings
 
 #Externally located plug-ins commonly installed by our devs.
+plugins/BarbarianPlugin
 plugins/cura-big-flame-graph
 plugins/cura-camera-position
 plugins/cura-god-mode-plugin

+ 27 - 43
CMakeLists.txt

@@ -1,5 +1,8 @@
+# Copyright (c) 2022 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
 project(cura)
-cmake_minimum_required(VERSION 3.6)
+cmake_minimum_required(VERSION 3.18)
 
 include(GNUInstallDirs)
 
@@ -8,9 +11,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
 set(URANIUM_DIR "${CMAKE_SOURCE_DIR}/../Uranium" CACHE PATH "The location of the Uranium repository")
 set(URANIUM_SCRIPTS_DIR "${URANIUM_DIR}/scripts" CACHE PATH "The location of the scripts directory of the Uranium repository")
 
-# Tests
-include(CuraTests)
-
 option(CURA_DEBUGMODE "Enable debug dialog and other debug features" OFF)
 if(CURA_DEBUGMODE)
     set(_cura_debugmode "ON")
@@ -32,17 +32,25 @@ configure_file(${CMAKE_SOURCE_DIR}/com.ultimaker.cura.desktop.in ${CMAKE_BINARY_
 
 configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY)
 
+if(NOT DEFINED Python_VERSION)
+    set(Python_VERSION
+            3.10
+            CACHE STRING "Python Version" FORCE)
+    message(STATUS "Setting Python version to ${Python_VERSION}. Set Python_VERSION if you want to compile against an other version.")
+endif()
+if(APPLE)
+    set(Python_FIND_FRAMEWORK NEVER)
+endif()
+find_package(Python ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter)
+message(STATUS "Linking and building ${project_name} against Python ${Python_VERSION}")
+if(NOT DEFINED Python_SITELIB_LOCAL)
+    set(Python_SITELIB_LOCAL
+            "${Python_SITELIB}"
+            CACHE PATH "Local alternative site-package location to install Cura" FORCE)
+endif()
 
-# FIXME: The new FindPython3 finds the system's Python3.6 rather than the Python3.5 that we built for Cura's environment.
-# So we're using the old method here, with FindPythonInterp for now.
-find_package(PythonInterp 3 REQUIRED)
-
-set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
-
-set(Python3_VERSION ${PYTHON_VERSION_STRING})
-set(Python3_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
-set(Python3_VERSION_MINOR ${PYTHON_VERSION_MINOR})
-set(Python3_VERSION_PATCH ${PYTHON_VERSION_PATCH})
+# Tests
+include(CuraTests)
 
 if(NOT ${URANIUM_DIR} STREQUAL "")
     set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${URANIUM_DIR}/cmake")
@@ -58,30 +66,15 @@ if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
     endif()
 endif()
 
-
-install(DIRECTORY resources
-        DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
+install(DIRECTORY resources DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
 
 include(CuraPluginInstall)
 
+install(FILES cura_app.py DESTINATION ${CMAKE_INSTALL_BINDIR}
+        PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+install(DIRECTORY cura DESTINATION "${Python_SITELIB_LOCAL}")
+install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py DESTINATION "${Python_SITELIB_LOCAL}/cura/")
 if(NOT APPLE AND NOT WIN32)
-    install(FILES cura_app.py
-            DESTINATION ${CMAKE_INSTALL_BINDIR}
-            PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
-            RENAME cura)
-    if(EXISTS /etc/debian_version)
-        install(DIRECTORY cura
-            DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}/dist-packages
-            FILES_MATCHING PATTERN *.py)
-        install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
-            DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}/dist-packages/cura)
-    else()
-        install(DIRECTORY cura
-            DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages
-            FILES_MATCHING PATTERN *.py)
-        install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
-            DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/cura)
-    endif()
     install(FILES ${CMAKE_BINARY_DIR}/com.ultimaker.cura.desktop
             DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
     install(FILES ${CMAKE_SOURCE_DIR}/resources/images/cura-icon.png
@@ -91,13 +84,4 @@ if(NOT APPLE AND NOT WIN32)
     install(FILES cura.sharedmimeinfo
             DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages/
             RENAME cura.xml )
-else()
-    install(FILES cura_app.py
-            DESTINATION ${CMAKE_INSTALL_BINDIR}
-            PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-    install(DIRECTORY cura
-            DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages
-            FILES_MATCHING PATTERN *.py)
-    install(FILES ${CMAKE_BINARY_DIR}/CuraVersion.py
-            DESTINATION lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/cura)
 endif()

+ 5 - 0
SECURITY.md

@@ -0,0 +1,5 @@
+# Reporting vulnerabilities
+
+If you discover a vulnerability, please let us know as soon as possible via `security@ultimaker.com`.
+Please do not take advantage of the vulnerability and do not reveal the problem to others.
+To allow us to resolve the issue, please do provide us with sufficient information to reproduce the problem.

+ 2 - 15
cmake/CuraPluginInstall.cmake

@@ -1,4 +1,4 @@
-# Copyright (c) 2019 Ultimaker B.V.
+# Copyright (c) 2022 Ultimaker B.V.
 # CuraPluginInstall.cmake is released under the terms of the LGPLv3 or higher.
 
 #
@@ -11,19 +11,6 @@
 
 option(PRINT_PLUGIN_LIST "Should the list of plugins that are installed be printed?" ON)
 
-# FIXME: Remove the code for CMake <3.12 once we have switched over completely.
-# FindPython3 is a new module since CMake 3.12. It deprecates FindPythonInterp and FindPythonLibs. The FindPython3
-# module is copied from the CMake repository here so in CMake <3.12 we can still use it.
-if(${CMAKE_VERSION} VERSION_LESS 3.12)
-    # Use FindPythonInterp and FindPythonLibs for CMake <3.12
-    find_package(PythonInterp 3 REQUIRED)
-
-    set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
-else()
-    # Use FindPython3 for CMake >=3.12
-    find_package(Python3 REQUIRED COMPONENTS Interpreter)
-endif()
-
 # Options or configuration variables
 set(CURA_NO_INSTALL_PLUGINS "" CACHE STRING "A list of plugins that should not be installed, separated with ';' or ','.")
 
@@ -97,7 +84,7 @@ foreach(_plugin_json_path ${_plugin_json_list})
         if(${PRINT_PLUGIN_LIST})
             message(STATUS "[-] PLUGIN TO REMOVE : ${_rel_plugin_dir}")
         endif()
-        execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/mod_bundled_packages_json.py
+        execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/mod_bundled_packages_json.py
                         -d ${CMAKE_CURRENT_SOURCE_DIR}/resources/bundled_packages
                         ${_plugin_dir_name}
                         RESULT_VARIABLE _mod_json_result)

+ 5 - 11
cmake/CuraTests.cmake

@@ -1,15 +1,9 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2022 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 include(CTest)
 include(CMakeParseArguments)
 
-# FIXME: The new FindPython3 finds the system's Python3.6 rather than the Python3.5 that we built for Cura's environment.
-# So we're using the old method here, with FindPythonInterp for now.
-find_package(PythonInterp 3 REQUIRED)
-
-set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
-
 add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
 
 function(cura_add_test)
@@ -40,7 +34,7 @@ function(cura_add_test)
     if (NOT ${test_exists})
         add_test(
             NAME ${_NAME}
-            COMMAND ${Python3_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY}
+            COMMAND ${Python_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY}
         )
         set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT LANG=C)
         set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT "PYTHONPATH=${_PYTHONPATH}")
@@ -53,14 +47,14 @@ endfunction()
 #Add code style test.
 add_test(
     NAME "code-style"
-    COMMAND ${Python3_EXECUTABLE} run_mypy.py
+    COMMAND ${Python_EXECUTABLE} run_mypy.py
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 )
 
 #Add test for import statements which are not compatible with all builds
 add_test(
     NAME "invalid-imports"
-    COMMAND ${Python3_EXECUTABLE} scripts/check_invalid_imports.py
+    COMMAND ${Python_EXECUTABLE} scripts/check_invalid_imports.py
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 )
 
@@ -78,6 +72,6 @@ endforeach()
 #Add test for whether the shortcut alt-keys are unique in every translation.
 add_test(
     NAME "shortcut-keys"
-    COMMAND ${Python3_EXECUTABLE} scripts/check_shortcut_keys.py
+    COMMAND ${Python_EXECUTABLE} scripts/check_shortcut_keys.py
     WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 )

+ 6 - 6
cura/API/Account.py

@@ -1,8 +1,8 @@
 # Copyright (c) 2021 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
-
+import enum
 from datetime import datetime
-from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QTimer, Q_ENUMS
+from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QTimer, pyqtEnum
 from typing import Any, Optional, Dict, TYPE_CHECKING, Callable
 
 from UM.Logger import Logger
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
 i18n_catalog = i18nCatalog("cura")
 
 
-class SyncState:
+class SyncState(enum.IntEnum):
     """QML: Cura.AccountSyncState"""
     SYNCING = 0
     SUCCESS = 1
@@ -41,7 +41,7 @@ class Account(QObject):
 
     # The interval in which sync services are automatically triggered
     SYNC_INTERVAL = 60.0  # seconds
-    Q_ENUMS(SyncState)
+    pyqtEnum(SyncState)
 
     loginStateChanged = pyqtSignal(bool)
     """Signal emitted when user logged in or out"""
@@ -269,10 +269,10 @@ class Account(QObject):
         return self._authorization_service.getAccessToken()
 
     @pyqtProperty("QVariantMap", notify = userProfileChanged)
-    def userProfile(self) -> Optional[Dict[str, Optional[str]]]:
+    def userProfile(self) -> Dict[str, Optional[str]]:
         """None if no user is logged in otherwise the logged in  user as a dict containing containing user_id, username and profile_image_url """
         if not self._user_profile:
-            return None
+            return {}
         return self._user_profile.__dict__
 
     @pyqtProperty(str, notify=lastSyncDateTimeChanged)

+ 1 - 1
cura/API/ConnectionStatus.py

@@ -1,6 +1,6 @@
 from typing import Optional
 
-from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty
+from PyQt6.QtCore import QObject, pyqtSignal, pyqtProperty
 
 from UM.TaskManagement.HttpRequestManager import HttpRequestManager
 

+ 4 - 3
cura/API/__init__.py

@@ -2,7 +2,7 @@
 # Cura is released under the terms of the LGPLv3 or higher.
 from typing import Optional, TYPE_CHECKING
 
-from PyQt5.QtCore import QObject, pyqtProperty
+from PyQt6.QtCore import QObject, pyqtProperty
 
 from cura.API.Backups import Backups
 from cura.API.ConnectionStatus import ConnectionStatus
@@ -34,12 +34,13 @@ class CuraAPI(QObject):
             raise RuntimeError("Tried to create singleton '{class_name}' more than once.".format(class_name = CuraAPI.__name__))
         if application is None:
             raise RuntimeError("Upon first time creation, the application must be set.")
-        cls.__instance = super(CuraAPI, cls).__new__(cls)
+        instance = super(CuraAPI, cls).__new__(cls)
         cls._application = application
-        return cls.__instance
+        return instance
 
     def __init__(self, application: Optional["CuraApplication"] = None) -> None:
         super().__init__(parent = CuraAPI._application)
+        CuraAPI.__instance = self
 
         self._account = Account(self._application)
 

Some files were not shown because too many files changed in this diff