示例#1
0
	def __init__(
			self,
			name="mockAddon",
			version="1.0",
			minNVDAVersion=LastNVDAVersionString,
			lastTestedNVDAVersion=CurrentNVDAVersionString
	):
		super(mockAddon, self).__init__()
		self._name = name
		self._version = version
		self._minNVDAVersion = None
		if minNVDAVersion:
			self._minNVDAVersion = versionInfo.getNVDAVersionTupleFromString(minNVDAVersion)
		self._lastTestedNVDAVersion = None
		if lastTestedNVDAVersion:
			self._lastTestedNVDAVersion = versionInfo.getNVDAVersionTupleFromString(lastTestedNVDAVersion)
示例#2
0
 def __init__(self,
              name="mockAddon",
              version="1.0",
              minNVDAVersion=LastNVDAVersionString,
              lastTestedNVDAVersion=CurrentNVDAVersionString):
     super(mockAddon, self).__init__()
     self._name = name
     self._version = version
     self._minNVDAVersion = None
     if minNVDAVersion:
         self._minNVDAVersion = versionInfo.getNVDAVersionTupleFromString(
             minNVDAVersion)
     self._lastTestedNVDAVersion = None
     if lastTestedNVDAVersion:
         self._lastTestedNVDAVersion = versionInfo.getNVDAVersionTupleFromString(
             lastTestedNVDAVersion)
示例#3
0
 def onReviewAddonsButton(self, evt):
     from gui import addonGui
     incompatibleAddons = addonGui.IncompatibleAddonsDialog(
         parent=self,
         NVDAVersion=versionInfo.getNVDAVersionTupleFromString(
             self.version))
     incompatibleAddons.ShowModal()
     incompatibleAddons.Destroy()
示例#4
0
 def _download(self, url):
     remote = urllib.urlopen(url)
     if remote.code != 200:
         raise RuntimeError("Download failed with code %d" % remote.code)
     # #2352: Some security scanners such as Eset NOD32 HTTP Scanner
     # cause huge read delays while downloading.
     # Therefore, set a higher timeout.
     remote.fp._sock.settimeout(120)
     size = int(remote.headers["content-length"])
     local = file(self.destPath, "wb")
     if self.fileHash:
         hasher = hashlib.sha1()
     self._guiExec(self._downloadReport, 0, size)
     read = 0
     chunk = DOWNLOAD_BLOCK_SIZE
     while True:
         if self._shouldCancel:
             return
         if size - read < chunk:
             chunk = size - read
         block = remote.read(chunk)
         if not block:
             break
         read += len(block)
         if self._shouldCancel:
             return
         local.write(block)
         if self.fileHash:
             hasher.update(block)
         self._guiExec(self._downloadReport, read, size)
     if read < size:
         raise RuntimeError("Content too short")
     if self.fileHash and hasher.hexdigest() != self.fileHash:
         raise RuntimeError("Content has incorrect file hash")
     # getFileVersionInfo will fail as long as the file is still open.
     local.close()
     fileVersionInfo = fileUtils.getFileVersionInfo(
         self.destPath.decode("mbcs"), "FileVersion")
     fileVersion = fileVersionInfo.get('FileVersion') or self.version
     self.versionTuple = versionInfo.getNVDAVersionTupleFromString(
         fileVersion)
     self._guiExec(self._downloadReport, read, size)
示例#5
0
	def _download(self, url):
		remote = urllib.urlopen(url)
		if remote.code != 200:
			raise RuntimeError("Download failed with code %d" % remote.code)
		# #2352: Some security scanners such as Eset NOD32 HTTP Scanner
		# cause huge read delays while downloading.
		# Therefore, set a higher timeout.
		remote.fp._sock.settimeout(120)
		size = int(remote.headers["content-length"])
		local = file(self.destPath, "wb")
		if self.fileHash:
			hasher = hashlib.sha1()
		self._guiExec(self._downloadReport, 0, size)
		read = 0
		chunk=DOWNLOAD_BLOCK_SIZE
		while True:
			if self._shouldCancel:
				return
			if size -read <chunk:
				chunk =size -read
			block = remote.read(chunk)
			if not block:
				break
			read += len(block)
			if self._shouldCancel:
				return
			local.write(block)
			if self.fileHash:
				hasher.update(block)
			self._guiExec(self._downloadReport, read, size)
		if read < size:
			raise RuntimeError("Content too short")
		if self.fileHash and hasher.hexdigest() != self.fileHash:
			raise RuntimeError("Content has incorrect file hash")
		# getFileVersionInfo will fail as long as the file is still open.
		local.close()
		fileVersionInfo = fileUtils.getFileVersionInfo(self.destPath.decode("mbcs"), "FileVersion")
		fileVersion = fileVersionInfo.get('FileVersion') or self.version
		self.versionTuple = versionInfo.getNVDAVersionTupleFromString(fileVersion)
		self._guiExec(self._downloadReport, read, size)
示例#6
0
	def lastTestedNVDAVersion(self):
		version = self.manifest.get('lastTestedNVDAVersion')
		if not version:
			return None
		return getNVDAVersionTupleFromString(version)
示例#7
0
	def minimumNVDAVersion(self):
		version = self.manifest.get('minimumNVDAVersion')
		if not version:
			return None
		return getNVDAVersionTupleFromString(version)
示例#8
0
    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()
示例#9
0
    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()