diff options
author | Remco Burema <r.burema@ultimaker.com> | 2018-10-13 20:36:11 +0300 |
---|---|---|
committer | Remco Burema <r.burema@ultimaker.com> | 2018-10-13 20:36:11 +0300 |
commit | 8c71a8855c9f80ce0beb5daad6bd643633db010b (patch) | |
tree | b4e838b74a0ad05c1341bbb3619a2ac273e62344 /plugins/FirmwareUpdateChecker | |
parent | 60408c14bcac5aac9ac8b623f1d455b06032cd09 (diff) |
FirmwareUpdateChecker: Remove superfluous 'version_parser' as a setting, since it broke lean principles.
Diffstat (limited to 'plugins/FirmwareUpdateChecker')
3 files changed, 9 insertions, 21 deletions
diff --git a/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerJob.py b/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerJob.py index 5bb9d076b6..a873f17d61 100644 --- a/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerJob.py +++ b/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerJob.py @@ -46,14 +46,17 @@ class FirmwareUpdateCheckerJob(Job): return result + def parseVersionResponse(self, response: str) -> Version: + raw_str = response.split("\n", 1)[0].rstrip() + return Version(raw_str) + def getCurrentVersionForMachine(self, machine_id: int) -> Version: max_version = self.ZERO_VERSION machine_urls = self._lookups.getCheckUrlsFor(machine_id) - parse_function = self._lookups.getParseVersionUrlFor(machine_id) - if machine_urls is not None and parse_function is not None: + if machine_urls is not None: for url in machine_urls: - version = parse_function(self.getUrlResponse(url)) + version = self.parseVersionResponse(self.getUrlResponse(url)) if version > max_version: max_version = version diff --git a/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerLookup.py b/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerLookup.py index ceecef61ba..4813e3ecbb 100644 --- a/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerLookup.py +++ b/plugins/FirmwareUpdateChecker/FirmwareUpdateCheckerLookup.py @@ -16,13 +16,7 @@ def getSettingsKeyForMachine(machine_id: int) -> str: return "info/latest_checked_firmware_for_{0}".format(machine_id) -def defaultParseVersionResponse(response: str) -> Version: - raw_str = response.split("\n", 1)[0].rstrip() - return Version(raw_str) - - class FirmwareUpdateCheckerLookup: - JSON_NAME_TO_VERSION_PARSE_FUNCTION = {"default": defaultParseVersionResponse} def __init__(self, json_path) -> None: # Open the .json file with the needed lookup-lists for each machine(/model) and retrieve "raw" json. @@ -44,12 +38,6 @@ class FirmwareUpdateCheckerLookup: machine_name = machine_json.get("name").lower() # Lower in case upper-case char are added to the json. self._machine_ids.append(machine_id) self._machine_per_name[machine_name] = machine_id - version_parse_function = \ - self.JSON_NAME_TO_VERSION_PARSE_FUNCTION.get(machine_json.get("version_parser")) - if version_parse_function is None: - Logger.log("w", "No version-parse-function specified for machine {0}.".format(machine_name)) - version_parse_function = defaultParseVersionResponse # Use default instead if nothing is found. - self._parse_version_url_per_machine[machine_id] = version_parse_function self._check_urls_per_machine[machine_id] = [] # Multiple check-urls: see "_comment" in the .json file. for check_url in machine_json.get("check_urls"): self._check_urls_per_machine[machine_id].append(check_url) diff --git a/plugins/FirmwareUpdateChecker/resources/machines.json b/plugins/FirmwareUpdateChecker/resources/machines.json index ee072f75c3..d9eaad0abf 100644 --- a/plugins/FirmwareUpdateChecker/resources/machines.json +++ b/plugins/FirmwareUpdateChecker/resources/machines.json @@ -11,8 +11,7 @@ "http://software.ultimaker.com/jedi/releases/latest.version?utm_source=cura&utm_medium=software&utm_campaign=resources", "http://software.ultimaker.com/releases/firmware/9066/stable/version.txt" ], - "update_url": "https://ultimaker.com/en/resources/20500-upgrade-firmware", - "version_parser": "default" + "update_url": "https://ultimaker.com/en/resources/20500-upgrade-firmware" }, { "id": 9511, @@ -22,15 +21,13 @@ "http://software.ultimaker.com/jedi/releases/latest.version?utm_source=cura&utm_medium=software&utm_campaign=resources", "http://software.ultimaker.com/releases/firmware/9511/stable/version.txt" ], - "update_url": "https://ultimaker.com/en/resources/20500-upgrade-firmware", - "version_parser": "default" + "update_url": "https://ultimaker.com/en/resources/20500-upgrade-firmware" }, { "id": 9051, "name": "ultimaker s5", "check_urls": ["http://software.ultimaker.com/releases/firmware/9051/stable/version.txt"], - "update_url": "https://ultimaker.com/en/resources/20500-upgrade-firmware", - "version_parser": "default" + "update_url": "https://ultimaker.com/en/resources/20500-upgrade-firmware" } ] } |