Merge branch 'maintenance' into devel

# Conflicts:
#	.github/workflows/build.yml
#	.github/workflows/test_install.yml
#	setup.py
#	src/octoprint/printer/standard.py
#	src/octoprint/util/__init__.py
This commit is contained in:
Gina Häußge committed 2021-03-15 18:03:51 +01:00
commit d8fa8e3029
7 files changed
+45 -27

No files matched your search

+5 -5
View File
@@ -12,7 +12,7 @@ import os
import threading
import time
from frozendict import frozendict
from immutabledict import immutabledict
import octoprint.util.json
from octoprint import util as util
@@ -47,7 +47,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self._logger_job = logging.getLogger(f"{__name__}.job")
self._dict = (
frozendict
immutabledict
if settings().getBoolean(["devel", "useFrozenDictForPrinterState"])
else dict
)
@@ -188,7 +188,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
@property
def firmware_info(self):
return frozendict(self._firmware_info) if self._firmware_info else None
return immutabledict(self._firmware_info) if self._firmware_info else None
# ~~ handling of PrinterCallbacks
@@ -802,11 +802,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
return self._comm.getErrorString()
def get_current_data(self, *args, **kwargs):
return util.thaw_frozendict(self._stateMonitor.get_current_data())
return util.thaw_immutabledict(self._stateMonitor.get_current_data())
def get_current_job(self, *args, **kwargs):
currentData = self._stateMonitor.get_current_data()
return util.thaw_frozendict(currentData["job"])
return util.thaw_immutabledict(currentData["job"])
def get_current_temperatures(self, *args, **kwargs):
if self._comm is not None:
+11 -6
View File
@@ -25,7 +25,7 @@ from collections.abc import Iterable, MutableMapping, Set
from functools import wraps
from typing import Union
import frozendict
from immutabledict import immutabledict
from octoprint import UMASK
from octoprint.util.connectivity import ConnectivityChecker # noqa: F401
@@ -1323,20 +1323,25 @@ glob_escape = deprecated(
)(glob.escape)
def thaw_frozendict(obj):
if not isinstance(obj, (dict, frozendict.frozendict)):
raise ValueError("obj must be a dict or frozendict instance")
def thaw_immutabledict(obj):
if not isinstance(obj, (dict, immutabledict)):
raise ValueError("obj must be a dict or immutabledict instance")
# only true love can thaw a frozen dict
letitgo = {}
for key, value in obj.items():
if isinstance(value, (dict, frozendict.frozendict)):
letitgo[key] = thaw_frozendict(value)
if isinstance(value, (dict, immutabledict)):
letitgo[key] = thaw_immutabledict(value)
else:
letitgo[key] = copy.deepcopy(value)
return letitgo
thaw_frozendict = deprecated(
"thaw_frozendict has been renamed to thaw_immutabledict", since="1.6.0"
)(thaw_immutabledict)
def utmify(link, source=None, medium=None, name=None, term=None, content=None):
if source is None:
return link
+6 -2
View File
@@ -5,7 +5,11 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
import collections
import json
import frozendict
try:
from immutabledict import immutabledict
except ImportError:
# Python 2
from frozendict import frozendict as immutabledict
from octoprint.util import to_unicode
@@ -42,5 +46,5 @@ class JsonEncoding:
raise TypeError
JsonEncoding.add_encoder(frozendict.frozendict, lambda obj: dict(obj))
JsonEncoding.add_encoder(immutabledict, lambda obj: dict(obj))
JsonEncoding.add_encoder(bytes, lambda obj: to_unicode(obj))