From 482f0461fcdd49d5f42eff04920f14232e25303e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 18 Dec 2015 10:50:54 +0100 Subject: [PATCH] Add check for profile version The profile reader now checks whether the profile version is the same as the target version in the Dictionary of Doom. Contributes to issue CURA-37. --- plugins/LegacyProfileReader/DictionaryOfDoom.json | 2 +- plugins/LegacyProfileReader/LegacyProfileReader.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/LegacyProfileReader/DictionaryOfDoom.json b/plugins/LegacyProfileReader/DictionaryOfDoom.json index efbfcac7d4..6ff6dac4dd 100644 --- a/plugins/LegacyProfileReader/DictionaryOfDoom.json +++ b/plugins/LegacyProfileReader/DictionaryOfDoom.json @@ -1,6 +1,6 @@ { "source_version": "15.04", - "target_version": "2.1", + "target_version": 1, "translation": { "line_width": "nozzle_size", diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 5491b3ca18..5d89a85978 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -82,6 +82,14 @@ class LegacyProfileReader(ProfileReader): Logger.log("e", "Could not parse DictionaryOfDoom.json: %s", str(e)) return None + #Check the target version in the Dictionary of Doom with this application version. + if "target_version" not in dict_of_doom: + Logger.log("e", "Dictionary of Doom has no target version. Is it the correct JSON file?") + return None + if Profile.ProfileVersion != dict_of_doom["target_version"]: + Logger.log("e", "Dictionary of Doom of legacy profile reader (version %s) is not in sync with the profile version (version %s)!", dict_of_doom["target_version"], str(Profile.ProfileVersion)) + return None + if "translation" not in dict_of_doom: Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?") return None