From de824067820a0e2871b601886ce470db8ffad34c Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Fri, 15 May 2020 14:00:44 +0200 Subject: [PATCH] Convert doxygen to rst for UltimakerMachineActions, USBPrinting --- plugins/USBPrinting/USBPrinterOutputDevice.py | 29 +++++++++++-------- .../USBPrinterOutputDeviceManager.py | 15 ++++++---- .../BedLevelMachineAction.py | 7 +++-- .../UMOUpgradeSelection.py | 7 +++-- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 6be3827e5e..2e52a89713 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -110,20 +110,22 @@ class USBPrinterOutputDevice(PrinterOutputDevice): application = CuraApplication.getInstance() application.triggerNextExitCheck() - ## Reset USB device settings - # def resetDeviceSettings(self) -> None: + """Reset USB device settings""" + self._firmware_name = None - ## Request the current scene to be sent to a USB-connected printer. - # - # \param nodes A collection of scene nodes to send. This is ignored. - # \param file_name A suggestion for a file name to write. - # \param filter_by_machine Whether to filter MIME types by machine. This - # is ignored. - # \param kwargs Keyword arguments. def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None: + """Request the current scene to be sent to a USB-connected printer. + + :param nodes: A collection of scene nodes to send. This is ignored. + :param file_name: A suggestion for a file name to write. + :param filter_by_machine: Whether to filter MIME types by machine. This + is ignored. + :param kwargs: Keyword arguments. + """ + if self._is_printing: message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress")) message.show() @@ -144,9 +146,11 @@ class USBPrinterOutputDevice(PrinterOutputDevice): self._printGCode(gcode_textio.getvalue()) - ## Start a print based on a g-code. - # \param gcode The g-code to print. def _printGCode(self, gcode: str): + """Start a print based on a g-code. + + :param gcode: The g-code to print. + """ self._gcode.clear() self._paused = False @@ -219,8 +223,9 @@ class USBPrinterOutputDevice(PrinterOutputDevice): self._update_thread = Thread(target=self._update, daemon=True, name = "USBPrinterUpdate") self._serial = None - ## Send a command to printer. def sendCommand(self, command: Union[str, bytes]): + """Send a command to printer.""" + if not self._command_received.is_set(): self._command_queue.put(command) else: diff --git a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py index a0585adf51..3ee43e071e 100644 --- a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py +++ b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py @@ -20,9 +20,10 @@ from . import USBPrinterOutputDevice i18n_catalog = i18nCatalog("cura") -## Manager class that ensures that an USBPrinterOutput device is created for every connected USB printer. @signalemitter class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin): + """Manager class that ensures that an USBPrinterOutput device is created for every connected USB printer.""" + addUSBOutputDeviceSignal = Signal() progressChanged = pyqtSignal() @@ -85,8 +86,9 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin): self._addRemovePorts(port_list) time.sleep(5) - ## Helper to identify serial ports (and scan for them) def _addRemovePorts(self, serial_ports): + """Helper to identify serial ports (and scan for them)""" + # First, find and add all new or changed keys for serial_port in list(serial_ports): if serial_port not in self._serial_port_list: @@ -98,16 +100,19 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin): if port not in self._serial_port_list: device.close() - ## Because the model needs to be created in the same thread as the QMLEngine, we use a signal. def addOutputDevice(self, serial_port): + """Because the model needs to be created in the same thread as the QMLEngine, we use a signal.""" + device = USBPrinterOutputDevice.USBPrinterOutputDevice(serial_port) device.connectionStateChanged.connect(self._onConnectionStateChanged) self._usb_output_devices[serial_port] = device device.connect() - ## Create a list of serial ports on the system. - # \param only_list_usb If true, only usb ports are listed def getSerialPortList(self, only_list_usb = False): + """Create a list of serial ports on the system. + + :param only_list_usb: If true, only usb ports are listed + """ base_list = [] for port in serial.tools.list_ports.comports(): if not isinstance(port, tuple): diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py index 818ad0e4f0..7d2eb74f84 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.py +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -14,9 +14,12 @@ from UM.Logger import Logger catalog = i18nCatalog("cura") -## A simple action to handle manual bed leveling procedure for printers that don't have it on the firmware. -# This is currently only used by the Ultimaker Original+ class BedLevelMachineAction(MachineAction): + """A simple action to handle manual bed leveling procedure for printers that don't have it on the firmware. + + This is currently only used by the Ultimaker Original+ + """ + def __init__(self): super().__init__("BedLevel", catalog.i18nc("@action", "Level build plate")) self._qml_url = "BedLevelMachineAction.qml" diff --git a/plugins/UltimakerMachineActions/UMOUpgradeSelection.py b/plugins/UltimakerMachineActions/UMOUpgradeSelection.py index f6275e5b56..62eab75986 100644 --- a/plugins/UltimakerMachineActions/UMOUpgradeSelection.py +++ b/plugins/UltimakerMachineActions/UMOUpgradeSelection.py @@ -11,9 +11,12 @@ catalog = i18nCatalog("cura") from cura.Settings.CuraStackBuilder import CuraStackBuilder -## The Ultimaker Original can have a few revisions & upgrades. This action helps with selecting them, so they are added -# as a variant. + class UMOUpgradeSelection(MachineAction): + """The Ultimaker Original can have a few revisions & upgrades. + This action helps with selecting them, so they are added as a variant. + """ + def __init__(self): super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades")) self._qml_url = "UMOUpgradeSelectionMachineAction.qml"