def __init__(self, parent): title = _('Application upgrade') asset = assetManager.getSelfUpdaterAsset() updater = asset and asset.getUpdater() if not updater: raise Error('Application upgrade is not available') super().__init__(parent, title, updater)
def checkForUpdate(self): updAsset = assetManager.getSelfUpdaterAsset() if updAsset: if not assetListUpdater.isRunning() and not updAsset.hasUpdate(): assetListUpdater.start(updateList=True, autoUpdate=True) if assetListUpdater.isRunning(): with BusyDlg(self, _('Checking for update...')) as dlg: dlg.ShowModalWhile(assetListUpdater.isRunning) return updAsset.hasUpdate() return False
def runUpdater(self): updAsset = assetManager.getSelfUpdaterAsset() if updAsset and updAsset.hasUpdate(): dlg = wx.MessageDialog( self, _('New version is available. Update now?'), _('Upgrade'), wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: if not updAsset.hasLocalUpdate(): SelfUpdateWin(self).ShowModal() if updAsset.hasLocalUpdate(): updAsset.installUpdate() return True return False
def onClose(self, event): if event.CanVeto() and settings().askForUpdate: updAsset = assetManager.getSelfUpdaterAsset() if updAsset and updAsset.hasUpdate(): dlg = wx.MessageDialog( self, _('New version is available. Update now?'), _('Upgrade'), wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.runUpdater(False) assetManager.updateTask.stop() event.Skip()
def checkForUpdate(self): updAsset = assetManager.getSelfUpdaterAsset() if updAsset: if not assetListUpdater.isRunning() and not updAsset.hasUpdate(): assetListUpdater.start(updateList=True, autoUpdate=True) if assetListUpdater.isRunning(): with BusyDlg(self, _('Checking for update...'), cancellable=True) as dlg: if dlg.ShowModalWhile( assetListUpdater.isRunning) == wx.ID_OK: if assetListUpdater.hasList(): return updAsset else: assetListUpdater.stop() else: return updAsset
def runUpdater(self, askForUpdate=True): updAsset = assetManager.getSelfUpdaterAsset() if updAsset and updAsset.hasUpdate(): if not updAsset.hasLocalUpdate(): SelfUpdateWin(self).ShowModal() if askForUpdate: dlg = wx.MessageDialog( self, _('New version is ready to be installed. Upgrade now?' ), _('Upgrade'), wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal != wx.ID_YES: return False if updAsset.hasLocalUpdate(): updAsset.installUpdate() return True return False
def onMenuItemCheckUpdateClick(self, event): updAsset = assetManager.getSelfUpdaterAsset() hasLocalUpdate = updAsset and updAsset.hasLocalUpdate() if not assetManager.updateTask.isRunning() and not hasLocalUpdate: assetManager.updateTask.start() if assetManager.updateTask.isRunning(): with BusyDlg(self, _('Checking for update...')): while assetManager.updateTask.isRunning(): wx.Yield() if self.runUpdater(): self.Close(force=True) else: dlg = wx.MessageDialog(self, _('Your version is up to date'), _('Upgrade'), wx.OK | wx.ICON_INFORMATION) dlg.ShowModal()