mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Remove much logging or use debug level, fix cloud icon not appearing right away
This commit is contained in:
parent
dd2f12f68a
commit
beb68213f4
4 changed files with 16 additions and 17 deletions
|
@ -178,6 +178,7 @@ class MachineManager(QObject):
|
||||||
self._printer_output_devices.append(printer_output_device)
|
self._printer_output_devices.append(printer_output_device)
|
||||||
|
|
||||||
self.outputDevicesChanged.emit()
|
self.outputDevicesChanged.emit()
|
||||||
|
self.printerConnectedStatusChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = currentConfigurationChanged)
|
@pyqtProperty(QObject, notify = currentConfigurationChanged)
|
||||||
def currentConfiguration(self) -> ConfigurationModel:
|
def currentConfiguration(self) -> ConfigurationModel:
|
||||||
|
@ -520,7 +521,7 @@ class MachineManager(QObject):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||||
def printerConnected(self):
|
def printerConnected(self) -> bool:
|
||||||
return bool(self._printer_output_devices)
|
return bool(self._printer_output_devices)
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||||
|
@ -532,9 +533,10 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
@pyqtProperty(bool, notify = printerConnectedStatusChanged)
|
||||||
def activeMachineHasCloudConnection(self) -> bool:
|
def activeMachineHasCloudConnection(self) -> bool:
|
||||||
if not self.activeMachineHasRemoteConnection:
|
# A cloud connection is only available if the active output device actually is a cloud connected device.
|
||||||
return False
|
# We cannot simply use the connection_type metadata entry as that's always set to 'NetworkConnection'
|
||||||
output_device = next(iter(self.printerOutputDevices), None) # type: Optional[PrinterOutputDevice]
|
# if there was a network connection during setup, which is always the case.
|
||||||
|
output_device = next(iter(self._printer_output_devices), None) # type: Optional[PrinterOutputDevice]
|
||||||
if not output_device:
|
if not output_device:
|
||||||
return False
|
return False
|
||||||
return output_device.connectionType == ConnectionType.CloudConnection
|
return output_device.connectionType == ConnectionType.CloudConnection
|
||||||
|
|
|
@ -101,7 +101,7 @@ class CloudApiClient:
|
||||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
||||||
if self._account.isLoggedIn:
|
if self._account.isLoggedIn:
|
||||||
request.setRawHeader(b"Authorization", "Bearer {}".format(self._account.accessToken).encode())
|
request.setRawHeader(b"Authorization", "Bearer {}".format(self._account.accessToken).encode())
|
||||||
Logger.log("i", "Created request for URL %s. Logged in = %s", path, self._account.isLoggedIn)
|
# Logger.log("i", "Created request for URL %s. Logged in = %s", path, self._account.isLoggedIn)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
## Parses the given JSON network reply into a status code and a dictionary, handling unexpected errors as well.
|
## Parses the given JSON network reply into a status code and a dictionary, handling unexpected errors as well.
|
||||||
|
@ -112,7 +112,7 @@ class CloudApiClient:
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||||
try:
|
try:
|
||||||
response = bytes(reply.readAll()).decode()
|
response = bytes(reply.readAll()).decode()
|
||||||
Logger.log("i", "Received a reply %s from %s with %s", status_code, reply.url().toString(), response)
|
# Logger.log("i", "Received a reply %s from %s with %s", status_code, reply.url().toString(), response)
|
||||||
return status_code, json.loads(response)
|
return status_code, json.loads(response)
|
||||||
except (UnicodeDecodeError, JSONDecodeError, ValueError) as err:
|
except (UnicodeDecodeError, JSONDecodeError, ValueError) as err:
|
||||||
error = CloudErrorObject(code=type(err).__name__, title=str(err), http_code=str(status_code),
|
error = CloudErrorObject(code=type(err).__name__, title=str(err), http_code=str(status_code),
|
||||||
|
|
|
@ -65,8 +65,6 @@ class T:
|
||||||
# Currently it only supports viewing the printer and print job status and adding a new job to the queue.
|
# Currently it only supports viewing the printer and print job status and adding a new job to the queue.
|
||||||
# As such, those methods have been implemented here.
|
# As such, those methods have been implemented here.
|
||||||
# Note that this device represents a single remote cluster, not a list of multiple clusters.
|
# Note that this device represents a single remote cluster, not a list of multiple clusters.
|
||||||
#
|
|
||||||
# TODO: figure our how the QML interface for the cluster networking should operate with this limited functionality.
|
|
||||||
class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
# The interval with which the remote clusters are checked
|
# The interval with which the remote clusters are checked
|
||||||
|
@ -202,10 +200,9 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
super()._update()
|
super()._update()
|
||||||
if self._last_request_time and time() - self._last_request_time < self.CHECK_CLUSTER_INTERVAL:
|
if self._last_request_time and time() - self._last_request_time < self.CHECK_CLUSTER_INTERVAL:
|
||||||
Logger.log("i", "Not updating: %s - %s < %s", time(), self._last_request_time, self.CHECK_CLUSTER_INTERVAL)
|
|
||||||
return # avoid calling the cloud too often
|
return # avoid calling the cloud too often
|
||||||
|
|
||||||
Logger.log("i", "Updating: %s - %s >= %s", time(), self._last_request_time, self.CHECK_CLUSTER_INTERVAL)
|
Logger.log("d", "Updating: %s - %s >= %s", time(), self._last_request_time, self.CHECK_CLUSTER_INTERVAL)
|
||||||
if self._account.isLoggedIn:
|
if self._account.isLoggedIn:
|
||||||
self.setAuthenticationState(AuthState.Authenticated)
|
self.setAuthenticationState(AuthState.Authenticated)
|
||||||
self._last_request_time = time()
|
self._last_request_time = time()
|
||||||
|
@ -342,7 +339,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
||||||
## Shows a message when the upload has succeeded
|
## Shows a message when the upload has succeeded
|
||||||
# \param response: The response from the cloud API.
|
# \param response: The response from the cloud API.
|
||||||
def _onPrintRequested(self, response: CloudPrintResponse) -> None:
|
def _onPrintRequested(self, response: CloudPrintResponse) -> None:
|
||||||
Logger.log("i", "The cluster will be printing this print job with the ID %s", response.cluster_job_id)
|
Logger.log("d", "The cluster will be printing this print job with the ID %s", response.cluster_job_id)
|
||||||
self._progress.hide()
|
self._progress.hide()
|
||||||
Message(
|
Message(
|
||||||
text = T.UPLOAD_SUCCESS_TEXT,
|
text = T.UPLOAD_SUCCESS_TEXT,
|
||||||
|
|
|
@ -50,7 +50,7 @@ class CloudOutputDeviceManager:
|
||||||
|
|
||||||
# Called when the uses logs in or out
|
# Called when the uses logs in or out
|
||||||
def _onLoginStateChanged(self, is_logged_in: bool) -> None:
|
def _onLoginStateChanged(self, is_logged_in: bool) -> None:
|
||||||
Logger.log("i", "Log in state changed to %s", is_logged_in)
|
Logger.log("d", "Log in state changed to %s", is_logged_in)
|
||||||
if is_logged_in:
|
if is_logged_in:
|
||||||
if not self._update_timer.isActive():
|
if not self._update_timer.isActive():
|
||||||
self._update_timer.start()
|
self._update_timer.start()
|
||||||
|
@ -64,7 +64,7 @@ class CloudOutputDeviceManager:
|
||||||
|
|
||||||
## Gets all remote clusters from the API.
|
## Gets all remote clusters from the API.
|
||||||
def _getRemoteClusters(self) -> None:
|
def _getRemoteClusters(self) -> None:
|
||||||
Logger.log("i", "Retrieving remote clusters")
|
Logger.log("d", "Retrieving remote clusters")
|
||||||
self._api.getClusters(self._onGetRemoteClustersFinished)
|
self._api.getClusters(self._onGetRemoteClustersFinished)
|
||||||
|
|
||||||
## Callback for when the request for getting the clusters. is finished.
|
## Callback for when the request for getting the clusters. is finished.
|
||||||
|
@ -73,8 +73,8 @@ class CloudOutputDeviceManager:
|
||||||
|
|
||||||
removed_devices, added_clusters, updates = findChanges(self._remote_clusters, online_clusters)
|
removed_devices, added_clusters, updates = findChanges(self._remote_clusters, online_clusters)
|
||||||
|
|
||||||
Logger.log("i", "Parsed remote clusters to %s", [cluster.toDict() for cluster in online_clusters.values()])
|
Logger.log("d", "Parsed remote clusters to %s", [cluster.toDict() for cluster in online_clusters.values()])
|
||||||
Logger.log("i", "Removed: %s, added: %s, updates: %s", len(removed_devices), len(added_clusters), len(updates))
|
Logger.log("d", "Removed: %s, added: %s, updates: %s", len(removed_devices), len(added_clusters), len(updates))
|
||||||
|
|
||||||
# Remove output devices that are gone
|
# Remove output devices that are gone
|
||||||
for removed_cluster in removed_devices:
|
for removed_cluster in removed_devices:
|
||||||
|
@ -100,7 +100,7 @@ class CloudOutputDeviceManager:
|
||||||
def _connectToActiveMachine(self) -> None:
|
def _connectToActiveMachine(self) -> None:
|
||||||
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
|
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
|
||||||
if not active_machine:
|
if not active_machine:
|
||||||
Logger.log("i", "no active machine")
|
Logger.log("d", "no active machine")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if the stored cluster_id for the active machine is in our list of remote clusters.
|
# Check if the stored cluster_id for the active machine is in our list of remote clusters.
|
||||||
|
@ -109,7 +109,7 @@ class CloudOutputDeviceManager:
|
||||||
device = self._remote_clusters[stored_cluster_id]
|
device = self._remote_clusters[stored_cluster_id]
|
||||||
if not device.isConnected():
|
if not device.isConnected():
|
||||||
device.connect()
|
device.connect()
|
||||||
Logger.log("i", "Device connected by metadata %s", stored_cluster_id)
|
Logger.log("d", "Device connected by metadata %s", stored_cluster_id)
|
||||||
else:
|
else:
|
||||||
self._connectByNetworkKey(active_machine)
|
self._connectByNetworkKey(active_machine)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue