mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Refactor out unnecesary 'container' parameter (to make tests easier). [UnitTests]
This commit is contained in:
parent
846d608a03
commit
2b8b995422
2 changed files with 8 additions and 10 deletions
|
@ -76,7 +76,7 @@ class FirmwareUpdateChecker(Extension):
|
||||||
Logger.log("i", "No machine with name {0} in list of firmware to check.".format(container_name))
|
Logger.log("i", "No machine with name {0} in list of firmware to check.".format(container_name))
|
||||||
return
|
return
|
||||||
|
|
||||||
self._check_job = FirmwareUpdateCheckerJob(container = container, silent = silent,
|
self._check_job = FirmwareUpdateCheckerJob(silent = silent,
|
||||||
machine_name = container_name, metadata = metadata,
|
machine_name = container_name, metadata = metadata,
|
||||||
callback = self._onActionTriggered)
|
callback = self._onActionTriggered)
|
||||||
self._check_job.start()
|
self._check_job.start()
|
||||||
|
|
|
@ -25,9 +25,8 @@ class FirmwareUpdateCheckerJob(Job):
|
||||||
ZERO_VERSION = Version(STRING_ZERO_VERSION)
|
ZERO_VERSION = Version(STRING_ZERO_VERSION)
|
||||||
EPSILON_VERSION = Version(STRING_EPSILON_VERSION)
|
EPSILON_VERSION = Version(STRING_EPSILON_VERSION)
|
||||||
|
|
||||||
def __init__(self, container, silent, machine_name, metadata, callback) -> None:
|
def __init__(self, silent, machine_name, metadata, callback) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._container = container
|
|
||||||
self.silent = silent
|
self.silent = silent
|
||||||
self._callback = callback
|
self._callback = callback
|
||||||
|
|
||||||
|
@ -83,13 +82,10 @@ class FirmwareUpdateCheckerJob(Job):
|
||||||
application_version = Application.getInstance().getVersion()
|
application_version = Application.getInstance().getVersion()
|
||||||
self._headers = {"User-Agent": "%s - %s" % (application_name, application_version)}
|
self._headers = {"User-Agent": "%s - %s" % (application_name, application_version)}
|
||||||
|
|
||||||
# get machine name from the definition container
|
|
||||||
machine_name = self._container.definition.getName()
|
|
||||||
|
|
||||||
# If it is not None, then we compare between the checked_version and the current_version
|
# If it is not None, then we compare between the checked_version and the current_version
|
||||||
machine_id = self._lookups.getMachineId()
|
machine_id = self._lookups.getMachineId()
|
||||||
if machine_id is not None:
|
if machine_id is not None:
|
||||||
Logger.log("i", "You have a(n) {0} in the printer list. Let's check the firmware!".format(machine_name))
|
Logger.log("i", "You have a(n) {0} in the printer list. Do firmware-check.".format(self._machine_name))
|
||||||
|
|
||||||
current_version = self.getCurrentVersion()
|
current_version = self.getCurrentVersion()
|
||||||
|
|
||||||
|
@ -100,18 +96,20 @@ class FirmwareUpdateCheckerJob(Job):
|
||||||
# If the checked_version is "", it's because is the first time we check firmware and in this case
|
# If the checked_version is "", it's because is the first time we check firmware and in this case
|
||||||
# we will not show the notification, but we will store it for the next time
|
# we will not show the notification, but we will store it for the next time
|
||||||
Application.getInstance().getPreferences().setValue(setting_key_str, current_version)
|
Application.getInstance().getPreferences().setValue(setting_key_str, current_version)
|
||||||
Logger.log("i", "Reading firmware version of %s: checked = %s - latest = %s", machine_name, checked_version, current_version)
|
Logger.log("i", "Reading firmware version of %s: checked = %s - latest = %s",
|
||||||
|
self._machine_name, checked_version, current_version)
|
||||||
|
|
||||||
# The first time we want to store the current version, the notification will not be shown,
|
# The first time we want to store the current version, the notification will not be shown,
|
||||||
# because the new version of Cura will be release before the firmware and we don't want to
|
# because the new version of Cura will be release before the firmware and we don't want to
|
||||||
# notify the user when no new firmware version is available.
|
# notify the user when no new firmware version is available.
|
||||||
if (checked_version != "") and (checked_version != current_version):
|
if (checked_version != "") and (checked_version != current_version):
|
||||||
Logger.log("i", "SHOWING FIRMWARE UPDATE MESSAGE")
|
Logger.log("i", "SHOWING FIRMWARE UPDATE MESSAGE")
|
||||||
message = FirmwareUpdateCheckerMessage(machine_id, machine_name, self._lookups.getRedirectUserUrl())
|
message = FirmwareUpdateCheckerMessage(machine_id, self._machine_name,
|
||||||
|
self._lookups.getRedirectUserUrl())
|
||||||
message.actionTriggered.connect(self._callback)
|
message.actionTriggered.connect(self._callback)
|
||||||
message.show()
|
message.show()
|
||||||
else:
|
else:
|
||||||
Logger.log("i", "No machine with name {0} in list of firmware to check.".format(machine_name))
|
Logger.log("i", "No machine with name {0} in list of firmware to check.".format(self._machine_name))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.log("w", "Failed to check for new version: %s", e)
|
Logger.log("w", "Failed to check for new version: %s", e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue