Don't return any boolean in _update

Nothing listens to that return value, and its parent classes say that this must return None.

Contributes to issue CURA-5330.
This commit is contained in:
Ghostkeeper 2018-06-01 11:47:04 +02:00
parent a946a8aaed
commit 8ed3bd29cb
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -10,7 +10,7 @@ from cura.CuraApplication import CuraApplication
from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState
from PyQt5.QtNetwork import QHttpMultiPart, QHttpPart, QNetworkRequest, QNetworkAccessManager, QNetworkReply, QAuthenticator from PyQt5.QtNetwork import QHttpMultiPart, QHttpPart, QNetworkRequest, QNetworkAccessManager, QNetworkReply, QAuthenticator
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QUrl, QCoreApplication from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QUrl, QCoreApplication
from time import time from time import time
from typing import Any, Callable, Dict, List, Optional from typing import Any, Callable, Dict, List, Optional
from enum import IntEnum from enum import IntEnum
@ -29,7 +29,7 @@ class AuthState(IntEnum):
class NetworkedPrinterOutputDevice(PrinterOutputDevice): class NetworkedPrinterOutputDevice(PrinterOutputDevice):
authenticationStateChanged = pyqtSignal() authenticationStateChanged = pyqtSignal()
def __init__(self, device_id, address: str, properties: Dict[bytes, bytes], parent = None) -> None: def __init__(self, device_id, address: str, properties: Dict[bytes, bytes], parent: QObject = None) -> None:
super().__init__(device_id = device_id, parent = parent) super().__init__(device_id = device_id, parent = parent)
self._manager = None # type: QNetworkAccessManager self._manager = None # type: QNetworkAccessManager
self._last_manager_create_time = None # type: float self._last_manager_create_time = None # type: float
@ -69,7 +69,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._printer_type = value self._printer_type = value
break break
def requestWrite(self, nodes: List[SceneNode], file_name: str = None, filter_by_machine: bool = False, file_handler: FileHandler = None, **kwargs: Dict[str, Any]) -> None: def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
raise NotImplementedError("requestWrite needs to be implemented") raise NotImplementedError("requestWrite needs to be implemented")
def setAuthenticationState(self, authentication_state: AuthState) -> None: def setAuthenticationState(self, authentication_state: AuthState) -> None:
@ -123,7 +123,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._compressing_gcode = False self._compressing_gcode = False
return b"".join(file_data_bytes_list) return b"".join(file_data_bytes_list)
def _update(self) -> bool: def _update(self) -> None:
if self._last_response_time: if self._last_response_time:
time_since_last_response = time() - self._last_response_time time_since_last_response = time() - self._last_response_time
else: else:
@ -153,8 +153,6 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self.setConnectionState(self._connection_state_before_timeout) self.setConnectionState(self._connection_state_before_timeout)
self._connection_state_before_timeout = None self._connection_state_before_timeout = None
return True
def _createEmptyRequest(self, target: str, content_type: Optional[str] = "application/json") -> QNetworkRequest: def _createEmptyRequest(self, target: str, content_type: Optional[str] = "application/json") -> QNetworkRequest:
url = QUrl("http://" + self._address + self._api_prefix + target) url = QUrl("http://" + self._address + self._api_prefix + target)
request = QNetworkRequest(url) request = QNetworkRequest(url)