From 871fd63fa9b037141246d64141507804cd94ee7d Mon Sep 17 00:00:00 2001 From: Luc Rubio Date: Tue, 26 May 2020 09:25:11 +0100 Subject: [PATCH] Ability to rename printers. --- src/MPSM2NetworkedPrinterOutputDevice.py | 30 +++++++++--------------- src/Network/DeviceManager.py | 5 +--- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/MPSM2NetworkedPrinterOutputDevice.py b/src/MPSM2NetworkedPrinterOutputDevice.py index 12b6097..c8149a5 100644 --- a/src/MPSM2NetworkedPrinterOutputDevice.py +++ b/src/MPSM2NetworkedPrinterOutputDevice.py @@ -9,9 +9,8 @@ from UM.FileHandler.FileHandler import FileHandler from UM.Logger import Logger -from UM.i18n import i18nCatalog from UM.Scene.SceneNode import SceneNode - +from UM.i18n import i18nCatalog # pylint:disable=import-error from cura.CuraApplication import CuraApplication from cura.PrinterOutput.Models.ExtruderConfigurationModel \ @@ -23,24 +22,23 @@ import NetworkedPrinterOutputDevice, AuthState from cura.PrinterOutput.PrinterOutputDevice \ import ConnectionType, ConnectionState - +from .GCodeWriteFileJob import GCodeWriteFileJob # pylint:disable=relative-beyond-top-level from .MPSM2OutputController import MPSM2OutputController -from .Models.MPSM2PrinterOutputModel import MPSM2PrinterOutputModel -from .Models.MPSM2PrinterStatusModel import MPSM2PrinterStatusModel -from .Models.MPSM2PrintJobOutputModel import MPSM2PrintJobOutputModel -from .Network.ApiClient import ApiClient -from .GCodeWriteFileJob import GCodeWriteFileJob -from .Messages.PrintJobUploadProgressMessage \ - import PrintJobUploadProgressMessage from .Messages.PrintJobUploadBlockedMessage \ import PrintJobUploadBlockedMessage -from .Messages.PrintJobUploadSuccessMessage \ - import PrintJobUploadSuccessMessage from .Messages.PrintJobUploadCancelMessage \ import PrintJobUploadCancelMessage from .Messages.PrintJobUploadIsPrintingMessage \ import PrintJobUploadIsPrintingMessage +from .Messages.PrintJobUploadProgressMessage \ + import PrintJobUploadProgressMessage +from .Messages.PrintJobUploadSuccessMessage \ + import PrintJobUploadSuccessMessage +from .Models.MPSM2PrintJobOutputModel import MPSM2PrintJobOutputModel +from .Models.MPSM2PrinterOutputModel import MPSM2PrinterOutputModel +from .Models.MPSM2PrinterStatusModel import MPSM2PrinterStatusModel +from .Network.ApiClient import ApiClient from .Parser.MPSM2PrinterStatusParser \ import MPSM2PrinterStatusParser @@ -106,14 +104,8 @@ def __init__(self, device_id: str, address: str, instance_number=1, self._requested_cancel_print = False self._requested_hotend_temperature = None # int self._requested_bed_temperature = None # int + self.setName(device_name) - # Set the display name from the properties. - self.setName(self.getProperty('name')) - - # Set the display name of the printer type. - definitions = CuraApplication.getInstance().getContainerRegistry() \ - .findContainers(id=self.printerType) - self._printer_type_name = definitions[0].getName() if definitions else '' self._job_upload_message = PrintJobUploadProgressMessage( self._on_print_upload_cancelled) self._api_client = ApiClient(self.address, diff --git a/src/Network/DeviceManager.py b/src/Network/DeviceManager.py index db44791..8b0cc65 100644 --- a/src/Network/DeviceManager.py +++ b/src/Network/DeviceManager.py @@ -2,7 +2,6 @@ Copyright 2020 Luc Rubio Plugin is licensed under the GNU Lesser General Public License v3.0. """ -from UM.Settings.Interfaces import ContainerInterface from typing import Optional, Callable, List, cast from PyQt5.QtCore import pyqtSignal, QObject @@ -10,6 +9,7 @@ from UM import i18nCatalog from UM.Logger import Logger from UM.Settings.ContainerRegistry import ContainerRegistry +from UM.Settings.Interfaces import ContainerInterface from UM.Signal import Signal # pylint:disable=import-error from cura.CuraApplication import CuraApplication @@ -232,9 +232,6 @@ def _get_stored_manual_addresses(self) -> List[str]: def _connect_to_output_device(self, device: MPSM2NetworkedPrinterOutputDevice, machine: GlobalStack) -> None: Logger.log('d', 'Connecting to Output Device with key: %s.', device.key) - machine.setName(device.name) - machine.setMetaDataEntry(self.METADATA_MPSM2_KEY, device.key) - machine.setMetaDataEntry('group_name', device.name) machine.addConfiguredConnectionType(device.connectionType.value) if not device.isConnected():