Thaw the frozendict on printer.get_current_data
We don't want calling code to run into trouble because of that. Fixes #2506
This commit is contained in:
1 parent
70254e910c
commit
f782cfe83f
3 files changed
+39
-2
No files matched your search
@@ -550,11 +550,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
return self._comm.getStateId(state=state)
|
||||
|
||||
def get_current_data(self, *args, **kwargs):
|
||||
return self._stateMonitor.get_current_data()
|
||||
return util.thaw_frozendict(self._stateMonitor.get_current_data())
|
||||
|
||||
def get_current_job(self, *args, **kwargs):
|
||||
currentData = self._stateMonitor.get_current_data()
|
||||
return currentData["job"]
|
||||
return util.thaw_frozendict(currentData["job"])
|
||||
|
||||
def get_current_temperatures(self, *args, **kwargs):
|
||||
if self._comm is not None:
|
||||
|
||||
@@ -21,6 +21,7 @@ from functools import wraps
|
||||
import warnings
|
||||
import contextlib
|
||||
import collections
|
||||
import frozendict
|
||||
|
||||
try:
|
||||
import queue
|
||||
@@ -970,6 +971,20 @@ except RuntimeError:
|
||||
monotonic_time = time.time
|
||||
|
||||
|
||||
def thaw_frozendict(obj):
|
||||
if not isinstance(obj, (dict, frozendict.frozendict)):
|
||||
raise ValueError("obj must be a dict or frozendict instance")
|
||||
|
||||
# only true love can thaw a frozen dict
|
||||
letitgo = dict()
|
||||
for key, value in obj.items():
|
||||
if isinstance(value, frozendict.frozendict):
|
||||
letitgo[key] = thaw_frozendict(value)
|
||||
else:
|
||||
letitgo[key] = value
|
||||
return letitgo
|
||||
|
||||
|
||||
def utmify(link, source=None, medium=None, name=None, term=None, content=None):
|
||||
if source is None:
|
||||
return link
|
||||
|
||||
Reference in new issue
Block a user