Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Paschal <ian.paschal@gmail.com>2018-09-06 17:57:45 +0300
committerIan Paschal <ian.paschal@gmail.com>2018-09-06 17:57:45 +0300
commit4cc1b6ce02a5aa629d3083f97b6a2cc61a14f971 (patch)
tree53674c37a50217b503bbc72c48cd51ad0cd56893
parent53d083e232a8edbc4f6ab52f8c8338fd134da31c (diff)
Add typings and fix code style
-rw-r--r--cura/PrintJobPreviewImageProvider.py2
-rw-r--r--cura/PrinterOutput/ExtruderConfigurationModel.py8
-rw-r--r--cura/PrinterOutput/ExtruderOutputModel.py6
-rw-r--r--cura/PrinterOutput/NetworkedPrinterOutputDevice.py47
-rw-r--r--cura/PrinterOutput/PrintJobOutputModel.py6
-rw-r--r--plugins/UM3NetworkPrinting/ClusterControlItem.qml9
-rw-r--r--plugins/UM3NetworkPrinting/ClusterMonitorItem.qml2
-rw-r--r--plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py18
-rw-r--r--plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml2
9 files changed, 61 insertions, 39 deletions
diff --git a/cura/PrintJobPreviewImageProvider.py b/cura/PrintJobPreviewImageProvider.py
index d3521bf0af..a8df5aa273 100644
--- a/cura/PrintJobPreviewImageProvider.py
+++ b/cura/PrintJobPreviewImageProvider.py
@@ -10,7 +10,7 @@ class PrintJobPreviewImageProvider(QQuickImageProvider):
super().__init__(QQuickImageProvider.Image)
## Request a new image.
- def requestImage(self, id, size):
+ def requestImage(self, id: str, size: QSize) -> QImage:
# The id will have an uuid and an increment separated by a slash. As we don't care about the value of the
# increment, we need to strip that first.
uuid = id[id.find("/") + 1:]
diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/PrinterOutput/ExtruderConfigurationModel.py
index 75ee4b6ab3..da0ad6b0b2 100644
--- a/cura/PrinterOutput/ExtruderConfigurationModel.py
+++ b/cura/PrinterOutput/ExtruderConfigurationModel.py
@@ -11,7 +11,7 @@ class ExtruderConfigurationModel(QObject):
extruderConfigurationChanged = pyqtSignal()
- def __init__(self, position: int = -1):
+ def __init__(self, position: int = -1) -> None:
super().__init__()
self._position = position # type: int
self._material = None # type: Optional[MaterialOutputModel]
@@ -24,17 +24,17 @@ class ExtruderConfigurationModel(QObject):
def position(self) -> int:
return self._position
- def setMaterial(self, material: Optional[MaterialOutputModel]):
+ def setMaterial(self, material: Optional[MaterialOutputModel]) -> None:
if self._hotend_id != material:
self._material = material
self.extruderConfigurationChanged.emit()
@pyqtProperty(QObject, fset = setMaterial, notify = extruderConfigurationChanged)
- def activeMaterial(self) -> MaterialOutputModel:
+ def activeMaterial(self) -> Optional[MaterialOutputModel]:
return self._material
@pyqtProperty(QObject, fset=setMaterial, notify=extruderConfigurationChanged)
- def material(self) -> MaterialOutputModel:
+ def material(self) -> Optional[MaterialOutputModel]:
return self._material
def setHotendID(self, hotend_id: Optional[str]) -> None:
diff --git a/cura/PrinterOutput/ExtruderOutputModel.py b/cura/PrinterOutput/ExtruderOutputModel.py
index c7fd58c098..30d53bbd85 100644
--- a/cura/PrinterOutput/ExtruderOutputModel.py
+++ b/cura/PrinterOutput/ExtruderOutputModel.py
@@ -22,8 +22,8 @@ class ExtruderOutputModel(QObject):
super().__init__(parent)
self._printer = printer # type: PrinterOutputModel
self._position = position
- self._target_hotend_temperature = 0 # type: float
- self._hotend_temperature = 0 # type: float
+ self._target_hotend_temperature = 0.0 # type: float
+ self._hotend_temperature = 0.0 # type: float
self._is_preheating = False
@@ -50,7 +50,7 @@ class ExtruderOutputModel(QObject):
def activeMaterial(self) -> Optional["MaterialOutputModel"]:
return self._extruder_configuration.activeMaterial
- def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]):
+ def updateActiveMaterial(self, material: Optional["MaterialOutputModel"]) -> None:
self._extruder_configuration.setMaterial(material)
## Update the hotend temperature. This only changes it locally.
diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py
index 36369feabb..94f86f19a3 100644
--- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py
+++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py
@@ -197,31 +197,43 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._validateManager()
request = self._createEmptyRequest(target)
self._last_request_time = time()
- reply = self._manager.put(request, data.encode())
- self._registerOnFinishedCallback(reply, on_finished)
+ if self._manager is not None:
+ reply = self._manager.put(request, data.encode())
+ self._registerOnFinishedCallback(reply, on_finished)
+ else:
+ Logger.log("e", "Could not find manager.")
def delete(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None:
self._validateManager()
request = self._createEmptyRequest(target)
self._last_request_time = time()
- reply = self._manager.deleteResource(request)
- self._registerOnFinishedCallback(reply, on_finished)
+ if self._manager is not None:
+ reply = self._manager.deleteResource(request)
+ self._registerOnFinishedCallback(reply, on_finished)
+ else:
+ Logger.log("e", "Could not find manager.")
def get(self, target: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None:
self._validateManager()
request = self._createEmptyRequest(target)
self._last_request_time = time()
- reply = self._manager.get(request)
- self._registerOnFinishedCallback(reply, on_finished)
+ if self._manager is not None:
+ reply = self._manager.get(request)
+ self._registerOnFinishedCallback(reply, on_finished)
+ else:
+ Logger.log("e", "Could not find manager.")
def post(self, target: str, data: str, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None:
self._validateManager()
request = self._createEmptyRequest(target)
self._last_request_time = time()
- reply = self._manager.post(request, data)
- if on_progress is not None:
- reply.uploadProgress.connect(on_progress)
- self._registerOnFinishedCallback(reply, on_finished)
+ if self._manager is not None:
+ reply = self._manager.post(request, data)
+ if on_progress is not None:
+ reply.uploadProgress.connect(on_progress)
+ self._registerOnFinishedCallback(reply, on_finished)
+ else:
+ Logger.log("e", "Could not find manager.")
def postFormWithParts(self, target: str, parts: List[QHttpPart], on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> QNetworkReply:
self._validateManager()
@@ -232,15 +244,18 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._last_request_time = time()
- reply = self._manager.post(request, multi_post_part)
+ if self._manager is not None:
+ reply = self._manager.post(request, multi_post_part)
- self._kept_alive_multiparts[reply] = multi_post_part
+ self._kept_alive_multiparts[reply] = multi_post_part
- if on_progress is not None:
- reply.uploadProgress.connect(on_progress)
- self._registerOnFinishedCallback(reply, on_finished)
+ if on_progress is not None:
+ reply.uploadProgress.connect(on_progress)
+ self._registerOnFinishedCallback(reply, on_finished)
- return reply
+ return reply
+ else:
+ Logger.log("e", "Could not find manager.")
def postForm(self, target: str, header_data: str, body_data: bytes, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None:
post_part = QHttpPart()
diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/PrinterOutput/PrintJobOutputModel.py
index c8d813f17c..7366b95f86 100644
--- a/cura/PrinterOutput/PrintJobOutputModel.py
+++ b/cura/PrinterOutput/PrintJobOutputModel.py
@@ -40,7 +40,7 @@ class PrintJobOutputModel(QObject):
self._compatible_machine_families = [] # type: List[str]
self._preview_image_id = 0
- self._preview_image = None
+ self._preview_image = None # type: Optional[QImage]
@pyqtProperty("QStringList", notify=compatibleMachineFamiliesChanged)
def compatibleMachineFamilies(self):
@@ -61,10 +61,10 @@ class PrintJobOutputModel(QObject):
temp = "image://print_job_preview/" + str(self._preview_image_id) + "/" + self._key
return QUrl(temp, QUrl.TolerantMode)
- def getPreviewImage(self):
+ def getPreviewImage(self) -> Optional[QImage]:
return self._preview_image
- def updatePreviewImage(self, preview_image: Optional[QImage]):
+ def updatePreviewImage(self, preview_image: Optional[QImage]) -> None:
if self._preview_image != preview_image:
self._preview_image = preview_image
self.previewImageChanged.emit()
diff --git a/plugins/UM3NetworkPrinting/ClusterControlItem.qml b/plugins/UM3NetworkPrinting/ClusterControlItem.qml
index 2b2c683bee..be72d3c07a 100644
--- a/plugins/UM3NetworkPrinting/ClusterControlItem.qml
+++ b/plugins/UM3NetworkPrinting/ClusterControlItem.qml
@@ -357,7 +357,14 @@ Component
function switchPopupState()
{
- popup.visible ? popup.close() : popup.open()
+ if (popup.visible)
+ {
+ popup.close()
+ }
+ else
+ {
+ popup.open()
+ }
}
Controls2.Button
diff --git a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml
index 82b1f554b7..71b598d05c 100644
--- a/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml
+++ b/plugins/UM3NetworkPrinting/ClusterMonitorItem.qml
@@ -101,8 +101,6 @@ Component
{
if (monitorFrame != null && !monitorFrame.visible)
{
- // After switching the Tab ensure that active printer is Null, the video stream image
- // might be active
OutputDevice.setActiveCamera(null)
}
}
diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py
index 353a67ccd0..8345de049c 100644
--- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py
+++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py
@@ -146,14 +146,15 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
Logger.log("e", "Missing file or mesh writer!")
return
self._sending_job = self._sendPrintJob(writer, preferred_format, nodes)
- self._sending_job.send(None) # Start the generator.
+ if self._sending_job is not None:
+ self._sending_job.send(None) # Start the generator.
- if len(self._printers) > 1: # We need to ask the user.
- self._spawnPrinterSelectionDialog()
- is_job_sent = True
- else: # Just immediately continue.
- self._sending_job.send("") # No specifically selected printer.
- is_job_sent = self._sending_job.send(None)
+ if len(self._printers) > 1: # We need to ask the user.
+ self._spawnPrinterSelectionDialog()
+ is_job_sent = True
+ else: # Just immediately continue.
+ self._sending_job.send("") # No specifically selected printer.
+ is_job_sent = self._sending_job.send(None)
def _spawnPrinterSelectionDialog(self):
if self._printer_selection_dialog is None:
@@ -171,7 +172,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
# \param target_printer The name of the printer to target.
@pyqtSlot(str)
def selectPrinter(self, target_printer: str = "") -> None:
- self._sending_job.send(target_printer)
+ if self._sending_job is not None:
+ self._sending_job.send(target_printer)
@pyqtSlot()
def cancelPrintSelection(self) -> None:
diff --git a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml
index 539d8385c9..0ae1fec920 100644
--- a/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml
+++ b/plugins/UM3NetworkPrinting/PrintCoreConfiguration.qml
@@ -22,7 +22,7 @@ Item
anchors.verticalCenter: printAndMaterialLabel.verticalCenter
opacity:
{
- if(printCoreConfiguration == undefined || printCoreConfiguration.activeMaterial == undefined || printCoreConfiguration.hotendID == undefined)
+ if(printCoreConfiguration == null || printCoreConfiguration.activeMaterial == null || printCoreConfiguration.hotendID == null)
{
return 0.5
}