mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
Remove trailing whitespace from Python files
This commit is contained in:
parent
1e33360c35
commit
89f0970a88
157 changed files with 562 additions and 562 deletions
|
@ -37,7 +37,7 @@ I18N_CATALOG = i18nCatalog("cura")
|
|||
|
||||
class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||
"""The cloud output device is a network output device that works remotely but has limited functionality.
|
||||
|
||||
|
||||
Currently it only supports viewing the printer and print job status and adding a new job to the queue.
|
||||
As such, those methods have been implemented here.
|
||||
Note that this device represents a single remote cluster, not a list of multiple clusters.
|
||||
|
@ -60,7 +60,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def __init__(self, api_client: CloudApiClient, cluster: CloudClusterResponse, parent: QObject = None) -> None:
|
||||
"""Creates a new cloud output device
|
||||
|
||||
|
||||
:param api_client: The client that will run the API calls
|
||||
:param cluster: The device response received from the cloud API.
|
||||
:param parent: The optional parent of this output device.
|
||||
|
@ -165,7 +165,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def _onStatusCallFinished(self, status: CloudClusterStatus) -> None:
|
||||
"""Method called when HTTP request to status endpoint is finished.
|
||||
|
||||
|
||||
Contains both printers and print jobs statuses in a single response.
|
||||
"""
|
||||
self._responseReceived()
|
||||
|
@ -202,7 +202,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def _onPrintJobCreated(self, job: ExportFileJob) -> None:
|
||||
"""Handler for when the print job was created locally.
|
||||
|
||||
|
||||
It can now be sent over the cloud.
|
||||
"""
|
||||
output = job.getOutput()
|
||||
|
@ -217,7 +217,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def _uploadPrintJob(self, job_response: CloudPrintJobResponse) -> None:
|
||||
"""Uploads the mesh when the print job was registered with the cloud API.
|
||||
|
||||
|
||||
:param job_response: The response received from the cloud API.
|
||||
"""
|
||||
if not self._tool_path:
|
||||
|
@ -236,7 +236,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def _onPrintUploadCompleted(self, response: CloudPrintResponse) -> None:
|
||||
"""Shows a message when the upload has succeeded
|
||||
|
||||
|
||||
:param response: The response from the cloud API.
|
||||
"""
|
||||
self._progress.hide()
|
||||
|
@ -245,7 +245,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def _onUploadError(self, message: str = None) -> None:
|
||||
"""Displays the given message if uploading the mesh has failed
|
||||
|
||||
|
||||
:param message: The message to display.
|
||||
"""
|
||||
self._progress.hide()
|
||||
|
|
|
@ -22,7 +22,7 @@ from ..Models.Http.CloudClusterResponse import CloudClusterResponse
|
|||
|
||||
class CloudOutputDeviceManager:
|
||||
"""The cloud output device manager is responsible for using the Ultimaker Cloud APIs to manage remote clusters.
|
||||
|
||||
|
||||
Keeping all cloud related logic in this class instead of the UM3OutputDevicePlugin results in more readable code.
|
||||
API spec is available on https://api.ultimaker.com/docs/connect/spec/.
|
||||
"""
|
||||
|
|
|
@ -32,7 +32,7 @@ class MeshFormatHandler:
|
|||
@property
|
||||
def preferred_format(self) -> Dict[str, Union[str, int, bool]]:
|
||||
"""Chooses the preferred file format.
|
||||
|
||||
|
||||
:return: A dict with the file format details, with the following keys:
|
||||
{id: str, extension: str, description: str, mime_type: str, mode: int, hide_in_file_dialog: bool}
|
||||
"""
|
||||
|
@ -41,7 +41,7 @@ class MeshFormatHandler:
|
|||
@property
|
||||
def writer(self) -> Optional[FileWriter]:
|
||||
"""Gets the file writer for the given file handler and mime type.
|
||||
|
||||
|
||||
:return: A file writer.
|
||||
"""
|
||||
return self._writer
|
||||
|
@ -84,7 +84,7 @@ class MeshFormatHandler:
|
|||
|
||||
def _getPreferredFormat(self, firmware_version: str) -> Dict[str, Union[str, int, bool]]:
|
||||
"""Chooses the preferred file format for the given file handler.
|
||||
|
||||
|
||||
:param firmware_version: The version of the firmware.
|
||||
:return: A dict with the file format details.
|
||||
"""
|
||||
|
@ -121,7 +121,7 @@ class MeshFormatHandler:
|
|||
|
||||
def _getWriter(self, mime_type: str) -> Optional[FileWriter]:
|
||||
"""Gets the file writer for the given file handler and mime type.
|
||||
|
||||
|
||||
:param mime_type: The mine type.
|
||||
:return: A file writer.
|
||||
"""
|
||||
|
|
|
@ -28,7 +28,7 @@ class PrintJobUploadProgressMessage(Message):
|
|||
|
||||
def update(self, percentage: int) -> None:
|
||||
"""Updates the percentage of the uploaded.
|
||||
|
||||
|
||||
:param percentage: The percentage amount (0-100).
|
||||
"""
|
||||
if not self._visible:
|
||||
|
|
|
@ -20,7 +20,7 @@ class BaseModel:
|
|||
|
||||
def __eq__(self, other):
|
||||
"""Checks whether the two models are equal.
|
||||
|
||||
|
||||
:param other: The other model.
|
||||
:return: True if they are equal, False if they are different.
|
||||
"""
|
||||
|
@ -28,7 +28,7 @@ class BaseModel:
|
|||
|
||||
def __ne__(self, other) -> bool:
|
||||
"""Checks whether the two models are different.
|
||||
|
||||
|
||||
:param other: The other model.
|
||||
:return: True if they are different, False if they are the same.
|
||||
"""
|
||||
|
@ -42,7 +42,7 @@ class BaseModel:
|
|||
@staticmethod
|
||||
def parseModel(model_class: Type[T], values: Union[T, Dict[str, Any]]) -> T:
|
||||
"""Parses a single model.
|
||||
|
||||
|
||||
:param model_class: The model class.
|
||||
:param values: The value of the model, which is usually a dictionary, but may also be already parsed.
|
||||
:return: An instance of the model_class given.
|
||||
|
@ -54,7 +54,7 @@ class BaseModel:
|
|||
@classmethod
|
||||
def parseModels(cls, model_class: Type[T], values: List[Union[T, Dict[str, Any]]]) -> List[T]:
|
||||
"""Parses a list of models.
|
||||
|
||||
|
||||
:param model_class: The model class.
|
||||
:param values: The value of the list. Each value is usually a dictionary, but may also be already parsed.
|
||||
:return: A list of instances of the model_class given.
|
||||
|
@ -64,7 +64,7 @@ class BaseModel:
|
|||
@staticmethod
|
||||
def parseDate(date: Union[str, datetime]) -> datetime:
|
||||
"""Parses the given date string.
|
||||
|
||||
|
||||
:param date: The date to parse.
|
||||
:return: The parsed date.
|
||||
"""
|
||||
|
|
|
@ -13,7 +13,7 @@ class CloudClusterResponse(BaseModel):
|
|||
host_internal_ip: Optional[str] = None, host_version: Optional[str] = None,
|
||||
friendly_name: Optional[str] = None, printer_type: str = "ultimaker3", **kwargs) -> None:
|
||||
"""Creates a new cluster response object.
|
||||
|
||||
|
||||
:param cluster_id: The secret unique ID, e.g. 'kBEeZWEifXbrXviO8mRYLx45P8k5lHVGs43XKvRniPg='.
|
||||
:param host_guid: The unique identifier of the print cluster host, e.g. 'e90ae0ac-1257-4403-91ee-a44c9b7e8050'.
|
||||
:param host_name: The name of the printer as configured during the Wi-Fi setup. Used as identifier for end users.
|
||||
|
|
|
@ -16,7 +16,7 @@ class CloudClusterStatus(BaseModel):
|
|||
generated_time: Union[str, datetime],
|
||||
**kwargs) -> None:
|
||||
"""Creates a new cluster status model object.
|
||||
|
||||
|
||||
:param printers: The latest status of each printer in the cluster.
|
||||
:param print_jobs: The latest status of each print job in the cluster.
|
||||
:param generated_time: The datetime when the object was generated on the server-side.
|
||||
|
|
|
@ -11,7 +11,7 @@ class CloudError(BaseModel):
|
|||
def __init__(self, id: str, code: str, title: str, http_status: str, detail: Optional[str] = None,
|
||||
meta: Optional[Dict[str, Any]] = None, **kwargs) -> None:
|
||||
"""Creates a new error object.
|
||||
|
||||
|
||||
:param id: Unique identifier for this particular occurrence of the problem.
|
||||
:param title: A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence
|
||||
of the problem, except for purposes of localization.
|
||||
|
|
|
@ -12,7 +12,7 @@ class CloudPrintJobResponse(BaseModel):
|
|||
upload_url: Optional[str] = None, content_type: Optional[str] = None,
|
||||
status_description: Optional[str] = None, slicing_details: Optional[dict] = None, **kwargs) -> None:
|
||||
"""Creates a new print job response model.
|
||||
|
||||
|
||||
:param job_id: The job unique ID, e.g. 'kBEeZWEifXbrXviO8mRYLx45P8k5lHVGs43XKvRniPg='.
|
||||
:param status: The status of the print job.
|
||||
:param status_description: Contains more details about the status, e.g. the cause of failures.
|
||||
|
|
|
@ -8,7 +8,7 @@ class CloudPrintJobUploadRequest(BaseModel):
|
|||
|
||||
def __init__(self, job_name: str, file_size: int, content_type: str, **kwargs) -> None:
|
||||
"""Creates a new print job upload request.
|
||||
|
||||
|
||||
:param job_name: The name of the print job.
|
||||
:param file_size: The size of the file in bytes.
|
||||
:param content_type: The content type of the print job (e.g. text/plain or application/gzip)
|
||||
|
|
|
@ -12,7 +12,7 @@ class CloudPrintResponse(BaseModel):
|
|||
def __init__(self, job_id: str, status: str, generated_time: Union[str, datetime],
|
||||
cluster_job_id: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new print response object.
|
||||
|
||||
|
||||
:param job_id: The unique ID of a print job inside of the cluster. This ID is generated by Cura Connect.
|
||||
:param status: The status of the print request (queued or failed).
|
||||
:param generated_time: The datetime when the object was generated on the server-side.
|
||||
|
|
|
@ -8,7 +8,7 @@ class ClusterBuildPlate(BaseModel):
|
|||
|
||||
def __init__(self, type: str = "glass", **kwargs) -> None:
|
||||
"""Create a new build plate
|
||||
|
||||
|
||||
:param type: The type of build plate glass or aluminium
|
||||
"""
|
||||
self.type = type
|
||||
|
|
|
@ -11,14 +11,14 @@ from ..BaseModel import BaseModel
|
|||
|
||||
class ClusterPrintCoreConfiguration(BaseModel):
|
||||
"""Class representing a cloud cluster printer configuration
|
||||
|
||||
|
||||
Also used for representing slots in a Material Station (as from Cura's perspective these are the same).
|
||||
"""
|
||||
|
||||
def __init__(self, extruder_index: int, material: Union[None, Dict[str, Any],
|
||||
ClusterPrinterConfigurationMaterial] = None, print_core_id: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new cloud cluster printer configuration object
|
||||
|
||||
|
||||
:param extruder_index: The position of the extruder on the machine as list index. Numbered from left to right.
|
||||
:param material: The material of a configuration object in a cluster printer. May be in a dict or an object.
|
||||
:param nozzle_diameter: The diameter of the print core at this position in millimeters, e.g. '0.4'.
|
||||
|
@ -32,7 +32,7 @@ class ClusterPrintCoreConfiguration(BaseModel):
|
|||
|
||||
def updateOutputModel(self, model: ExtruderOutputModel) -> None:
|
||||
"""Updates the given output model.
|
||||
|
||||
|
||||
:param model: The output model to update.
|
||||
"""
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class ClusterPrintJobConfigurationChange(BaseModel):
|
|||
def __init__(self, type_of_change: str, target_id: str, origin_id: str, index: Optional[int] = None,
|
||||
target_name: Optional[str] = None, origin_name: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new print job constraint.
|
||||
|
||||
|
||||
:param type_of_change: The type of configuration change, one of: "material", "print_core_change"
|
||||
:param index: The hotend slot or extruder index to change
|
||||
:param target_id: Target material guid or hotend id
|
||||
|
|
|
@ -10,7 +10,7 @@ class ClusterPrintJobConstraints(BaseModel):
|
|||
|
||||
def __init__(self, require_printer_name: Optional[str] = None, **kwargs) -> None:
|
||||
"""Creates a new print job constraint.
|
||||
|
||||
|
||||
:param require_printer_name: Unique name of the printer that this job should be printed on.
|
||||
Should be one of the unique_name field values in the cluster, e.g. 'ultimakersystem-ccbdd30044ec'
|
||||
"""
|
||||
|
|
|
@ -8,7 +8,7 @@ class ClusterPrintJobImpediment(BaseModel):
|
|||
|
||||
def __init__(self, translation_key: str, severity: int, **kwargs) -> None:
|
||||
"""Creates a new print job constraint.
|
||||
|
||||
|
||||
:param translation_key: A string indicating a reason the print cannot be printed,
|
||||
such as 'does_not_fit_in_build_volume'
|
||||
:param severity: A number indicating the severity of the problem, with higher being more severe
|
||||
|
|
|
@ -35,7 +35,7 @@ class ClusterPrintJobStatus(BaseModel):
|
|||
**kwargs) -> None:
|
||||
|
||||
"""Creates a new cloud print job status model.
|
||||
|
||||
|
||||
:param assigned_to: The name of the printer this job is assigned to while being queued.
|
||||
:param configuration: The required print core configurations of this print job.
|
||||
:param constraints: Print job constraints object.
|
||||
|
@ -96,7 +96,7 @@ class ClusterPrintJobStatus(BaseModel):
|
|||
|
||||
def createOutputModel(self, controller: ClusterOutputController) -> UM3PrintJobOutputModel:
|
||||
"""Creates an UM3 print job output model based on this cloud cluster print job.
|
||||
|
||||
|
||||
:param printer: The output model of the printer
|
||||
"""
|
||||
|
||||
|
@ -115,7 +115,7 @@ class ClusterPrintJobStatus(BaseModel):
|
|||
|
||||
def updateOutputModel(self, model: UM3PrintJobOutputModel) -> None:
|
||||
"""Updates an UM3 print job output model based on this cloud cluster print job.
|
||||
|
||||
|
||||
:param model: The model to update.
|
||||
"""
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class ClusterPrinterConfigurationMaterial(BaseModel):
|
|||
material: Optional[str] = None, **kwargs) -> None:
|
||||
|
||||
"""Creates a new material configuration model.
|
||||
|
||||
|
||||
:param brand: The brand of material in this print core, e.g. 'Ultimaker'.
|
||||
:param color: The color of material in this print core, e.g. 'Blue'.
|
||||
:param guid: he GUID of the material in this print core, e.g. '506c9f0d-e3aa-4bd4-b2d2-23e2425b1aa9'.
|
||||
|
@ -31,7 +31,7 @@ class ClusterPrinterConfigurationMaterial(BaseModel):
|
|||
|
||||
def createOutputModel(self) -> MaterialOutputModel:
|
||||
"""Creates a material output model based on this cloud printer material.
|
||||
|
||||
|
||||
A material is chosen that matches the current GUID. If multiple such
|
||||
materials are available, read-only materials are preferred and the
|
||||
material with the earliest alphabetical name will be selected.
|
||||
|
|
|
@ -13,7 +13,7 @@ class ClusterPrinterMaterialStation(BaseModel):
|
|||
material_slots: List[Union[ClusterPrinterMaterialStationSlot, Dict[str, Any]]] = None,
|
||||
**kwargs) -> None:
|
||||
"""Creates a new Material Station status.
|
||||
|
||||
|
||||
:param status: The status of the material station.
|
||||
:param: supported: Whether the material station is supported on this machine or not.
|
||||
:param material_slots: The active slots configurations of this material station.
|
||||
|
|
|
@ -11,7 +11,7 @@ class ClusterPrinterMaterialStationSlot(ClusterPrintCoreConfiguration):
|
|||
def __init__(self, slot_index: int, compatible: bool, material_remaining: float,
|
||||
material_empty: Optional[bool] = False, **kwargs) -> None:
|
||||
"""Create a new material station slot object.
|
||||
|
||||
|
||||
:param slot_index: The index of the slot in the material station (ranging 0 to 5).
|
||||
:param compatible: Whether the configuration is compatible with the print core.
|
||||
:param material_remaining: How much material is remaining on the spool (between 0 and 1, or -1 for missing data).
|
||||
|
|
|
@ -29,7 +29,7 @@ class ClusterPrinterStatus(BaseModel):
|
|||
build_plate: Union[Dict[str, Any], ClusterBuildPlate] = None,
|
||||
material_station: Union[Dict[str, Any], ClusterPrinterMaterialStation] = None, **kwargs) -> None:
|
||||
"""Creates a new cluster printer status
|
||||
|
||||
|
||||
:param enabled: A printer can be disabled if it should not receive new jobs. By default every printer is enabled.
|
||||
:param firmware_version: Firmware version installed on the printer. Can differ for each printer in a cluster.
|
||||
:param friendly_name: Human readable name of the printer. Can be used for identification purposes.
|
||||
|
@ -68,7 +68,7 @@ class ClusterPrinterStatus(BaseModel):
|
|||
|
||||
def createOutputModel(self, controller: PrinterOutputController) -> PrinterOutputModel:
|
||||
"""Creates a new output model.
|
||||
|
||||
|
||||
:param controller: - The controller of the model.
|
||||
"""
|
||||
|
||||
|
@ -82,7 +82,7 @@ class ClusterPrinterStatus(BaseModel):
|
|||
|
||||
def updateOutputModel(self, model: PrinterOutputModel) -> None:
|
||||
"""Updates the given output model.
|
||||
|
||||
|
||||
:param model: - The output model to update.
|
||||
"""
|
||||
|
||||
|
@ -121,7 +121,7 @@ class ClusterPrinterStatus(BaseModel):
|
|||
|
||||
def _getSlotsForExtruder(self, extruder_index: int) -> List[ClusterPrinterMaterialStationSlot]:
|
||||
"""Create a list of Material Station slots for the given extruder index.
|
||||
|
||||
|
||||
Returns a list with a single empty material slot if none are found to ensure we don't miss configurations.
|
||||
"""
|
||||
|
||||
|
@ -136,7 +136,7 @@ class ClusterPrinterStatus(BaseModel):
|
|||
@staticmethod
|
||||
def _isSupportedConfiguration(slot: ClusterPrinterMaterialStationSlot, extruder_index: int) -> bool:
|
||||
"""Check if a configuration is supported in order to make it selectable by the user.
|
||||
|
||||
|
||||
We filter out any slot that is not supported by the extruder index, print core type or if the material is empty.
|
||||
"""
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class ClusterApiClient:
|
|||
|
||||
def __init__(self, address: str, on_error: Callable) -> None:
|
||||
"""Initializes a new cluster API client.
|
||||
|
||||
|
||||
:param address: The network address of the cluster to call.
|
||||
:param on_error: The callback to be called whenever we receive errors from the server.
|
||||
"""
|
||||
|
@ -43,7 +43,7 @@ class ClusterApiClient:
|
|||
|
||||
def getSystem(self, on_finished: Callable) -> None:
|
||||
"""Get printer system information.
|
||||
|
||||
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
"""
|
||||
url = "{}/system".format(self.PRINTER_API_PREFIX)
|
||||
|
@ -52,7 +52,7 @@ class ClusterApiClient:
|
|||
|
||||
def getMaterials(self, on_finished: Callable[[List[ClusterMaterial]], Any]) -> None:
|
||||
"""Get the installed materials on the printer.
|
||||
|
||||
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
"""
|
||||
url = "{}/materials".format(self.CLUSTER_API_PREFIX)
|
||||
|
@ -61,7 +61,7 @@ class ClusterApiClient:
|
|||
|
||||
def getPrinters(self, on_finished: Callable[[List[ClusterPrinterStatus]], Any]) -> None:
|
||||
"""Get the printers in the cluster.
|
||||
|
||||
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
"""
|
||||
url = "{}/printers".format(self.CLUSTER_API_PREFIX)
|
||||
|
@ -70,7 +70,7 @@ class ClusterApiClient:
|
|||
|
||||
def getPrintJobs(self, on_finished: Callable[[List[ClusterPrintJobStatus]], Any]) -> None:
|
||||
"""Get the print jobs in the cluster.
|
||||
|
||||
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
"""
|
||||
url = "{}/print_jobs".format(self.CLUSTER_API_PREFIX)
|
||||
|
@ -112,7 +112,7 @@ class ClusterApiClient:
|
|||
|
||||
def _createEmptyRequest(self, path: str, content_type: Optional[str] = "application/json") -> QNetworkRequest:
|
||||
"""We override _createEmptyRequest in order to add the user credentials.
|
||||
|
||||
|
||||
:param url: The URL to request
|
||||
:param content_type: The type of the body contents.
|
||||
"""
|
||||
|
@ -126,7 +126,7 @@ class ClusterApiClient:
|
|||
@staticmethod
|
||||
def _parseReply(reply: QNetworkReply) -> Tuple[int, Dict[str, Any]]:
|
||||
"""Parses the given JSON network reply into a status code and a dictionary, handling unexpected errors as well.
|
||||
|
||||
|
||||
:param reply: The reply from the server.
|
||||
:return: A tuple with a status code and a dictionary.
|
||||
"""
|
||||
|
@ -141,7 +141,7 @@ class ClusterApiClient:
|
|||
def _parseModels(self, response: Dict[str, Any], on_finished: Union[Callable[[ClusterApiClientModel], Any],
|
||||
Callable[[List[ClusterApiClientModel]], Any]], model_class: Type[ClusterApiClientModel]) -> None:
|
||||
"""Parses the given models and calls the correct callback depending on the result.
|
||||
|
||||
|
||||
:param response: The response from the server, after being converted to a dict.
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
:param model_class: The type of the model to convert the response to. It may either be a single record or a list.
|
||||
|
@ -163,7 +163,7 @@ class ClusterApiClient:
|
|||
Callable[[List[ClusterApiClientModel]], Any]], model: Type[ClusterApiClientModel] = None,
|
||||
) -> None:
|
||||
"""Creates a callback function so that it includes the parsing of the response into the correct model.
|
||||
|
||||
|
||||
The callback is added to the 'finished' signal of the reply.
|
||||
:param reply: The reply that should be listened to.
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
|
|
|
@ -98,7 +98,7 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def setJobState(self, print_job_uuid: str, action: str) -> None:
|
||||
"""Set the remote print job state.
|
||||
|
||||
|
||||
:param print_job_uuid: The UUID of the print job to set the state for.
|
||||
:param action: The action to undertake ('pause', 'resume', 'abort').
|
||||
"""
|
||||
|
@ -118,7 +118,7 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def sendMaterialProfiles(self) -> None:
|
||||
"""Sync the material profiles in Cura with the printer.
|
||||
|
||||
|
||||
This gets called when connecting to a printer as well as when sending a print.
|
||||
"""
|
||||
job = SendMaterialJob(device = self)
|
||||
|
@ -143,14 +143,14 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
@pyqtSlot(str, name="selectTargetPrinter")
|
||||
def selectTargetPrinter(self, unique_name: str = "") -> None:
|
||||
"""Allows the user to choose a printer to print with from the printer selection dialogue.
|
||||
|
||||
|
||||
:param unique_name: The unique name of the printer to target.
|
||||
"""
|
||||
self._startPrintJobUpload(unique_name if unique_name != "" else None)
|
||||
|
||||
def _onPrintJobCreated(self, job: ExportFileJob) -> None:
|
||||
"""Handler for when the print job was created locally.
|
||||
|
||||
|
||||
It can now be sent over the network.
|
||||
"""
|
||||
|
||||
|
@ -208,7 +208,7 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||
|
||||
def _onUploadError(self, message: str = None) -> None:
|
||||
"""Displays the given message if uploading the mesh has failed
|
||||
|
||||
|
||||
:param message: The message to display.
|
||||
"""
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ if TYPE_CHECKING:
|
|||
|
||||
class SendMaterialJob(Job):
|
||||
"""Asynchronous job to send material profiles to the printer.
|
||||
|
||||
|
||||
This way it won't freeze up the interface while sending those materials.
|
||||
"""
|
||||
|
||||
|
@ -40,7 +40,7 @@ class SendMaterialJob(Job):
|
|||
|
||||
def _sendMissingMaterials(self, remote_materials_by_guid: Dict[str, ClusterMaterial]) -> None:
|
||||
"""Determine which materials should be updated and send them to the printer.
|
||||
|
||||
|
||||
:param remote_materials_by_guid: The remote materials by GUID.
|
||||
"""
|
||||
local_materials_by_guid = self._getLocalMaterials()
|
||||
|
@ -57,7 +57,7 @@ class SendMaterialJob(Job):
|
|||
def _determineMaterialsToSend(local_materials: Dict[str, LocalMaterial],
|
||||
remote_materials: Dict[str, ClusterMaterial]) -> Set[str]:
|
||||
"""From the local and remote materials, determine which ones should be synchronized.
|
||||
|
||||
|
||||
Makes a Set of id's containing only the id's of the materials that are not on the printer yet or the ones that
|
||||
are newer in Cura.
|
||||
:param local_materials: The local materials by GUID.
|
||||
|
@ -72,7 +72,7 @@ class SendMaterialJob(Job):
|
|||
|
||||
def _sendMaterials(self, materials_to_send: Set[str]) -> None:
|
||||
"""Send the materials to the printer.
|
||||
|
||||
|
||||
The given materials will be loaded from disk en sent to to printer.
|
||||
The given id's will be matched with filenames of the locally stored materials.
|
||||
:param materials_to_send: A set with id's of materials that must be sent.
|
||||
|
@ -97,7 +97,7 @@ class SendMaterialJob(Job):
|
|||
|
||||
def _sendMaterialFile(self, file_path: str, file_name: str, material_id: str) -> None:
|
||||
"""Send a single material file to the printer.
|
||||
|
||||
|
||||
Also add the material signature file if that is available.
|
||||
:param file_path: The path of the material file.
|
||||
:param file_name: The name of the material file.
|
||||
|
@ -143,7 +143,7 @@ class SendMaterialJob(Job):
|
|||
@staticmethod
|
||||
def _getLocalMaterials() -> Dict[str, LocalMaterial]:
|
||||
"""Retrieves a list of local materials
|
||||
|
||||
|
||||
Only the new newest version of the local materials is returned
|
||||
:return: a dictionary of LocalMaterial objects by GUID
|
||||
"""
|
||||
|
|
|
@ -14,7 +14,7 @@ from cura.CuraApplication import CuraApplication
|
|||
|
||||
class ZeroConfClient:
|
||||
"""The ZeroConfClient handles all network discovery logic.
|
||||
|
||||
|
||||
It emits signals when new network services were found or disappeared.
|
||||
"""
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ZeroConfClient:
|
|||
|
||||
def start(self) -> None:
|
||||
"""The ZeroConf service changed requests are handled in a separate thread so we don't block the UI.
|
||||
|
||||
|
||||
We can also re-schedule the requests when they fail to get detailed service info.
|
||||
Any new or re-reschedule requests will be appended to the request queue and the thread will process them.
|
||||
"""
|
||||
|
@ -108,7 +108,7 @@ class ZeroConfClient:
|
|||
def _onServiceChanged(self, zero_conf: Zeroconf, service_type: str, name: str,
|
||||
state_change: ServiceStateChange) -> bool:
|
||||
"""Handler for zeroConf detection.
|
||||
|
||||
|
||||
Return True or False indicating if the process succeeded.
|
||||
Note that this function can take over 3 seconds to complete. Be careful calling it from the main thread.
|
||||
"""
|
||||
|
|
|
@ -69,7 +69,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
"""Remove a manually connected networked printer."""
|
||||
|
||||
self._network_output_device_manager.removeManualDevice(key, address)
|
||||
|
||||
|
||||
def getDiscoveredDevices(self) -> Dict[str, LocalClusterOutputDevice]:
|
||||
"""Get the discovered devices from the local network."""
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ I18N_CATALOG = i18nCatalog("cura")
|
|||
|
||||
class UltimakerNetworkedPrinterAction(MachineAction):
|
||||
"""Machine action that allows to connect the active machine to a networked devices.
|
||||
|
||||
|
||||
TODO: in the future this should be part of the new discovery workflow baked into Cura.
|
||||
"""
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ from .Models.Http.ClusterPrintJobStatus import ClusterPrintJobStatus
|
|||
|
||||
class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
||||
"""Output device class that forms the basis of Ultimaker networked printer output devices.
|
||||
|
||||
|
||||
Currently used for local networking and cloud printing using Ultimaker Connect.
|
||||
This base class primarily contains all the Qt properties and slots needed for the monitor page to work.
|
||||
"""
|
||||
|
@ -218,7 +218,7 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
def _checkStillConnected(self) -> None:
|
||||
"""Check if we're still connected by comparing the last timestamps for network response and the current time.
|
||||
|
||||
|
||||
This implementation is similar to the base NetworkedPrinterOutputDevice, but is tweaked slightly.
|
||||
Re-connecting is handled automatically by the output device managers in this plugin.
|
||||
TODO: it would be nice to have this logic in the managers, but connecting those with signals causes crashes.
|
||||
|
@ -233,7 +233,7 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
def _reconnectForActiveMachine(self) -> None:
|
||||
"""Reconnect for the active output device.
|
||||
|
||||
|
||||
Does nothing if the device is not meant for the active machine.
|
||||
"""
|
||||
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
|
@ -301,7 +301,7 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
def _updatePrintJobs(self, remote_jobs: List[ClusterPrintJobStatus]) -> None:
|
||||
"""Updates the local list of print jobs with the list received from the cluster.
|
||||
|
||||
|
||||
:param remote_jobs: The print jobs received from the cluster.
|
||||
"""
|
||||
self._responseReceived()
|
||||
|
@ -336,7 +336,7 @@ class UltimakerNetworkedPrinterOutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
def _createPrintJobModel(self, remote_job: ClusterPrintJobStatus) -> UM3PrintJobOutputModel:
|
||||
"""Create a new print job model based on the remote status of the job.
|
||||
|
||||
|
||||
:param remote_job: The remote print job data.
|
||||
"""
|
||||
model = remote_job.createOutputModel(ClusterOutputController(self))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue