mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 10:17:52 -06:00
Do not run firmware update check jobs in parallel
CURA-5418 To avoid showing multiple update messages.
This commit is contained in:
parent
af2d05ebfa
commit
afc5c1fbbd
1 changed files with 17 additions and 5 deletions
|
@ -6,11 +6,13 @@ from PyQt5.QtGui import QDesktopServices
|
||||||
|
|
||||||
from UM.Extension import Extension
|
from UM.Extension import Extension
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
|
||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
|
|
||||||
from .FirmwareUpdateCheckerJob import FirmwareUpdateCheckerJob
|
from .FirmwareUpdateCheckerJob import FirmwareUpdateCheckerJob
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
|
||||||
|
|
||||||
i18n_catalog = i18nCatalog("cura")
|
i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ class FirmwareUpdateChecker(Extension):
|
||||||
ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
|
||||||
|
|
||||||
self._download_url = None
|
self._download_url = None
|
||||||
|
self._check_job = None
|
||||||
|
|
||||||
## Callback for the message that is spawned when there is a new version.
|
## Callback for the message that is spawned when there is a new version.
|
||||||
def _onActionTriggered(self, message, action):
|
def _onActionTriggered(self, message, action):
|
||||||
|
@ -50,6 +53,9 @@ class FirmwareUpdateChecker(Extension):
|
||||||
if isinstance(container, GlobalStack):
|
if isinstance(container, GlobalStack):
|
||||||
self.checkFirmwareVersion(container, True)
|
self.checkFirmwareVersion(container, True)
|
||||||
|
|
||||||
|
def _onJobFinished(self, *args, **kwargs):
|
||||||
|
self._check_job = None
|
||||||
|
|
||||||
## Connect with software.ultimaker.com, load latest.version and check version info.
|
## Connect with software.ultimaker.com, load latest.version and check version info.
|
||||||
# If the version info is different from the current version, spawn a message to
|
# If the version info is different from the current version, spawn a message to
|
||||||
# allow the user to download it.
|
# allow the user to download it.
|
||||||
|
@ -57,7 +63,13 @@ class FirmwareUpdateChecker(Extension):
|
||||||
# \param silent type(boolean) Suppresses messages other than "new version found" messages.
|
# \param silent type(boolean) Suppresses messages other than "new version found" messages.
|
||||||
# This is used when checking for a new firmware version at startup.
|
# This is used when checking for a new firmware version at startup.
|
||||||
def checkFirmwareVersion(self, container = None, silent = False):
|
def checkFirmwareVersion(self, container = None, silent = False):
|
||||||
job = FirmwareUpdateCheckerJob(container = container, silent = silent, url = self.JEDI_VERSION_URL,
|
# Do not run multiple check jobs in parallel
|
||||||
|
if self._check_job is not None:
|
||||||
|
Logger.log("i", "A firmware update check is already running, do nothing.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self._check_job = FirmwareUpdateCheckerJob(container = container, silent = silent, url = self.JEDI_VERSION_URL,
|
||||||
callback = self._onActionTriggered,
|
callback = self._onActionTriggered,
|
||||||
set_download_url_callback = self._onSetDownloadUrl)
|
set_download_url_callback = self._onSetDownloadUrl)
|
||||||
job.start()
|
self._check_job.start()
|
||||||
|
self._check_job.finished.connect(self._onJobFinished)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue