FirmwareUpdateCheckerLookup.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import List, Optional
  4. from UM.i18n import i18nCatalog
  5. i18n_catalog = i18nCatalog("cura")
  6. def getSettingsKeyForMachine(machine_id: int) -> str:
  7. return "info/latest_checked_firmware_for_{0}".format(machine_id)
  8. class FirmwareUpdateCheckerLookup:
  9. def __init__(self, machine_name, machine_json) -> None:
  10. # Parse all the needed lookup-tables from the ".json" file(s) in the resources folder.
  11. self._machine_id = machine_json.get("id")
  12. self._machine_name = machine_name.lower() # Lower in-case upper-case chars are added to the original json.
  13. self._check_urls = [] # type:List[str]
  14. for check_url in machine_json.get("check_urls", []):
  15. self._check_urls.append(check_url)
  16. self._redirect_user = machine_json.get("update_url")
  17. def getMachineId(self) -> Optional[int]:
  18. return self._machine_id
  19. def getMachineName(self) -> Optional[int]:
  20. return self._machine_name
  21. def getCheckUrls(self) -> Optional[List[str]]:
  22. return self._check_urls
  23. def getRedirectUserUrl(self) -> Optional[str]:
  24. return self._redirect_user