mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-04 09:25:22 +08:00
Update typing hints to new style
More boyscouting as I try to understand this code CURA-8463
This commit is contained in:
parent
4ac8229c33
commit
f8ebf98df3
@ -46,15 +46,15 @@ class CloudOutputDeviceManager:
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Persistent dict containing the remote clusters for the authenticated user.
|
# Persistent dict containing the remote clusters for the authenticated user.
|
||||||
self._remote_clusters = {} # type: Dict[str, CloudOutputDevice]
|
self._remote_clusters: Dict[str, CloudOutputDevice] = {}
|
||||||
|
|
||||||
# Dictionary containing all the cloud printers loaded in Cura
|
# Dictionary containing all the cloud printers loaded in Cura
|
||||||
self._um_cloud_printers = {} # type: Dict[str, GlobalStack]
|
self._um_cloud_printers: Dict[str, GlobalStack] = {}
|
||||||
|
|
||||||
self._account = CuraApplication.getInstance().getCuraAPI().account # type: Account
|
self._account: Account = CuraApplication.getInstance().getCuraAPI().account
|
||||||
self._api = CloudApiClient(CuraApplication.getInstance(), on_error = lambda error: Logger.log("e", str(error)))
|
self._api = CloudApiClient(CuraApplication.getInstance(), on_error = lambda error: Logger.log("e", str(error)))
|
||||||
self._account.loginStateChanged.connect(self._onLoginStateChanged)
|
self._account.loginStateChanged.connect(self._onLoginStateChanged)
|
||||||
self._removed_printers_message = None # type: Optional[Message]
|
self._removed_printers_message: Optional[Message] = None
|
||||||
|
|
||||||
# Ensure we don't start twice.
|
# Ensure we don't start twice.
|
||||||
self._running = False
|
self._running = False
|
||||||
@ -113,8 +113,8 @@ class CloudOutputDeviceManager:
|
|||||||
CuraApplication.getInstance().getContainerRegistry().findContainerStacks(
|
CuraApplication.getInstance().getContainerRegistry().findContainerStacks(
|
||||||
type = "machine") if m.getMetaDataEntry(self.META_CLUSTER_ID, None)}
|
type = "machine") if m.getMetaDataEntry(self.META_CLUSTER_ID, None)}
|
||||||
new_clusters = []
|
new_clusters = []
|
||||||
all_clusters = {c.cluster_id: c for c in clusters} # type: Dict[str, CloudClusterResponse]
|
all_clusters: Dict[str, CloudClusterResponse] = {c.cluster_id: c for c in clusters}
|
||||||
online_clusters = {c.cluster_id: c for c in clusters if c.is_online} # type: Dict[str, CloudClusterResponse]
|
online_clusters: Dict[str, CloudClusterResponse] = {c.cluster_id: c for c in clusters if c.is_online}
|
||||||
|
|
||||||
# Add the new printers in Cura.
|
# Add the new printers in Cura.
|
||||||
for device_id, cluster_data in all_clusters.items():
|
for device_id, cluster_data in all_clusters.items():
|
||||||
@ -369,7 +369,7 @@ class CloudOutputDeviceManager:
|
|||||||
|
|
||||||
# Remove the output device from the printers
|
# Remove the output device from the printers
|
||||||
for device_id in removed_device_ids:
|
for device_id in removed_device_ids:
|
||||||
device = self._um_cloud_printers.get(device_id, None) # type: Optional[GlobalStack]
|
device: Optional[GlobalStack] = self._um_cloud_printers.get(device_id, None)
|
||||||
if not device:
|
if not device:
|
||||||
continue
|
continue
|
||||||
if device_id in output_device_manager.getOutputDeviceIds():
|
if device_id in output_device_manager.getOutputDeviceIds():
|
||||||
@ -383,7 +383,7 @@ class CloudOutputDeviceManager:
|
|||||||
self._removed_printers_message.show()
|
self._removed_printers_message.show()
|
||||||
|
|
||||||
def _onDiscoveredDeviceRemoved(self, device_id: str) -> None:
|
def _onDiscoveredDeviceRemoved(self, device_id: str) -> None:
|
||||||
device = self._remote_clusters.pop(device_id, None) # type: Optional[CloudOutputDevice]
|
device: Optional[CloudOutputDevice] = self._remote_clusters.pop(device_id, None)
|
||||||
if not device:
|
if not device:
|
||||||
return
|
return
|
||||||
device.close()
|
device.close()
|
||||||
@ -397,7 +397,7 @@ class CloudOutputDeviceManager:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Create a new machine.
|
# Create a new machine.
|
||||||
# We do not use use MachineManager.addMachine here because we need to set the cluster ID before activating it.
|
# We do not use MachineManager.addMachine here because we need to set the cluster ID before activating it.
|
||||||
new_machine = CuraStackBuilder.createMachine(device.name, device.printerType, show_warning_message=False)
|
new_machine = CuraStackBuilder.createMachine(device.name, device.printerType, show_warning_message=False)
|
||||||
if not new_machine:
|
if not new_machine:
|
||||||
Logger.error(f"Failed creating a new machine for {device.name}")
|
Logger.error(f"Failed creating a new machine for {device.name}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user