diff --git a/.versioneer-lookup b/.versioneer-lookup index 28de35100..4a56f141b 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -29,10 +29,10 @@ improve/.* 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev staging/bugfix 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev bug/.* 1.7.4 59cbfadf8922d85b9df40f8d0173e8c21724c3b8 pep440-dev -# staging/maintenance is currently the branch for preparation of 1.8.0rc4 +# staging/maintenance is currently the branch for preparation of 1.8.0rc6 # so is regressionfix/... -staging/maintenance 1.8.0rc5 c5b095a8b905d759c84acab5e8a65ed3170d124c pep440-dev -regressionfix/.* 1.8.0rc5 c5b095a8b905d759c84acab5e8a65ed3170d124c pep440-dev +staging/maintenance 1.8.0rc6 45598764e6c7f6257de87a98d15964209ddc9e09 pep440-dev +regressionfix/.* 1.8.0rc6 45598764e6c7f6257de87a98d15964209ddc9e09 pep440-dev # staging/devel is currently inactive (but has the 1.4.1rc4 namespace) staging/devel 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index e15b1bb57..ad47d8a25 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -18,10 +18,10 @@ from octoprint.util.version import ( ) SENTRY_URL_SERVER = ( - "https://b39cd0dcaea5404798ec3eb193b291db@o118517.ingest.sentry.io/1373987" + "https://890bd6bca44a4b7e92918b0ba74049ca@o118517.ingest.sentry.io/1373987" ) SENTRY_URL_COREUI = ( - "https://ab48b21452fe424eaf79468aa6c94bd7@o118517.ingest.sentry.io/1374096" + "https://1f4ba2d14bfc4b1c9a861fde1c1d452d@o118517.ingest.sentry.io/1374096" ) SETTINGS_DEFAULTS = { diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index c48642a70..14d065804 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -490,6 +490,7 @@ def _saveSettings(data): s.setBaseFolder(folder, future[folder]) except Exception: + logger.exception("Something went wrong while saving a folder path") abort(400, description="At least one of the configured folders is invalid") if "api" in data: diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 28ddc4800..71b494c23 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -34,6 +34,7 @@ from yaml import YAMLError from octoprint.util import ( CaseInsensitiveSet, atomic_write, + deprecated, dict_merge, fast_deepcopy, generate_api_key, @@ -862,7 +863,6 @@ class Settings: self._map = HierarchicalChainMap({}, default_settings) self.load_overlays(overlays) - self._config = None self._dirty = False self._dirty_time = 0 self._last_config_hash = None @@ -1125,7 +1125,7 @@ class Settings: @property def config_yaml(self): - return yaml.dump(self._config) + return yaml.dump(self.config) @property def config_hash(self): @@ -1140,10 +1140,28 @@ class Settings: return self._last_config_hash @property - def _config(self): + def config(self): + """ + A view of the local config as stored in config.yaml + + Does not support modifications, they will be thrown away silently. If you need to + modify anything in the settings, utilize the provided set and remove methods. + """ return self._map.top_map + @property + @deprecated( + "Settings._config has been deprecated and is a read-only view. Please use Settings.config or the set & remove methods instead.", + since="1.8.0", + ) + def _config(self): + return self.config + @_config.setter + @deprecated( + "Setting of Settings._config has been deprecated. Please use the set & remove methods instead and get in touch if you have a usecase they don't cover.", + since="1.8.0", + ) def _config(self, value): self._map.top_map = value @@ -1174,11 +1192,14 @@ class Settings: # ~~ load and save def load(self, migrate=False): + config = None + mtime = None + if os.path.exists(self._configfile) and os.path.isfile(self._configfile): with open(self._configfile, encoding="utf-8", errors="replace") as f: try: - self._config = yaml.load_from_file(file=f) - self._mtime = self.last_modified + config = yaml.load_from_file(file=f) + mtime = self.last_modified except YAMLError as e: details = str(e) @@ -1198,8 +1219,11 @@ class Settings: ) # changed from else to handle cases where the file exists, but is empty / 0 bytes - if not self._config or not isinstance(self._config, dict): - self._config = {} + if not config or not isinstance(config, dict): + config = {} + + self._map.top_map = config + self._mtime = mtime if migrate: self._migrate_config() @@ -1293,7 +1317,7 @@ class Settings: def _migrate_config(self, config=None, persist=False): if config is None: - config = self._config + config = self._map.top_map persist = True dirty = False @@ -1315,6 +1339,9 @@ class Settings: dirty = migrate(config) or dirty if dirty and persist: + self._map.top_map = ( + config # we need to write it back here or the changes will be lost + ) self.save(force=True) def _migrate_gcode_scripts(self, config): @@ -1833,7 +1860,7 @@ class Settings: permissions=0o600, max_permissions=0o666, ) as configFile: - yaml.save_to_file(self._config, file=configFile) + yaml.save_to_file(self._map.top_map, file=configFile) self._dirty = False except Exception: self._logger.exception("Error while saving config.yaml!") @@ -2072,10 +2099,7 @@ class Settings: folder = default_folder try: - del self._config["folder"][type] - if not len(self._config["folder"]): - del self._config["folder"] - self._mark_dirty() + self.remove(["folder", type]) self.save() except KeyError: pass @@ -2270,23 +2294,12 @@ class Settings: currentPath = self.getBaseFolder(type) defaultPath = self._get_default_folder(type) - if ( - (path is None or path == defaultPath) - and "folder" in self._config - and type in self._config["folder"] - ): - del self._config["folder"][type] - if not self._config["folder"]: - del self._config["folder"] - self._mark_dirty() + if path is None or path == defaultPath: + self.remove(["folder", type]) elif (path != currentPath and path != defaultPath) or force: if validate: _validate_folder(path, check_writable=True, deep_check_writable=True) - - if "folder" not in self._config: - self._config["folder"] = {} - self._config["folder"][type] = path - self._mark_dirty() + self.set(["folder", type], path, force=force) def saveScript(self, script_type, name, script): script_folder = self.getBaseFolder("scripts") diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 92b525600..49d3e8a9a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -6268,6 +6268,10 @@ def parse_temperature_line(line, current): for match in re.finditer(regex_temp, line): values = match.groupdict() sensor = values["sensor"] + if sensor in result: + # sensor already seen, let's not overwrite stuff + continue + toolnum = values.get("toolnum", None) tool_number = int(toolnum) if toolnum is not None and len(toolnum) else None if tool_number and tool_number > max_tool_num: diff --git a/tests/util/test_comm_helpers.py b/tests/util/test_comm_helpers.py index ac600b978..7bcf90386 100644 --- a/tests/util/test_comm_helpers.py +++ b/tests/util/test_comm_helpers.py @@ -330,6 +330,16 @@ class TestCommHelpers(unittest.TestCase): }, 0, ), + ( + # Only first occurrence of a sensor should be used, second B gets ignored + "T:210.04 /210.00 B:52.00 /52.00 @:85 B:1234.0 /1234.0", + 0, + { + "T0": (210.04, 210.0), + "B": (52.00, 52.0), + }, + 0, + ), ) @unpack def test_process_temperature_line(self, line, current, expected_result, expected_max):