def test_setAddonCompatibility_untestedWithoutSupportToUnknown_incompatibleStored(self): addonNotSupported = mockAddon(minNVDAVersion=NextNVDAVersionString, lastTestedNVDAVersion=LastNVDAVersionString) AddonCompatibilityState.setAddonCompatibility( addonNotSupported, NVDAVersion=CurrentNVDAVersionTuple ) compat = self.mockStateSaver.getSavedState(addonNotSupported) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE)
def test_setAddonCompatibility_untestedWithSupportToUnknown_unknownStored(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) AddonCompatibilityState.setAddonCompatibility( notTestedAddon, NVDAVersion=CurrentNVDAVersionTuple ) compat = self.mockStateSaver.getSavedState(notTestedAddon) self.assertCompatValuesMatch(compat, compatValues.UNKNOWN)
def test_setAddonCompatibility_testedWithSupportToUnknown_compatibleStored(self): compatibleAddon = mockAddon() AddonCompatibilityState.setAddonCompatibility( compatibleAddon, NVDAVersion=CurrentNVDAVersionTuple ) compat = self.mockStateSaver.getSavedState(compatibleAddon) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_COMPATIBLE)
def test_setAddonCompatibility_testedWithoutSupportToIncompatible_incompatibleStored(self): addonNotSupported = mockAddon(minNVDAVersion=NextNVDAVersionString) AddonCompatibilityState.setAddonCompatibility( addonNotSupported, NVDAVersion=CurrentNVDAVersionTuple, compatibilityStateValue=compatValues.MANUALLY_SET_INCOMPATIBLE ) compat = self.mockStateSaver.getSavedState(addonNotSupported) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE)
def test_setAddonCompatibility_untestedWithSupportToIncompatible_manuallySetIncompatibleStored(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) AddonCompatibilityState.setAddonCompatibility( notTestedAddon, NVDAVersion=CurrentNVDAVersionTuple, compatibilityStateValue=compatValues.MANUALLY_SET_INCOMPATIBLE ) compat = self.mockStateSaver.getSavedState(notTestedAddon) self.assertCompatValuesMatch(compat, compatValues.MANUALLY_SET_INCOMPATIBLE)
def refreshAddonsList(self,activeIndex=0): self.addonsList.DeleteAllItems() self.curAddons=[] for idx, addon in enumerate(self.unknownCompatibilityAddonsList): self.addonsList.Append(( "", # check box field addon.manifest['summary'], addon.version, addon.manifest.get('lastTestedNVDAVersion') or # Translators: Displayed for add-ons in the incompatible add-ons dialog # if the last tested NVDA version is not specified. _("not specified") )) compatValue = AddonCompatibilityState.getAddonCompatibility(addon, CURRENT_NVDA_VERSION) shouldCheck = compatValue == compatValues.MANUALLY_SET_COMPATIBLE self.addonsList.CheckItem(idx, check=shouldCheck) # select the given active addon, the last addon (after an addon is installed), or the first addon if not given curAddonsLen=len(self.unknownCompatibilityAddonsList) if curAddonsLen>0: # No addons to select if activeIndex==-1: # Special value, select last addon (newly installed) activeIndex=curAddonsLen-1 elif activeIndex<0 or activeIndex>=curAddonsLen: # Index invalid, select first addon. activeIndex=0 self.addonsList.Select(activeIndex,on=1) self.addonsList.SetItemState(activeIndex,wx.LIST_STATE_FOCUSED,wx.LIST_STATE_FOCUSED)
def refreshAddonsList(self, activeIndex=0): self.addonsList.DeleteAllItems() self.curAddons = [] for idx, addon in enumerate(self.unknownCompatibilityAddonsList): self.addonsList.Append(( "", # check box field addon.manifest['summary'], addon.version, addon.manifest.get('lastTestedNVDAVersion') or # Translators: Displayed for add-ons in the incompatible add-ons dialog # if the last tested NVDA version is not specified. _("not specified"))) compatValue = AddonCompatibilityState.getAddonCompatibility( addon, CURRENT_NVDA_VERSION) shouldCheck = compatValue == compatValues.MANUALLY_SET_COMPATIBLE self.addonsList.CheckItem(idx, check=shouldCheck) # select the given active addon, the last addon (after an addon is installed), or the first addon if not given curAddonsLen = len(self.unknownCompatibilityAddonsList) if curAddonsLen > 0: # No addons to select if activeIndex == -1: # Special value, select last addon (newly installed) activeIndex = curAddonsLen - 1 elif activeIndex < 0 or activeIndex >= curAddonsLen: # Index invalid, select first addon. activeIndex = 0 self.addonsList.Select(activeIndex, on=1) self.addonsList.SetItemState(activeIndex, wx.LIST_STATE_FOCUSED, wx.LIST_STATE_FOCUSED)
def test_getAddonCompatibility_stateUnknown_testedAndSupported_compatible( self): compatibleAddon = mockAddon() self.resetMockStateSaver(compatibleAddon, compatValues.UNKNOWN) compat = AddonCompatibilityState.getAddonCompatibility( compatibleAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_COMPATIBLE)
def test_getAddonCompatibility_noState_notTestedNotSupported_incompatible( self): addonNotSupported = mockAddon( minNVDAVersion=NextNVDAVersionString, lastTestedNVDAVersion=LastNVDAVersionString) compat = AddonCompatibilityState.getAddonCompatibility( addonNotSupported, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE)
def test_getAddonCompatibility_whiteListed_compatible(self): compatibleAddon = mockAddon() self.resetMockStateSaver(compatibleAddon, compatValues.MANUALLY_SET_COMPATIBLE) compat = AddonCompatibilityState.getAddonCompatibility( compatibleAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch( compat, compatValues.AUTO_DEDUCED_COMPATIBLE ) # auto deduced compat trumps manual set compat
def test_getAddonCompatibility_blackListed_untestedWithSupport_manuallySetIncompatible( self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) self.resetMockStateSaver(notTestedAddon, compatValues.MANUALLY_SET_INCOMPATIBLE) compat = AddonCompatibilityState.getAddonCompatibility( notTestedAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.MANUALLY_SET_INCOMPATIBLE)
def test_getAddonCompatibility_blackListed_testedWithoutSupport_incompatible( self): addonNotSupported = mockAddon(minNVDAVersion=NextNVDAVersionString) self.resetMockStateSaver(addonNotSupported, compatValues.MANUALLY_SET_INCOMPATIBLE) compat = AddonCompatibilityState.getAddonCompatibility( addonNotSupported, CurrentNVDAVersionTuple) self.assertCompatValuesMatch( compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE ) # auto deduced incompt trumps manual set incompat
def installAddon(self, addonPath, closeAfter=False): try: try: bundle = addonHandler.AddonBundle(addonPath) except: log.error("Error opening addon bundle from %s" % addonPath, exc_info=True) gui.messageBox( # Translators: The message displayed when an error occurs when opening an add-on package for adding. _("Failed to open add-on package file at %s - missing file or invalid file format" ) % addonPath, # Translators: The title of a dialog presented when an error occurs. _("Error"), wx.OK | wx.ICON_ERROR) return if not addonVersionCheck.hasAddonGotRequiredSupport(bundle): self._showAddonRequiresNVDAUpdateDialog(bundle) return if not addonVersionCheck.isAddonTested(bundle): if wx.YES != self._showAddonUntestedDialog(bundle): return AddonCompatibilityState.setAddonCompatibility( addon=bundle, compatibilityStateValue=compatValues. MANUALLY_SET_COMPATIBLE) elif wx.YES != self._showConfirmAddonInstallDialog(bundle): return prevAddon = None for addon in self.curAddons: if not addon.isPendingRemove and bundle.name == addon.manifest[ 'name']: prevAddon = addon break if prevAddon: summary = bundle.manifest["summary"] curVersion = prevAddon.manifest["version"] newVersion = bundle.manifest["version"] if gui.messageBox( # Translators: A message asking if the user wishes to update an add-on with the same version currently installed according to the version number. _("You are about to install version {newVersion} of {summary}, which appears to be already installed. Would you still like to update?" ).format(summary=summary, newVersion=newVersion) if curVersion == newVersion else # Translators: A message asking if the user wishes to update a previously installed add-on with this one. _("A version of this add-on is already installed. Would you like to update {summary} version {curVersion} to version {newVersion}?" ).format(summary=summary, curVersion=curVersion, newVersion=newVersion), # Translators: A title for the dialog asking if the user wishes to update a previously installed add-on with this one. _("Add-on Installation"), wx.YES | wx.NO | wx.ICON_WARNING) != wx.YES: return prevAddon.requestRemove() progressDialog = gui.IndeterminateProgressDialog( gui.mainFrame, # Translators: The title of the dialog presented while an Addon is being installed. _("Installing Add-on"), # Translators: The message displayed while an addon is being installed. _("Please wait while the add-on is being installed.")) try: gui.ExecAndPump(addonHandler.installAddonBundle, bundle) except: log.error("Error installing addon bundle from %s" % addonPath, exc_info=True) self.refreshAddonsList() progressDialog.done() del progressDialog # Translators: The message displayed when an error occurs when installing an add-on package. gui.messageBox( _("Failed to install add-on from %s") % addonPath, # Translators: The title of a dialog presented when an error occurs. _("Error"), wx.OK | wx.ICON_ERROR) return else: self.refreshAddonsList(activeIndex=-1) progressDialog.done() del progressDialog finally: if closeAfter: # #4460: If we do this immediately, wx seems to drop the WM_QUIT sent if the user chooses to restart. # This seems to have something to do with the wx.ProgressDialog. # The CallLater seems to work around this. wx.CallLater(1, self.Close)
def resetMockStateSaver(self, addon=None, compatVal=None): self.mockStateSaver = self.MockStateSaver(NVDAVersionTuple=CurrentNVDAVersionTuple) if addon is not None and compatVal is not None: self.mockStateSaver.setReturnOnLoad(addon, compatVal) AddonCompatibilityState.initialise(statePersistence=self.mockStateSaver, forceReInit=True)
def test_getAddonCompatibility_noState_notTestedWithSupport_unknown(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) compat = AddonCompatibilityState.getAddonCompatibility( notTestedAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.UNKNOWN)
def saveState(self): for itemIndex in xrange(len(self.unknownCompatibilityAddonsList)): checked = self.addonsList.IsChecked(itemIndex) compatValue = compatValues.MANUALLY_SET_COMPATIBLE if checked else compatValues.MANUALLY_SET_INCOMPATIBLE addon = self.unknownCompatibilityAddonsList[itemIndex] AddonCompatibilityState.setAddonCompatibility(addon, compatibilityStateValue=compatValue)
def test_getAddonCompatibility_noState_testedAndSupported_compatible(self): compatibleAddon = mockAddon() compat = AddonCompatibilityState.getAddonCompatibility( compatibleAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_COMPATIBLE)
def __init__(self, parent, updateInfo, auto): # Translators: The title of the dialog informing the user about an NVDA update. wx.Dialog.__init__(self, parent, title=_("NVDA Update")) DpiScalingHelperMixin.__init__(self, self.GetHandle()) self.updateInfo = updateInfo mainSizer = wx.BoxSizer(wx.VERTICAL) sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL) pendingUpdateDetails = getPendingUpdate() canOfferPendingUpdate = isPendingUpdate() and pendingUpdateDetails[1] == updateInfo["version"] text = sHelper.addItem(wx.StaticText(self)) bHelper = guiHelper.ButtonHelper(wx.HORIZONTAL) if not updateInfo: # Translators: A message indicating that no update to NVDA is available. message = _("No update available.") elif canOfferPendingUpdate: # Translators: A message indicating that an updated version of NVDA has been downloaded # and is pending to be installed. message = _("NVDA version {version} has been downloaded and is pending installation.").format(**updateInfo) self.newNVDAVersionTuple = pendingUpdateDetails[2] addonsWithoutKnownCompat = list(getAddonsWithoutKnownCompatibility(self.newNVDAVersionTuple)) showAddonCompat = any(addonsWithoutKnownCompat) if showAddonCompat: # Translators: A message indicating that some add-ons will be disabled unless reviewed before installation. message = message + _("\n\n" "However, your NVDA configuration contains add-ons that are not tested with this version of NVDA. " "These add-ons will be disabled after installation. " "If you rely on these add-ons, please review the list to manually enable them before installation." ) confirmationCheckbox = sHelper.addItem(wx.CheckBox( self, # Translators: A message to confirm that the user understands that addons that have not been reviewed and made # available, will be disabled after installation. label=_("I understand that these untested add-ons will be disabled") )) confirmationCheckbox.Bind( wx.EVT_CHECKBOX, lambda evt: self.installPendingButton.Enable(not self.installPendingButton.Enabled) ) # Translators: The label of a button to review add-ons prior to NVDA update. reviewAddonsButton = bHelper.addButton(self, label=_("&Review add-ons...")) reviewAddonsButton.Bind(wx.EVT_BUTTON, self.onReviewAddonsButton) reviewAddonsButton.SetFocus() for a in addonsWithoutKnownCompat: # now that the use is warned about the compatibility and so that the user is # not prompted again after installation, we set the default compatibility AddonCompatibilityState.setAddonCompatibility( addon=a, NVDAVersion=self.newNVDAVersionTuple, compatibilityStateValue=compatValues.MANUALLY_SET_INCOMPATIBLE ) self.installPendingButton = bHelper.addButton( self, # Translators: The label of a button to install a pending NVDA update. # {version} will be replaced with the version; e.g. 2011.3. label=_("&Install NVDA {version}").format(**updateInfo) ) self.installPendingButton.Bind( wx.EVT_BUTTON, lambda evt: self.onInstallButton(pendingUpdateDetails[0]) ) self.installPendingButton.Enable(not showAddonCompat) bHelper.addButton( self, # Translators: The label of a button to re-download a pending NVDA update. label=_("Re-&download update") ).Bind(wx.EVT_BUTTON, self.onDownloadButton) else: # Translators: A message indicating that an updated version of NVDA is available. # {version} will be replaced with the version; e.g. 2011.3. message = _("NVDA version {version} is available.").format(**updateInfo) bHelper.addButton( self, # Translators: The label of a button to download an NVDA update. label=_("&Download update") ).Bind(wx.EVT_BUTTON, self.onDownloadButton) if auto: # this prompt was triggered by auto update checker # the user might not want to wait for a download right now, so give the option to be reminded later. # Translators: The label of a button to remind the user later about performing some action. remindMeButton = bHelper.addButton(self, label=_("Remind me &later")) remindMeButton.Bind(wx.EVT_BUTTON, self.onLaterButton) remindMeButton.SetFocus() text.SetLabel(message) text.Wrap(self.scaleSize(500)) sHelper.addDialogDismissButtons(bHelper) # Translators: The label of a button to close a dialog. closeButton = bHelper.addButton(self, wx.ID_CLOSE, label=_("&Close")) closeButton.Bind(wx.EVT_BUTTON, lambda evt: self.Close()) self.Bind(wx.EVT_CLOSE, lambda evt: self.Destroy()) self.EscapeId = wx.ID_CLOSE mainSizer.Add(sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL) self.Sizer = mainSizer mainSizer.Fit(self) self.CentreOnScreen() self.Show()
def test_getAddonCompatibility_blackListed_testedWithSupport_compatible(self): compatibleAddon = mockAddon() self.resetMockStateSaver(compatibleAddon, compatValues.MANUALLY_SET_INCOMPATIBLE) compat = AddonCompatibilityState.getAddonCompatibility(compatibleAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_COMPATIBLE) # auto deduced compat trumps manual set incompat
def test_getAddonCompatibility_noState_notTestedWithSupport_unknown(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) compat = AddonCompatibilityState.getAddonCompatibility(notTestedAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.UNKNOWN)
def test_getAddonCompatibility_noState_notTestedNotSupported_incompatible(self): addonNotSupported = mockAddon(minNVDAVersion=NextNVDAVersionString, lastTestedNVDAVersion=LastNVDAVersionString) compat = AddonCompatibilityState.getAddonCompatibility(addonNotSupported, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE)
def test_getAddonCompatibility_stateUnknown_incompatible(self): addonNotSupported = mockAddon(minNVDAVersion=NextNVDAVersionString) self.resetMockStateSaver(addonNotSupported, compatValues.UNKNOWN) compat = AddonCompatibilityState.getAddonCompatibility(addonNotSupported, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE)
def test_getAddonCompatibility_stateUnknown_testedAndSupported_compatible(self): compatibleAddon = mockAddon() self.resetMockStateSaver(compatibleAddon, compatValues.UNKNOWN) compat = AddonCompatibilityState.getAddonCompatibility(compatibleAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_COMPATIBLE)
def __init__(self, parent, destPath, version): self.destPath = destPath self.version = version self.storeUpdatesDirWritable = os.path.isdir( storeUpdatesDir) and os.access(storeUpdatesDir, os.W_OK) # Translators: The title of the dialog asking the user to Install an NVDA update. wx.Dialog.__init__(self, parent, title=_("NVDA Update")) DpiScalingHelperMixin.__init__(self, self.GetHandle()) mainSizer = wx.BoxSizer(wx.VERTICAL) sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL) # Translators: A message indicating that an updated version of NVDA is ready to be installed. message = _("NVDA version {version} is ready to be installed.\n" ).format(version=version) newNVDAVersionTuple = versionInfo.getNVDAVersionTupleFromString( self.version) addonsWithoutKnownCompat = list( getAddonsWithoutKnownCompatibility(newNVDAVersionTuple)) showAddonCompat = any(addonsWithoutKnownCompat) if showAddonCompat: # Translators: A message indicating that some add-ons will be disabled unless reviewed before installation. message = message + _( "\nHowever, your NVDA configuration contains add-ons that are not tested with this version of NVDA. " "These add-ons will be disabled after installation. " "If you rely on these add-ons, please review the list to manually enable them before installation." ) for a in addonsWithoutKnownCompat: # now that the use is warned about the compatibility and so that the user is # not prompted again after installation, we set the default compatibility AddonCompatibilityState.setAddonCompatibility( addon=a, NVDAVersion=newNVDAVersionTuple, compatibilityStateValue=compatValues. MANUALLY_SET_INCOMPATIBLE) text = sHelper.addItem(wx.StaticText(self, label=message)) text.Wrap(self.scaleSize(500)) if showAddonCompat: self.confirmationCheckbox = sHelper.addItem( wx.CheckBox( self, # Translators: A message to confirm that the user understands that addons that have not been reviewed and made # available, will be disabled after installation. label= _("I understand that these untested add-ons will be disabled" ))) bHelper = sHelper.addDialogDismissButtons( guiHelper.ButtonHelper(wx.HORIZONTAL)) if showAddonCompat: # Translators: The label of a button to review add-ons prior to NVDA update. reviewAddonsButton = bHelper.addButton( self, label=_("&Review add-ons...")) reviewAddonsButton.Bind(wx.EVT_BUTTON, self.onReviewAddonsButton) reviewAddonsButton.SetFocus() # Translators: The label of a button to install an NVDA update. installButton = bHelper.addButton(self, wx.ID_OK, label=_("&Install update")) installButton.Bind(wx.EVT_BUTTON, self.onInstallButton) if not showAddonCompat: installButton.SetFocus() else: self.confirmationCheckbox.Bind( wx.EVT_CHECKBOX, lambda evt: installButton.Enable(not installButton.Enabled)) installButton.Enable(False) if self.storeUpdatesDirWritable: # Translators: The label of a button to postpone an NVDA update. postponeButton = bHelper.addButton(self, wx.ID_CLOSE, label=_("&Postpone update")) postponeButton.Bind(wx.EVT_BUTTON, self.onPostponeButton) self.EscapeId = wx.ID_CLOSE else: self.EscapeId = wx.ID_OK mainSizer.Add(sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL) self.Sizer = mainSizer mainSizer.Fit(self) self.CentreOnScreen()
def test_getAddonCompatibility_blackListed_testedWithoutSupport_incompatible(self): addonNotSupported = mockAddon(minNVDAVersion=NextNVDAVersionString) self.resetMockStateSaver(addonNotSupported, compatValues.MANUALLY_SET_INCOMPATIBLE) compat = AddonCompatibilityState.getAddonCompatibility(addonNotSupported, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_INCOMPATIBLE) # auto deduced incompt trumps manual set incompat
def test_getAddonCompatibility_blackListed_untestedWithSupport_manuallySetIncompatible(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) self.resetMockStateSaver(notTestedAddon, compatValues.MANUALLY_SET_INCOMPATIBLE) compat = AddonCompatibilityState.getAddonCompatibility(notTestedAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.MANUALLY_SET_INCOMPATIBLE)
def test_getAddonCompatibility_stateUnknown_unknown(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) self.resetMockStateSaver(notTestedAddon, compatValues.UNKNOWN) compat = AddonCompatibilityState.getAddonCompatibility( notTestedAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.UNKNOWN)
def installAddon(self, addonPath, closeAfter=False): try: try: bundle = addonHandler.AddonBundle(addonPath) except: log.error("Error opening addon bundle from %s" % addonPath, exc_info=True) gui.messageBox( # Translators: The message displayed when an error occurs when opening an add-on package for adding. _("Failed to open add-on package file at %s - missing file or invalid file format") % addonPath, # Translators: The title of a dialog presented when an error occurs. _("Error"), wx.OK | wx.ICON_ERROR ) return if not addonVersionCheck.hasAddonGotRequiredSupport(bundle): self._showAddonRequiresNVDAUpdateDialog(bundle) return if not addonVersionCheck.isAddonTested(bundle): if wx.YES != self._showAddonUntestedDialog(bundle): return AddonCompatibilityState.setAddonCompatibility( addon=bundle, compatibilityStateValue=compatValues.MANUALLY_SET_COMPATIBLE ) elif wx.YES != self._showConfirmAddonInstallDialog(bundle): return prevAddon=None for addon in self.curAddons: if not addon.isPendingRemove and bundle.name==addon.manifest['name']: prevAddon=addon break if prevAddon: summary=bundle.manifest["summary"] curVersion=prevAddon.manifest["version"] newVersion=bundle.manifest["version"] if gui.messageBox( # Translators: A message asking if the user wishes to update an add-on with the same version currently installed according to the version number. _("You are about to install version {newVersion} of {summary}, which appears to be already installed. Would you still like to update?").format( summary=summary, newVersion=newVersion ) if curVersion==newVersion else # Translators: A message asking if the user wishes to update a previously installed add-on with this one. _("A version of this add-on is already installed. Would you like to update {summary} version {curVersion} to version {newVersion}?").format( summary=summary, curVersion=curVersion, newVersion=newVersion ), # Translators: A title for the dialog asking if the user wishes to update a previously installed add-on with this one. _("Add-on Installation"), wx.YES|wx.NO|wx.ICON_WARNING)!=wx.YES: return prevAddon.requestRemove() progressDialog = gui.IndeterminateProgressDialog(gui.mainFrame, # Translators: The title of the dialog presented while an Addon is being installed. _("Installing Add-on"), # Translators: The message displayed while an addon is being installed. _("Please wait while the add-on is being installed.")) try: gui.ExecAndPump(addonHandler.installAddonBundle,bundle) except: log.error("Error installing addon bundle from %s"%addonPath,exc_info=True) self.refreshAddonsList() progressDialog.done() del progressDialog # Translators: The message displayed when an error occurs when installing an add-on package. gui.messageBox(_("Failed to install add-on from %s")%addonPath, # Translators: The title of a dialog presented when an error occurs. _("Error"), wx.OK | wx.ICON_ERROR) return else: self.refreshAddonsList(activeIndex=-1) progressDialog.done() del progressDialog finally: if closeAfter: # #4460: If we do this immediately, wx seems to drop the WM_QUIT sent if the user chooses to restart. # This seems to have something to do with the wx.ProgressDialog. # The CallLater seems to work around this. wx.CallLater(1, self.Close)
def __init__(self, parent, destPath, version, versionTuple): self.destPath = destPath self.version = version self.versionTuple = versionTuple self.storeUpdatesDirWritable = os.path.isdir(storeUpdatesDir) and os.access(storeUpdatesDir, os.W_OK) # Translators: The title of the dialog asking the user to Install an NVDA update. wx.Dialog.__init__(self, parent, title=_("NVDA Update")) DpiScalingHelperMixin.__init__(self, self.GetHandle()) mainSizer = wx.BoxSizer(wx.VERTICAL) sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL) # Translators: A message indicating that an updated version of NVDA is ready to be installed. message = _("NVDA version {version} is ready to be installed.\n").format(version=version) addonsWithoutKnownCompat = list(getAddonsWithoutKnownCompatibility(versionTuple)) showAddonCompat = any(addonsWithoutKnownCompat) if showAddonCompat: # Translators: A message indicating that some add-ons will be disabled unless reviewed before installation. message = message + _( "\nHowever, your NVDA configuration contains add-ons that are not tested with this version of NVDA. " "These add-ons will be disabled after installation. " "If you rely on these add-ons, please review the list to manually enable them before installation." ) for a in addonsWithoutKnownCompat: # now that the use is warned about the compatibility and so that the user is # not prompted again after installation, we set the default compatibility AddonCompatibilityState.setAddonCompatibility( addon=a, NVDAVersion=versionTuple, compatibilityStateValue=compatValues.MANUALLY_SET_INCOMPATIBLE) text = sHelper.addItem(wx.StaticText(self, label=message)) text.Wrap(self.scaleSize(500)) if showAddonCompat: self.confirmationCheckbox = sHelper.addItem(wx.CheckBox( self, # Translators: A message to confirm that the user understands that addons that have not been reviewed and made # available, will be disabled after installation. label=_("I understand that these untested add-ons will be disabled") )) bHelper = sHelper.addDialogDismissButtons(guiHelper.ButtonHelper(wx.HORIZONTAL)) if showAddonCompat: # Translators: The label of a button to review add-ons prior to NVDA update. reviewAddonsButton = bHelper.addButton(self, label=_("&Review add-ons...")) reviewAddonsButton.Bind(wx.EVT_BUTTON, self.onReviewAddonsButton) reviewAddonsButton.SetFocus() # Translators: The label of a button to install an NVDA update. installButton = bHelper.addButton(self, wx.ID_OK, label=_("&Install update")) installButton.Bind(wx.EVT_BUTTON, self.onInstallButton) if not showAddonCompat: installButton.SetFocus() else: self.confirmationCheckbox.Bind( wx.EVT_CHECKBOX, lambda evt: installButton.Enable(not installButton.Enabled) ) installButton.Enable(False) if self.storeUpdatesDirWritable: # Translators: The label of a button to postpone an NVDA update. postponeButton = bHelper.addButton(self, wx.ID_CLOSE, label=_("&Postpone update")) postponeButton.Bind(wx.EVT_BUTTON, self.onPostponeButton) self.EscapeId = wx.ID_CLOSE else: self.EscapeId = wx.ID_OK mainSizer.Add(sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL) self.Sizer = mainSizer mainSizer.Fit(self) self.CentreOnScreen()
def test_getAddonCompatibility_noState_testedAndSupported_compatible(self): compatibleAddon = mockAddon() compat = AddonCompatibilityState.getAddonCompatibility(compatibleAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.AUTO_DEDUCED_COMPATIBLE)
def __init__(self, parent, updateInfo, auto): # Translators: The title of the dialog informing the user about an NVDA update. wx.Dialog.__init__(self, parent, title=_("NVDA Update")) DpiScalingHelperMixin.__init__(self, self.GetHandle()) self.updateInfo = updateInfo mainSizer = wx.BoxSizer(wx.VERTICAL) sHelper = guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL) pendingUpdateDetails = getPendingUpdate() canOfferPendingUpdate = isPendingUpdate( ) and pendingUpdateDetails[1] == updateInfo["version"] text = sHelper.addItem(wx.StaticText(self)) bHelper = guiHelper.ButtonHelper(wx.HORIZONTAL) if not updateInfo: # Translators: A message indicating that no update to NVDA is available. message = _("No update available.") elif canOfferPendingUpdate: # Translators: A message indicating that an updated version of NVDA has been downloaded # and is pending to be installed. message = _( "NVDA version {version} has been downloaded and is pending installation." ).format(**updateInfo) self.newNVDAVersionTuple = versionInfo.getNVDAVersionTupleFromString( updateInfo["version"]) addonsWithoutKnownCompat = list( getAddonsWithoutKnownCompatibility(self.newNVDAVersionTuple)) showAddonCompat = any(addonsWithoutKnownCompat) if showAddonCompat: # Translators: A message indicating that some add-ons will be disabled unless reviewed before installation. message = message + _( "\n\n" "However, your NVDA configuration contains add-ons that are not tested with this version of NVDA. " "These add-ons will be disabled after installation. " "If you rely on these add-ons, please review the list to manually enable them before installation." ) confirmationCheckbox = sHelper.addItem( wx.CheckBox( self, # Translators: A message to confirm that the user understands that addons that have not been reviewed and made # available, will be disabled after installation. label= _("I understand that these untested add-ons will be disabled" ))) confirmationCheckbox.Bind( wx.EVT_CHECKBOX, lambda evt: self.installPendingButton. Enable(not self.installPendingButton.Enabled)) # Translators: The label of a button to review add-ons prior to NVDA update. reviewAddonsButton = bHelper.addButton( self, label=_("&Review add-ons...")) reviewAddonsButton.Bind(wx.EVT_BUTTON, self.onReviewAddonsButton) reviewAddonsButton.SetFocus() for a in addonsWithoutKnownCompat: # now that the use is warned about the compatibility and so that the user is # not prompted again after installation, we set the default compatibility AddonCompatibilityState.setAddonCompatibility( addon=a, NVDAVersion=self.newNVDAVersionTuple, compatibilityStateValue=compatValues. MANUALLY_SET_INCOMPATIBLE) self.installPendingButton = bHelper.addButton( self, # Translators: The label of a button to install a pending NVDA update. # {version} will be replaced with the version; e.g. 2011.3. label=_("&Install NVDA {version}").format(**updateInfo)) self.installPendingButton.Bind( wx.EVT_BUTTON, lambda evt: self.onInstallButton(pendingUpdateDetails[0])) self.installPendingButton.Enable(not showAddonCompat) bHelper.addButton( self, # Translators: The label of a button to re-download a pending NVDA update. label=_("Re-&download update")).Bind(wx.EVT_BUTTON, self.onDownloadButton) else: # Translators: A message indicating that an updated version of NVDA is available. # {version} will be replaced with the version; e.g. 2011.3. message = _("NVDA version {version} is available.").format( **updateInfo) bHelper.addButton( self, # Translators: The label of a button to download an NVDA update. label=_("&Download update")).Bind(wx.EVT_BUTTON, self.onDownloadButton) if auto: # this prompt was triggered by auto update checker # the user might not want to wait for a download right now, so give the option to be reminded later. # Translators: The label of a button to remind the user later about performing some action. remindMeButton = bHelper.addButton(self, label=_("Remind me &later")) remindMeButton.Bind(wx.EVT_BUTTON, self.onLaterButton) remindMeButton.SetFocus() text.SetLabel(message) text.Wrap(self.scaleSize(500)) sHelper.addDialogDismissButtons(bHelper) # Translators: The label of a button to close a dialog. closeButton = bHelper.addButton(self, wx.ID_CLOSE, label=_("&Close")) closeButton.Bind(wx.EVT_BUTTON, lambda evt: self.Close()) self.Bind(wx.EVT_CLOSE, lambda evt: self.Destroy()) self.EscapeId = wx.ID_CLOSE mainSizer.Add(sHelper.sizer, border=guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL) self.Sizer = mainSizer mainSizer.Fit(self) self.CentreOnScreen() self.Show()
def test_getAddonCompatibility_stateUnknown_unknown(self): notTestedAddon = mockAddon(lastTestedNVDAVersion=LastNVDAVersionString) self.resetMockStateSaver(notTestedAddon, compatValues.UNKNOWN) compat = AddonCompatibilityState.getAddonCompatibility(notTestedAddon, CurrentNVDAVersionTuple) self.assertCompatValuesMatch(compat, compatValues.UNKNOWN)