def error(self, message): """Shows an error in a standard Windows message dialog, and then exits NVDA""" out = "" out = self.format_usage() out += "\nerror: %s" % message winUser.MessageBox(0, out, u"Error", 0) sys.exit(2)
def doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,silent=False,startAfterInstall=True): progressDialog = gui.IndeterminateProgressDialog(gui.mainFrame, # Translators: The title of the dialog presented while NVDA is being updated. _("Updating NVDA") if isUpdate # Translators: The title of the dialog presented while NVDA is being installed. else _("Installing NVDA"), # Translators: The message displayed while NVDA is being updated. _("Please wait while your previous installation of NVDA is being updated.") if isUpdate # Translators: The message displayed while NVDA is being installed. else _("Please wait while NVDA is being installed")) try: res=config.execElevated(config.SLAVE_FILENAME,["install",str(int(createDesktopShortcut)),str(int(startOnLogon))],wait=True,handleAlreadyElevated=True) if res==2: raise installer.RetriableFailure if copyPortableConfig: installedUserConfigPath=config.getInstalledUserConfigPath() if installedUserConfigPath: gui.ExecAndPump(installer.copyUserConfig,installedUserConfigPath) except Exception as e: res=e log.error("Failed to execute installer",exc_info=True) progressDialog.done() del progressDialog if isinstance(res,installer.RetriableFailure): # Translators: a message dialog asking to retry or cancel when NVDA install fails message=_("The installation is unable to remove or overwrite a file. Another copy of NVDA may be running on another logged-on user account. Please make sure all installed copies of NVDA are shut down and try the installation again.") # Translators: the title of a retry cancel dialog when NVDA installation fails title=_("File in Use") if winUser.MessageBox(None,message,title,winUser.MB_RETRYCANCEL)==winUser.IDRETRY: return doInstall(createDesktopShortcut,startOnLogon,copyPortableConfig,isUpdate,silent,startAfterInstall) if res!=0: log.error("Installation failed: %s"%res) # Translators: The message displayed when an error occurs during installation of NVDA. gui.messageBox(_("The installation of NVDA failed. Please check the Log Viewer for more information."), # Translators: The title of a dialog presented when an error occurs. _("Error"), wx.OK | wx.ICON_ERROR) return if not silent: msg = ( # Translators: The message displayed when NVDA has been successfully installed. _("Successfully installed NVDA. ") if not isUpdate # Translators: The message displayed when NVDA has been successfully updated. else _("Successfully updated your installation of NVDA. ")) # Translators: The message displayed to the user after NVDA is installed # and the installed copy is about to be started. gui.messageBox(msg+_("Please press OK to start the installed copy."), # Translators: The title of a dialog presented to indicate a successful operation. _("Success")) if startAfterInstall: # #4475: ensure that the first window of the new process is not hidden by providing SW_SHOWNORMAL shellapi.ShellExecute( None, None, os.path.join(installer.defaultInstallPath,'nvda.exe'), None, None, winUser.SW_SHOWNORMAL ) else: wx.GetApp().ExitMainLoop()
def doCreatePortable(portableDirectory,copyUserConfig=False): d = gui.IndeterminateProgressDialog(gui.mainFrame, # Translators: The title of the dialog presented while a portable copy of NVDA is bieng created. _("Creating Portable Copy"), # Translators: The message displayed while a portable copy of NVDA is bieng created. _("Please wait while a portable copy of NVDA is created.")) try: gui.ExecAndPump(installer.createPortableCopy,portableDirectory,copyUserConfig) except Exception as e: log.error("Failed to create portable copy",exc_info=True) d.done() if isinstance(e,installer.RetriableFailure): # Translators: a message dialog asking to retry or cancel when NVDA portable copy creation fails message=_("NVDA is unable to remove or overwrite a file.") # Translators: the title of a retry cancel dialog when NVDA portable copy creation fails title=_("File in Use") if winUser.MessageBox(None,message,title,winUser.MB_RETRYCANCEL)==winUser.IDRETRY: return doCreatePortable(portableDirectory,copyUserConfig) # Translators: The message displayed when an error occurs while creating a portable copy of NVDA. # %s will be replaced with the specific error message. gui.messageBox(_("Failed to create portable copy: %s")%e, _("Error"), wx.OK | wx.ICON_ERROR) return d.done() # Translators: The message displayed when a portable copy of NVDA has been successfully created. # %s will be replaced with the destination directory. gui.messageBox(_("Successfully created a portable copy of NVDA at %s")%portableDirectory, _("Success"))
def doCreatePortable(portableDirectory, copyUserConfig=False, silent=False, startAfterCreate=False): d = gui.IndeterminateProgressDialog( gui.mainFrame, # Translators: The title of the dialog presented while a portable copy of NVDA is bieng created. _("Creating Portable Copy"), # Translators: The message displayed while a portable copy of NVDA is bieng created. _("Please wait while a portable copy of NVDA is created.")) try: gui.ExecAndPump(installer.createPortableCopy, portableDirectory, copyUserConfig) except Exception as e: log.error("Failed to create portable copy", exc_info=True) d.done() if isinstance(e, installer.RetriableFailure): # Translators: a message dialog asking to retry or cancel when NVDA portable copy creation fails message = _("NVDA is unable to remove or overwrite a file.") # Translators: the title of a retry cancel dialog when NVDA portable copy creation fails title = _("File in Use") if winUser.MessageBox(None, message, title, winUser.MB_RETRYCANCEL) == winUser.IDRETRY: return doCreatePortable(portableDirectory, copyUserConfig, silent, startAfterCreate) # Translators: The message displayed when an error occurs while creating a portable copy of NVDA. # %s will be replaced with the specific error message. gui.messageBox( _("Failed to create portable copy: %s") % e, _("Error"), wx.OK | wx.ICON_ERROR) return d.done() if silent: wx.GetApp().ExitMainLoop() else: # Translators: The message displayed when a portable copy of NVDA has been successfully created. # %s will be replaced with the destination directory. gui.messageBox( _("Successfully created a portable copy of NVDA at %s") % portableDirectory, _("Success")) if startAfterCreate: # #4475: ensure that the first window of the new process is not hidden by providing SW_SHOWNORMAL shellapi.ShellExecute( None, None, os.path.join(os.path.abspath(portableDirectory), 'nvda.exe'), u"-r", None, winUser.SW_SHOWNORMAL)
def _onSetLocalClick(self, evt): # Translators: The message displayed when the current source path is relative. if not path.isabs(self._ttsPath.GetValue()): # Translators: The message displayed when the current source path is relative. gui.messageBox(_("Relative paths are not allowed."), _("Error"), wx.OK|wx.ICON_ERROR, self) return # Translators: A message to ask the user to copy IBMTTS files to Add-on folder. if gui.messageBox(_("Are you sure to copy IBMTTS files to local NVDA driver Add-on? It may not work in some IBMTTS distributions."), # Translators: The title of the Asking dialog displayed when trying to copy IBMTTS files. _("Copy IBMTTS files"), wx.YES|wx.NO|wx.ICON_QUESTION, self) == wx.YES: progressDialog = gui.IndeterminateProgressDialog(gui.mainFrame, # Translators: The title of the dialog presented while IBMTTS files are being copied. _("Copying files"), # Translators: The message displayed while IBMTTS files are being copied. _("Please wait while IBMTTS files are copied into add-on.")) while True: try: gui.ExecAndPump(self.copyTtsFiles) res = True break except Exception: # Translators: a message dialog asking to retry or cancel when copying IBMTTS files. message=_("Unable to copy a file. Perhaps it is currently being used by another process or you have run out of disc space on the drive you are copying to.") # Translators: the title of a retry cancel dialog when copying IBMTTS files. title=_("Error Copying") if winUser.MessageBox(None,message,title,winUser.MB_RETRYCANCEL) != winUser.IDRETRY: res=False log.debugWarning("Error when copying IBMTTS files into Add-on",exc_info=True) break progressDialog.done() del progressDialog if res: self._ttsPath.SetValue("ibmtts") # this parameter is saved even if the user doesn't click accept button. config.conf['ibmeci']['TTSPath'] = self._ttsPath.GetValue() # Translators: The message displayed when copying IBMTTS files to Add-on was successful. gui.messageBox(_("Successfully copied IBMTTS files. The local copy will be used after restart NVDA."), # Translators: The title displayed when copying IBMTTS files to Add-on was successful. _("Success"),wx.OK|wx.ICON_INFORMATION,self) else: # Translators: The message displayed when errors were found while trying to copy IBMTTS files to Add-on. gui.messageBox(_("Error copying IBMTTS files"), _("Error"), wx.OK|wx.ICON_ERROR, self)
def print_help(self, file=None): """Shows help in a standard Windows message dialog""" winUser.MessageBox(0, self.format_help(), u"Help", 0)
def error(self, message): """Shows an error in a standard Windows message dialog, and then exits NVDA""" out = "" out = self.format_usage() out += "\nerror: %s" % message winUser.MessageBox(0, out, u"Error", 0) sys.exit(2) globalVars.startTime = time.time() # Check OS version requirements import winVersion if not winVersion.isSupportedOS(): winUser.MessageBox(0, ctypes.FormatError(winUser.ERROR_OLD_WIN_VERSION), None, winUser.MB_ICONERROR) sys.exit(1) def stringToBool(string): """Wrapper for configobj.validate.is_boolean to raise the proper exception for wrong values.""" from configobj.validate import is_boolean, ValidateError try: return is_boolean(string) except ValidateError as e: raise argparse.ArgumentTypeError(e.message) #Process option arguments parser = NoConsoleOptionParser() quitGroup = parser.add_mutually_exclusive_group()