mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
Typing fixes
Some things the CI is complaining about. Contributes to issue CURA-8609.
This commit is contained in:
parent
a703e6b882
commit
af54316690
3 changed files with 11 additions and 8 deletions
|
@ -18,7 +18,7 @@ from UM.Signal import Signal
|
||||||
from UM.TaskManagement.HttpRequestManager import HttpRequestManager # To call the API.
|
from UM.TaskManagement.HttpRequestManager import HttpRequestManager # To call the API.
|
||||||
from UM.TaskManagement.HttpRequestScope import JsonDecoratorScope
|
from UM.TaskManagement.HttpRequestScope import JsonDecoratorScope
|
||||||
|
|
||||||
from typing import Dict, Optional, TYPE_CHECKING
|
from typing import Any, Dict, Optional, TYPE_CHECKING
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from PyQt5.QtNetwork import QNetworkReply
|
from PyQt5.QtNetwork import QNetworkReply
|
||||||
from cura.UltimakerCloud.CloudMaterialSync import CloudMaterialSync
|
from cura.UltimakerCloud.CloudMaterialSync import CloudMaterialSync
|
||||||
|
@ -42,7 +42,7 @@ class UploadMaterialsJob(Job):
|
||||||
UPLOAD_CONFIRM_URL = UltimakerCloudConstants.CuraCloudAPIRoot + "/connect/v1/clusters/{cluster_id}/printers/{cluster_printer_id}/action/confirm_material_upload"
|
UPLOAD_CONFIRM_URL = UltimakerCloudConstants.CuraCloudAPIRoot + "/connect/v1/clusters/{cluster_id}/printers/{cluster_printer_id}/action/confirm_material_upload"
|
||||||
|
|
||||||
class Result(enum.IntEnum):
|
class Result(enum.IntEnum):
|
||||||
SUCCCESS = 0
|
SUCCESS = 0
|
||||||
FAILED = 1
|
FAILED = 1
|
||||||
|
|
||||||
def __init__(self, material_sync: "CloudMaterialSync"):
|
def __init__(self, material_sync: "CloudMaterialSync"):
|
||||||
|
@ -51,8 +51,8 @@ class UploadMaterialsJob(Job):
|
||||||
self._scope = JsonDecoratorScope(UltimakerCloudScope(cura.CuraApplication.CuraApplication.getInstance())) # type: JsonDecoratorScope
|
self._scope = JsonDecoratorScope(UltimakerCloudScope(cura.CuraApplication.CuraApplication.getInstance())) # type: JsonDecoratorScope
|
||||||
self._archive_filename = None # type: Optional[str]
|
self._archive_filename = None # type: Optional[str]
|
||||||
self._archive_remote_id = None # type: Optional[str] # ID that the server gives to this archive. Used to communicate about the archive to the server.
|
self._archive_remote_id = None # type: Optional[str] # ID that the server gives to this archive. Used to communicate about the archive to the server.
|
||||||
self._printer_sync_status = {}
|
self._printer_sync_status = {} # type: Dict[str, str]
|
||||||
self._printer_metadata = {}
|
self._printer_metadata = {} # type: Dict[str, Any]
|
||||||
self.processProgressChanged.connect(self._onProcessProgressChanged)
|
self.processProgressChanged.connect(self._onProcessProgressChanged)
|
||||||
|
|
||||||
uploadCompleted = Signal()
|
uploadCompleted = Signal()
|
||||||
|
@ -113,7 +113,8 @@ class UploadMaterialsJob(Job):
|
||||||
|
|
||||||
upload_url = response_data["upload_url"]
|
upload_url = response_data["upload_url"]
|
||||||
self._archive_remote_id = response_data["material_profile_id"]
|
self._archive_remote_id = response_data["material_profile_id"]
|
||||||
file_data = open(self._archive_filename, "rb").read()
|
with open(self._archive_filename, "rb") as f:
|
||||||
|
file_data = f.read()
|
||||||
http = HttpRequestManager.getInstance()
|
http = HttpRequestManager.getInstance()
|
||||||
http.put(
|
http.put(
|
||||||
url = upload_url,
|
url = upload_url,
|
||||||
|
|
|
@ -27,8 +27,8 @@ class CloudMaterialSync(QObject):
|
||||||
self.sync_all_dialog = None # type: Optional[QObject]
|
self.sync_all_dialog = None # type: Optional[QObject]
|
||||||
self._export_upload_status = "idle"
|
self._export_upload_status = "idle"
|
||||||
self._checkIfNewMaterialsWereInstalled()
|
self._checkIfNewMaterialsWereInstalled()
|
||||||
self._export_progress = 0
|
self._export_progress = 0.0
|
||||||
self._printer_status = {}
|
self._printer_status = {} # type: Dict[str, str]
|
||||||
|
|
||||||
def _checkIfNewMaterialsWereInstalled(self) -> None:
|
def _checkIfNewMaterialsWereInstalled(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -161,6 +161,8 @@ class CloudMaterialSync(QObject):
|
||||||
self.setPrinterStatus(printers_status)
|
self.setPrinterStatus(printers_status)
|
||||||
|
|
||||||
def exportUploadCompleted(self, job_result: UploadMaterialsJob.Result, job_error: Optional[Exception]):
|
def exportUploadCompleted(self, job_result: UploadMaterialsJob.Result, job_error: Optional[Exception]):
|
||||||
|
if not self.sync_all_dialog: # Shouldn't get triggered before the dialog is open, but better to check anyway.
|
||||||
|
return
|
||||||
if job_result == UploadMaterialsJob.Result.FAILED:
|
if job_result == UploadMaterialsJob.Result.FAILED:
|
||||||
if isinstance(job_error, UploadMaterialsError):
|
if isinstance(job_error, UploadMaterialsError):
|
||||||
self.sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Error sending materials to the Digital Factory:") + " " + str(job_error))
|
self.sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Error sending materials to the Digital Factory:") + " " + str(job_error))
|
||||||
|
|
|
@ -5,11 +5,11 @@ from PyQt5.QtNetwork import QNetworkRequest
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.TaskManagement.HttpRequestScope import DefaultUserAgentScope
|
from UM.TaskManagement.HttpRequestScope import DefaultUserAgentScope
|
||||||
from cura.API import Account
|
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
|
from cura.API.Account import Account
|
||||||
|
|
||||||
|
|
||||||
class UltimakerCloudScope(DefaultUserAgentScope):
|
class UltimakerCloudScope(DefaultUserAgentScope):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue