Merge branch 'STAR-322_cloud-connection' of github.com:Ultimaker/Cura into STAR-322_cloud-connection

This commit is contained in:
Daniel Schiavini 2018-12-05 10:44:53 +01:00
commit 3c5e74a72c
17 changed files with 179 additions and 202 deletions

View file

@ -63,8 +63,6 @@ class CloudOutputDeviceManager:
found_clusters = {c.cluster_id: c for c in clusters}
Logger.log("i", "Parsed remote clusters to %s", found_clusters)
if not found_clusters:
return
known_cluster_ids = set(self._remote_clusters.keys())
found_cluster_ids = set(found_clusters.keys())
@ -85,8 +83,7 @@ class CloudOutputDeviceManager:
device = CloudOutputDevice(self._api, cluster.cluster_id)
self._output_device_manager.addOutputDevice(device)
self._remote_clusters[cluster.cluster_id] = device
device.connect() # TODO: remove this
self._connectToActiveMachine(cluster.cluster_id, cluster.host_name)
self._connectToActiveMachine(cluster.cluster_id)
## Remove a CloudOutputDevice
# \param cluster: The cluster that was removed
@ -95,16 +92,16 @@ class CloudOutputDeviceManager:
if cluster.cluster_id in self._remote_clusters:
del self._remote_clusters[cluster.cluster_id]
## Callback for when the active machine was changed by the user.
def _connectToActiveMachine(self, cluster_id: Optional[str] = None, host_name: Optional[str] = None) -> None:
## Callback for when the active machine was changed by the user or a new remote cluster was found.
def _connectToActiveMachine(self, cluster_id: Optional[str] = None) -> None:
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
if not active_machine:
return
# TODO: Remove this once correct pairing has been added (see below).
# TODO: This just adds any available cluster to the active device for testing.
if cluster_id:
active_machine.setMetaDataEntry("um_cloud_cluster_id", cluster_id)
active_machine.setMetaDataEntry("connect_group_name", host_name)
# Check if the stored cluster_id for the active machine is in our list of remote clusters.
stored_cluster_id = active_machine.getMetaDataEntry("um_cloud_cluster_id")

View file

@ -385,8 +385,24 @@ class ClusterUM3OutputDevice(BaseCuraConnectDevice):
@pyqtSlot(int, result = str)
def getDateCompleted(self, time_remaining: int) -> str:
current_time = time()
datetime_completed = datetime.fromtimestamp(current_time + time_remaining)
return (datetime_completed.strftime("%a %b ") + "{day}".format(day=datetime_completed.day)).upper()
completed = datetime.fromtimestamp(current_time + time_remaining)
today = datetime.fromtimestamp(current_time)
# If finishing date is more than 7 days out, using "Mon Dec 3 at HH:MM" format
if completed.toordinal() > today.toordinal() + 7:
return completed.strftime("%a %b ") + "{day}".format(day=completed.day)
# If finishing date is within the next week, use "Monday at HH:MM" format
elif completed.toordinal() > today.toordinal() + 1:
return completed.strftime("%a")
# If finishing tomorrow, use "tomorrow at HH:MM" format
elif completed.toordinal() > today.toordinal():
return "tomorrow"
# If finishing today, use "today at HH:MM" format
else:
return "today"
@pyqtSlot(str)
def sendJobToTop(self, print_job_uuid: str) -> None: