diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 9d6a2361a1..e6fa00869a 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -682,7 +682,7 @@ class CuraApplication(QtApplication): Logger.log("i", "Initializing quality manager") from cura.Machines.QualityManager import QualityManager - self._quality_manager = QualityManager(container_registry, parent = self) + self._quality_manager = QualityManager(self, parent = self) self._quality_manager.initialize() Logger.log("i", "Initializing machine manager") diff --git a/cura/Machines/QualityManager.py b/cura/Machines/QualityManager.py index d924f4c83e..ce19624c21 100644 --- a/cura/Machines/QualityManager.py +++ b/cura/Machines/QualityManager.py @@ -5,8 +5,6 @@ from typing import TYPE_CHECKING, Optional, cast, Dict, List from PyQt5.QtCore import QObject, QTimer, pyqtSignal, pyqtSlot -from UM.Application import Application - from UM.ConfigurationErrorMessage import ConfigurationErrorMessage from UM.Logger import Logger from UM.Util import parseBool @@ -22,7 +20,6 @@ if TYPE_CHECKING: from cura.Settings.GlobalStack import GlobalStack from .QualityChangesGroup import QualityChangesGroup from cura.CuraApplication import CuraApplication - from UM.Settings.ContainerRegistry import ContainerRegistry # @@ -39,12 +36,11 @@ class QualityManager(QObject): qualitiesUpdated = pyqtSignal() - def __init__(self, container_registry: "ContainerRegistry", parent = None) -> None: + def __init__(self, application: "CuraApplication", parent = None) -> None: super().__init__(parent) - from cura.CuraApplication import CuraApplication - self._application = CuraApplication.getInstance() # type: CuraApplication + self._application = application self._material_manager = self._application.getMaterialManager() - self._container_registry = container_registry + self._container_registry = self._application.getContainerRegistry() self._empty_quality_container = self._application.empty_quality_container self._empty_quality_changes_container = self._application.empty_quality_changes_container @@ -460,7 +456,7 @@ class QualityManager(QObject): # stack and clear the user settings. @pyqtSlot(str) def createQualityChanges(self, base_name: str) -> None: - machine_manager = CuraApplication.getInstance().getMachineManager() + machine_manager = self._application.getMachineManager() global_stack = machine_manager.activeMachine if not global_stack: diff --git a/cura/OAuth2/AuthorizationHelpers.py b/cura/OAuth2/AuthorizationHelpers.py index 6cb53d2252..f75ad9c9f9 100644 --- a/cura/OAuth2/AuthorizationHelpers.py +++ b/cura/OAuth2/AuthorizationHelpers.py @@ -4,7 +4,7 @@ import json import random from hashlib import sha512 from base64 import b64encode -from typing import Optional +from typing import Dict, Optional import requests @@ -28,33 +28,35 @@ class AuthorizationHelpers: # \param authorization_code: The authorization code from the 1st step. # \param verification_code: The verification code needed for the PKCE extension. # \return: An AuthenticationResponse object. - def getAccessTokenUsingAuthorizationCode(self, authorization_code: str, verification_code: str)-> "AuthenticationResponse": - return self.parseTokenResponse(requests.post(self._token_url, data={ - "client_id": self._settings.CLIENT_ID, - "redirect_uri": self._settings.CALLBACK_URL, + def getAccessTokenUsingAuthorizationCode(self, authorization_code: str, verification_code: str) -> "AuthenticationResponse": + data = { + "client_id": self._settings.CLIENT_ID if self._settings.CLIENT_ID is not None else "", + "redirect_uri": self._settings.CALLBACK_URL if self._settings.CALLBACK_URL is not None else "", "grant_type": "authorization_code", "code": authorization_code, "code_verifier": verification_code, - "scope": self._settings.CLIENT_SCOPES - })) # type: ignore + "scope": self._settings.CLIENT_SCOPES if self._settings.CLIENT_SCOPES is not None else "", + } + return self.parseTokenResponse(requests.post(self._token_url, data = data)) # type: ignore # Request the access token from the authorization server using a refresh token. # \param refresh_token: # \return: An AuthenticationResponse object. - def getAccessTokenUsingRefreshToken(self, refresh_token: str) -> AuthenticationResponse: - return self.parseTokenResponse(requests.post(self._token_url, data={ - "client_id": self._settings.CLIENT_ID, - "redirect_uri": self._settings.CALLBACK_URL, + def getAccessTokenUsingRefreshToken(self, refresh_token: str) -> "AuthenticationResponse": + data = { + "client_id": self._settings.CLIENT_ID if self._settings.CLIENT_ID is not None else "", + "redirect_uri": self._settings.CALLBACK_URL if self._settings.CALLBACK_URL is not None else "", "grant_type": "refresh_token", "refresh_token": refresh_token, - "scope": self._settings.CLIENT_SCOPES - })) # type: ignore + "scope": self._settings.CLIENT_SCOPES if self._settings.CLIENT_SCOPES is not None else "", + } + return self.parseTokenResponse(requests.post(self._token_url, data = data)) # type: ignore @staticmethod # Parse the token response from the authorization server into an AuthenticationResponse object. # \param token_response: The JSON string data response from the authorization server. # \return: An AuthenticationResponse object. - def parseTokenResponse(token_response: requests.models.Response) -> AuthenticationResponse: + def parseTokenResponse(token_response: requests.models.Response) -> "AuthenticationResponse": token_data = None try: diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py index 8532f40890..bdb4cbcba8 100644 --- a/cura/Scene/ConvexHullDecorator.py +++ b/cura/Scene/ConvexHullDecorator.py @@ -9,7 +9,6 @@ from UM.Math.Polygon import Polygon from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from UM.Settings.ContainerRegistry import ContainerRegistry - from cura.Settings.ExtruderManager import ExtruderManager from cura.Scene import ConvexHullNode