Always return a fake machine, even if empty

Contributes to CL-1331
This commit is contained in:
Ian Paschal 2019-05-09 16:19:39 +02:00
parent 26ab359a93
commit 03fd9da417

View file

@ -27,19 +27,25 @@ class Machines(QObject):
@pyqtSlot(result=dict) @pyqtSlot(result=dict)
def getCurrentMachine(self) -> dict: def getCurrentMachine(self) -> dict:
global_stack = self._application.getGlobalContainerStack()
if global_stack:
metadata = global_stack.getMetaData()
# Since Cura doesn't have a machine class, we're going to make a fake one to make our # Since Cura doesn't have a machine class, we're going to make a fake one to make our
# lives a little bit easier. # lives a little bit easier.
fake_machine = { fake_machine = {
"hostname": "", "hostname": "",
"group_id": global_stack.getMetaDataEntry("group_id") if "group_id" in metadata else "", "group_id": "",
"group_name": global_stack.getMetaDataEntry("group_name") if "group_name" in metadata else "", "group_name": "",
"um_network_key": global_stack.getMetaDataEntry("um_network_key") if "um_network_key" in metadata else "", "um_network_key": "",
"configuration": {} "configuration": {}
} }
global_stack = self._application.getGlobalContainerStack()
if global_stack:
metadata = global_stack.getMetaData()
if "group_id" in metadata:
fake_machine["group_id"] = global_stack.getMetaDataEntry("group_id")
if "group_name" in metadata:
fake_machine["group_name"] = global_stack.getMetaDataEntry("group_name")
if "um_network_key" in metadata:
fake_machine["um_network_key"] = global_stack.getMetaDataEntry("um_network_key")
return fake_machine return fake_machine
## Set the current machine's friendy name. ## Set the current machine's friendy name.