Codestyle fixes

CL-894
This commit is contained in:
Jaime van Kessel 2018-08-17 10:34:14 +02:00
parent 01b9ba03d4
commit d4aaa73928
3 changed files with 40 additions and 34 deletions

View file

@ -33,6 +33,10 @@ class ExtruderConfigurationModel(QObject):
def activeMaterial(self) -> MaterialOutputModel:
return self._material
@pyqtProperty(QObject, fset=setMaterial, notify=extruderConfigurationChanged)
def material(self) -> MaterialOutputModel:
return self._material
def setHotendID(self, hotend_id: Optional[str]) -> None:
if self._hotend_id != hotend_id:
self._hotend_id = hotend_id

View file

@ -9,7 +9,7 @@ from UM.FileHandler.WriteFileJob import WriteFileJob #To call the file writer as
from UM.Logger import Logger
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.i18n import i18nCatalog
from UM.Mesh.MeshWriter import MeshWriter # For typing
from UM.Message import Message
from UM.Qt.Duration import Duration, DurationFormat
from UM.OutputDevice import OutputDeviceError # To show that something went wrong when writing.
@ -34,7 +34,7 @@ from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QObject
from time import time
from datetime import datetime
from typing import Optional, Dict, List, Set
from typing import Optional, Dict, List
import io # To create the correct buffers for sending data to the printer.
import json
@ -91,9 +91,10 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
self._finished_jobs = [] # type: List[PrintJobOutputModel]
self._cluster_size = int(properties.get(b"cluster_size", 0))
self._cluster_size = int(properties.get(b"cluster_size", 0)) # type: int
self._latest_reply_handler = None # type: Optional[QNetworkReply]
self._sending_job = None
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
self.writeStarted.emit(self)
@ -159,7 +160,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
self._printer_selection_dialog.show()
@pyqtProperty(int, constant=True)
def clusterSize(self):
def clusterSize(self) -> int:
return self._cluster_size
## Allows the user to choose a printer to print with from the printer
@ -281,8 +282,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
# If successfully sent:
if bytes_sent == bytes_total:
# Show a confirmation to the user so they know the job was sucessful and provide the option to switch to the
# monitor tab.
# Show a confirmation to the user so they know the job was sucessful and provide the option to switch to
# the monitor tab.
self._success_message = Message(
i18n_catalog.i18nc("@info:status", "Print job was successfully sent to the printer."),
lifetime=5, dismissable=True,
@ -412,7 +413,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
image.loadFromData(reply.readAll())
print_job.updatePreviewImage(image)
def _update(self) -> None:
super()._update()
self.get("printers/", on_finished = self._onGetPrintersDataFinished)
@ -615,6 +615,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
job = SendMaterialJob(device = self)
job.run()
def loadJsonFromReply(reply: QNetworkReply) -> Optional[List[Dict[str, Any]]]:
try:
result = json.loads(bytes(reply.readAll()).decode("utf-8"))
@ -633,8 +634,8 @@ def checkValidGetReply(reply: QNetworkReply) -> bool:
return True
def findByKey(list: List[Union[PrintJobOutputModel, PrinterOutputModel]], key: str) -> Optional[PrintJobOutputModel]:
for item in list:
def findByKey(lst: List[Union[PrintJobOutputModel, PrinterOutputModel]], key: str) -> Optional[PrintJobOutputModel]:
for item in lst:
if item.key == key:
return item
return None

View file

@ -148,6 +148,7 @@ Item
text: "Send to top"
onClicked: OutputDevice.sendJobToTop(printJob.key)
width: parent.width
enabled: OutputDevice.printJobs[0].key != printJob.key
}
}