mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
FirmwareUpdateChecker: Small refactors due to code review.
This commit is contained in:
parent
1b7055f0f3
commit
60408c14bc
4 changed files with 27 additions and 24 deletions
|
@ -12,17 +12,17 @@ from UM.i18n import i18nCatalog
|
|||
i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
|
||||
def get_settings_key_for_machine(machine_id: int) -> str:
|
||||
def getSettingsKeyForMachine(machine_id: int) -> str:
|
||||
return "info/latest_checked_firmware_for_{0}".format(machine_id)
|
||||
|
||||
|
||||
def default_parse_version_response(response: str) -> Version:
|
||||
def defaultParseVersionResponse(response: str) -> Version:
|
||||
raw_str = response.split("\n", 1)[0].rstrip()
|
||||
return Version(raw_str.split(".")) # Split it into a list; the default parsing of "single string" is different.
|
||||
return Version(raw_str)
|
||||
|
||||
|
||||
class FirmwareUpdateCheckerLookup:
|
||||
JSON_NAME_TO_VERSION_PARSE_FUNCTION = {"default": default_parse_version_response}
|
||||
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.
|
||||
|
@ -48,7 +48,7 @@ class FirmwareUpdateCheckerLookup:
|
|||
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 = default_parse_version_response # Use default instead if nothing is found.
|
||||
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"):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue