def setup(): log.debug("Starting " + application.name + " %s" % (application.version, )) config.setup() fixes.setup() log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Application path is %s" % (paths.app_path(), )) log.debug("config path is %s" % (paths.config_path(), )) sound.setup() output.setup() languageHandler.setLanguage(config.app["app-settings"]["language"]) keys.setup() from controller import mainController from sessionmanager import sessionManager app = widgetUtils.mainLoopObject() if system == "Windows": if config.app["app-settings"]["donation_dialog_displayed"] == False: donation() updater.do_update() sm = sessionManager.sessionManagerController() sm.fill_list() if len(sm.sessions) == 0: sm.show() else: sm.do_ok() if hasattr(sm.view, "destroy"): sm.view.destroy() del sm r = mainController.Controller() r.view.show() r.do_work() r.check_invisible_at_startup() if system == "Windows": call_threaded(r.start) elif system == "Linux": GLib.idle_add(r.start) app.run()
def generate_document(language): reload(languageHandler) languageHandler.setLanguage(language) reload(strings) markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"]) first_html_block = """<!doctype html> <html lang="%s"> <head> <title>%s</title> <meta charset="utf-8"> </head> <body> <header><h1>%s</h1></header> """ % ( language, strings.documentation[0], strings.documentation[0], ) first_html_block = first_html_block + markdown_file first_html_block = first_html_block + "\n</body>\n</html>" if not os.path.exists(language): os.mkdir(language) mdfile = _open("%s/manual.html" % language, "w", encoding="utf-8") mdfile.write(first_html_block) mdfile.close()
def save_configuration(self): if self.codes[self.dialog.general.language.GetSelection()] != config.app["app-settings"]["language"]: config.app["app-settings"]["language"] = self.codes[self.dialog.general.language.GetSelection()] languageHandler.setLanguage(config.app["app-settings"]["language"]) self.needs_restart = True if self.kmnames[self.dialog.general.km.GetSelection()] != config.app["app-settings"]["load_keymap"]: config.app["app-settings"]["load_keymap"] =self.kmnames[self.dialog.general.km.GetSelection()] kmFile = open(paths.config_path("keymap.keymap"), "w") kmFile.close() self.needs_restart = True if config.app["app-settings"]["use_invisible_keyboard_shorcuts"] != self.dialog.get_value("general", "use_invisible_shorcuts"): config.app["app-settings"]["use_invisible_keyboard_shorcuts"] = self.dialog.get_value("general", "use_invisible_shorcuts") pub.sendMessage("invisible-shorcuts-changed", registered=self.dialog.get_value("general", "use_invisible_shorcuts")) config.app["app-settings"]["voice_enabled"] = self.dialog.get_value("general", "disable_sapi5") config.app["app-settings"]["hide_gui"] = self.dialog.get_value("general", "hide_gui") config.app["app-settings"]["ask_at_exit"] = self.dialog.get_value("general", "ask_at_exit") config.app["app-settings"]["handle_longtweets"] = self.dialog.get_value("general", "handle_longtweets") config.app["app-settings"]["play_ready_sound"] = self.dialog.get_value("general", "play_ready_sound") config.app["app-settings"]["speak_ready_msg"] = self.dialog.get_value("general", "speak_ready_msg") if config.app["proxy"]["server"] != self.dialog.get_value("proxy", "server") or config.app["proxy"]["port"] != self.dialog.get_value("proxy", "port") or config.app["proxy"]["user"] != self.dialog.get_value("proxy", "user") or config.app["proxy"]["password"] != self.dialog.get_value("proxy", "password"): if self.is_started == True: self.needs_restart = True config.app["proxy"]["server"] = self.dialog.get_value("proxy", "server") config.app["proxy"]["port"] = self.dialog.get_value("proxy", "port") config.app["proxy"]["user"] = self.dialog.get_value("proxy", "user") config.app["proxy"]["password"] = self.dialog.get_value("proxy", "password") config.app.write()
def test_NVDASupportedLanguages_LanguageIsSetCorrectly(self): """ Tests languageHandler.setLanguage, using all NVDA supported languages, which should do the following: - set the translation service and languageHandler.curLang - set the windows locale for the thread (fallback to system default) - set the python locale for the thread (match the translation service, fallback to system default) """ for localeName in TRANSLATABLE_LANGS: with self.subTest(localeName=localeName): langOnly = localeName.split("_")[0] languageHandler.setLanguage(localeName) # check curLang/translation service is set self.assertEqual(languageHandler.curLang, localeName) # check Windows thread is set threadLocale = ctypes.windll.kernel32.GetThreadLocale() threadLocaleName = languageHandler.windowsLCIDToLocaleName( threadLocale) threadLocaleLang = threadLocaleName.split("_")[0] if localeName in UNSUPPORTED_WIN_LANGUAGES: # our translatable locale isn't supported by windows # check that the system locale is unchanged self.assertEqual(self._defaultThreadLocaleName, threadLocaleName) else: # check that the language codes are correctly set for the thread self.assertEqual( langOnly, threadLocaleLang, f"full values: {localeName} {threadLocaleName}", ) # check that the python locale is set python_locale = locale.setlocale(locale.LC_ALL) if localeName in UNSUPPORTED_WIN_LANGUAGES: # our translatable locale isn't supported by python # check that the system locale is unchanged self.assertEqual(self._defaultPythonLocale, python_locale) else: # check that the language codes are correctly set for python # They can be set to the exact locale that was requested, to the locale gotten # from the language name if language_country cannot be set # or just to English name of the language. lang_country = languageHandler.localeStringFromLocaleCode( localeName) possibleVariants = {lang_country} if "65001" in lang_country: # Python normalizes Unicode Windows code page to 'utf8' possibleVariants.add( lang_country.replace("65001", "utf8")) if "_" in lang_country: possibleVariants.add( languageHandler.localeStringFromLocaleCode( localeName.split("_")[0])) possibleVariants.add( languageHandler.englishLanguageNameFromNVDALocale( localeName)) self.assertIn( locale.setlocale(locale.LC_ALL), possibleVariants, f"full values: {localeName} {python_locale}")
def resetConfiguration(factoryDefaults=False): """Loads the configuration, installs the correct language support and initialises audio so that it will use the configured synth and speech settings. """ import config import braille import speech import languageHandler import inputCore log.debug("Terminating braille") braille.terminate() log.debug("terminating speech") speech.terminate() log.debug("terminating addonHandler") addonHandler.terminate() log.debug("Reloading config") config.load(factoryDefaults=factoryDefaults) logHandler.setLogLevelFromConfig() #Language lang = config.conf["general"]["language"] log.debug("setting language to %s"%lang) languageHandler.setLanguage(lang) # Addons addonHandler.initialize() #Speech log.debug("initializing speech") speech.initialize() #braille log.debug("Initializing braille") braille.initialize() log.debug("Reloading user and locale input gesture maps") inputCore.manager.loadUserGestureMap() inputCore.manager.loadLocaleGestureMap() log.info("Reverted to saved configuration")
def save_configuration(self): if self.codes[self.dialog.general.language.GetSelection( )] != config.app["app-settings"]["language"]: config.app["app-settings"]["language"] = self.codes[ self.dialog.general.language.GetSelection()] languageHandler.setLanguage(config.app["app-settings"]["language"]) self.needs_restart = True if self.kmnames[self.dialog.general.km.GetSelection( )] != config.app["app-settings"]["load_keymap"]: config.app["app-settings"]["load_keymap"] = self.kmnames[ self.dialog.general.km.GetSelection()] kmFile = open(paths.config_path("keymap.keymap"), "w") kmFile.close() self.needs_restart = True if config.app["app-settings"][ "use_invisible_keyboard_shorcuts"] != self.dialog.get_value( "general", "use_invisible_shorcuts"): config.app["app-settings"][ "use_invisible_keyboard_shorcuts"] = self.dialog.get_value( "general", "use_invisible_shorcuts") pub.sendMessage("invisible-shorcuts-changed", registered=self.dialog.get_value( "general", "use_invisible_shorcuts")) config.app["app-settings"]["voice_enabled"] = self.dialog.get_value( "general", "disable_sapi5") config.app["app-settings"]["hide_gui"] = self.dialog.get_value( "general", "hide_gui") config.app["app-settings"]["ask_at_exit"] = self.dialog.get_value( "general", "ask_at_exit") config.app["app-settings"][ "handle_longtweets"] = self.dialog.get_value( "general", "handle_longtweets") config.app["app-settings"]["play_ready_sound"] = self.dialog.get_value( "general", "play_ready_sound") config.app["app-settings"]["speak_ready_msg"] = self.dialog.get_value( "general", "speak_ready_msg") if config.app["proxy"]["server"] != self.dialog.get_value( "proxy", "server" ) or config.app["proxy"]["port"] != self.dialog.get_value( "proxy", "port" ) or config.app["proxy"]["user"] != self.dialog.get_value( "proxy", "user" ) or config.app["proxy"]["password"] != self.dialog.get_value( "proxy", "password"): if self.is_started == True: self.needs_restart = True config.app["proxy"]["server"] = self.dialog.get_value( "proxy", "server") config.app["proxy"]["port"] = self.dialog.get_value( "proxy", "port") config.app["proxy"]["user"] = self.dialog.get_value( "proxy", "user") config.app["proxy"]["password"] = self.dialog.get_value( "proxy", "password") config.app.write()
def __init__(self, *args, **kwargs): self._prevLang = languageHandler.getLanguage() ctypes.windll.kernel32.SetThreadLocale(0) defaultThreadLocale = ctypes.windll.kernel32.GetThreadLocale() self._defaultThreadLocaleName = languageHandler.windowsLCIDToLocaleName( defaultThreadLocale) locale.setlocale(locale.LC_ALL, "") self._defaultPythonLocale = locale.setlocale(locale.LC_ALL) languageHandler.setLanguage(self._prevLang) super().__init__(*args, **kwargs)
def ok(self, ev): if self.list.get_count() == 0: wx.MessageDialog(None, _(u"You need to configure an account."), _(u"Account Error"), wx.ICON_ERROR).ShowModal() return current_session = self.sessions[self.list.get_selected()] manager.manager.set_current_session(current_session) config.MAINFILE = "%s/session.conf" % (manager.manager.get_current_session()) config.setup() lang=config.main['general']['language'] languageHandler.setLanguage(lang) sound.setup() output.setup() self.EndModal(wx.ID_OK)
def ok(self, ev): if self.list.get_count() == 0: wx.MessageDialog(None, _(u"You need to configure an account."), _(u"Account Error"), wx.ICON_ERROR).ShowModal() return current_session = self.sessions[self.list.get_selected()] manager.manager.set_current_session(current_session) config.MAINFILE = "%s/session.conf" % ( manager.manager.get_current_session()) config.setup() lang = config.main['general']['language'] languageHandler.setLanguage(lang) sound.setup() output.setup() self.EndModal(wx.ID_OK)
def setup(): log.debug("Starting " + application.name + " %s" % (application.version,)) config.setup() log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Application path is %s" % (paths.app_path(),)) log.debug("config path is %s" % (paths.config_path(),)) sound.setup() output.setup() languageHandler.setLanguage(config.app["app-settings"]["language"]) message(message=_(u"Loading files and configuration, please wait...")) fixes.setup() keys.setup() from controller import mainController from sessionmanager import sessionManager app = widgetUtils.mainLoopObject() gplwarning() if system == "Windows": if config.app["app-settings"]["donation_dialog_displayed"] == False: donation() if config.app["app-settings"]["check_updates"] == True: updater.do_update() else: message(message=_(u"Set to ignore updates at startup. To change this preference, go to global config")) sm = sessionManager.sessionManagerController() sm.fill_list() if len(sm.sessions) == 0: sm.show() else: sm.do_ok() if hasattr(sm.view, "destroy"): sm.view.destroy() del sm r = mainController.Controller() r.view.show() r.do_work() r.check_invisible_at_startup() if system == "Windows": call_threaded(r.start) elif system == "Linux": GLib.idle_add(r.start) message( message=_(u"Welcome to %s. Main application's window will appears shortly. Happy tweeting!") % application.name ) app.run()
def setup(): log.debug("Starting Socializer %s" % (application.version,)) config.setup() log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Application path is %s" % (paths.app_path(),)) log.debug("config path is %s" % (paths.config_path(),)) output.setup() languageHandler.setLanguage(config.app["app-settings"]["language"]) log.debug("Language set to %s" % (languageHandler.getLanguage())) keys.setup() from controller import mainController from sessionmanager import sessionManager app = widgetUtils.mainLoopObject() log.debug("Created Application mainloop object") sm = sessionManager.sessionManagerController() del sm r = mainController.Controller() call_threaded(r.login) app.run()
def onSave(self, ev): need_restart = False # Check general settings if config.main["general"]["language"] != self.general.langs[self.general.language.GetSelection()][0]: if self.general.langs[self.general.language.GetSelection()][0] in self.general.codes: config.main["general"]["language"] = self.general.langs[self.general.language.GetSelection()][0] languageHandler.setLanguage(config.main["general"]["language"]) need_restart = True if platform.system() == "Windows": config.main["general"]["voice_enabled"] = self.general.disable_sapi5.GetValue() config.main["general"]["ask_at_exit"] = self.general.ask_at_exit.GetValue() if (self.general.use_invisible_shorcuts.GetValue() == True and config.main["general"]["use_invisible_keyboard_shorcuts"] != True) and self.parent.showing == True: km = self.parent.create_invisible_keyboard_shorcuts() self.parent.register_invisible_keyboard_shorcuts(km) elif (self.general.use_invisible_shorcuts.GetValue() == False and config.main["general"]["use_invisible_keyboard_shorcuts"] != False) and self.parent.showing == True: km = self.parent.create_invisible_keyboard_shorcuts() self.parent.unregister_invisible_keyboard_shorcuts(km) config.main["general"]["use_invisible_keyboard_shorcuts"] = self.general.use_invisible_shorcuts.GetValue() config.main["general"]["hide_gui"] = self.general.show_gui.GetValue() config.main["general"]["max_api_calls"] = self.general.apiCalls.GetValue() config.main["general"]["max_tweets_per_call"] = self.general.itemsPerApiCall.GetValue() if config.main["general"]["relative_times"] != self.general.relative_time.GetValue(): config.main["general"]["relative_times"] = self.general.relative_time.GetValue() need_restart = True if config.main["general"]["reverse_timelines"] != self.general.reverse_timelines.GetValue(): config.main["general"]["reverse_timelines"] = self.general.reverse_timelines.GetValue() need_restart = True ## Check buffers settings config.main["other_buffers"]["show_followers"] = self.buffers.followers.GetValue() self.check_followers_change() config.main["other_buffers"]["show_friends"] = self.buffers.friends.GetValue() self.check_friends_change() config.main["other_buffers"]["show_favourites"] = self.buffers.favs.GetValue() self.check_favs_change() config.main["other_buffers"]["show_events"] = self.buffers.events.GetValue() self.check_events_change() config.main["other_buffers"]["show_blocks"] = self.buffers.blocks.GetValue() self.check_blocks_change() config.main["other_buffers"]["show_muted_users"] = self.buffers.mutes.GetValue() self.check_mutes_change() ## Check sound settings config.main["sound"]["volume"] = self.sound.volumeCtrl.GetValue()/100.0 config.main["sound"]["global_mute"] = self.sound.global_mute.GetValue() if system == "Windows": config.main["sound"]["output_device"] = self.sound.output.GetStringSelection() config.main["sound"]["input_device"] = self.sound.input.GetValue() try: snd.player.input.set_device(snd.player.input.find_device_by_name(config.main["sound"]["input_device"])) snd.player.output.set_device(snd.player.output.find_device_by_name(config.main["sound"]["output_device"])) except: config.main["sound"]["output_device"] = "Default" config.main["sound"]["input_device"] = "Default" config.main["sound"]["sndup_api_key"] = self.services.apiKey.GetValue() config.main["sound"]["current_soundpack"] = self.sound.soundpack.GetStringSelection() snd.player.check_soundpack() if need_restart == True: config.main.write() wx.MessageDialog(None, _(u"The application requires to be restarted to save these changes. Press OK to do it now."), _("Restart TW Blue"), wx.OK).ShowModal() restart.restart_program() config.main.write() self.EndModal(wx.ID_OK)
def main(): """NVDA's core main loop. This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. Then it initialises the wx application object and sets up the core pump, which checks the queues and executes functions when requested. Finally, it starts the wx main loop. """ log.debug("Core starting") try: # Windows >= Vista ctypes.windll.user32.SetProcessDPIAware() except AttributeError: pass import config if not globalVars.appArgs.configPath: globalVars.appArgs.configPath=config.getUserDefaultConfigPath(useInstalledPathIfExists=globalVars.appArgs.launcher) #Initialize the config path (make sure it exists) config.initConfigPath() log.info("Config dir: %s"%os.path.abspath(globalVars.appArgs.configPath)) log.debug("loading config") import config config.initialize() if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]: try: nvwave.playWaveFile("waves\\start.wav") except: pass logHandler.setLogLevelFromConfig() try: lang = config.conf["general"]["language"] import languageHandler log.debug("setting language to %s"%lang) languageHandler.setLanguage(lang) except: log.warning("Could not set language to %s"%lang) import versionInfo log.info("NVDA version %s" % versionInfo.version) log.info("Using Windows version %s" % winVersion.winVersionText) log.info("Using Python version %s"%sys.version) log.info("Using comtypes version %s"%comtypes.__version__) # Set a reasonable timeout for any socket connections NVDA makes. import socket socket.setdefaulttimeout(10) log.debug("Initializing add-ons system") addonHandler.initialize() if globalVars.appArgs.disableAddons: log.info("Add-ons are disabled. Restart NVDA to enable them.") import appModuleHandler log.debug("Initializing appModule Handler") appModuleHandler.initialize() import NVDAHelper log.debug("Initializing NVDAHelper") NVDAHelper.initialize() import speechDictHandler log.debug("Speech Dictionary processing") speechDictHandler.initialize() import speech log.debug("Initializing speech") speech.initialize() if not globalVars.appArgs.minimal and (time.time()-globalVars.startTime)>5: log.debugWarning("Slow starting core (%.2f sec)" % (time.time()-globalVars.startTime)) # Translators: This is spoken when NVDA is starting. speech.speakMessage(_("Loading NVDA. Please wait...")) import wx log.info("Using wx version %s"%wx.version()) class App(wx.App): def OnAssert(self,file,line,cond,msg): message="{file}, line {line}:\nassert {cond}: {msg}".format(file=file,line=line,cond=cond,msg=msg) log.debugWarning(message,codepath="WX Widgets",stack_info=True) app = App(redirect=False) # We do support QueryEndSession events, but we don't want to do anything for them. app.Bind(wx.EVT_QUERY_END_SESSION, lambda evt: None) def onEndSession(evt): # NVDA will be terminated as soon as this function returns, so save configuration if appropriate. config.saveOnExit() speech.cancelSpeech() if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]: try: nvwave.playWaveFile("waves\\exit.wav",async=False) except: pass log.info("Windows session ending") app.Bind(wx.EVT_END_SESSION, onEndSession) import braille log.debug("Initializing braille") braille.initialize() log.debug("Initializing braille input") import brailleInput brailleInput.initialize() import displayModel log.debug("Initializing displayModel") displayModel.initialize() log.debug("Initializing GUI") import gui gui.initialize() import audioDucking if audioDucking.isAudioDuckingSupported(): # the GUI mainloop must be running for this to work so delay it wx.CallAfter(audioDucking.initialize) # #3763: In wxPython 3, the class name of frame windows changed from wxWindowClassNR to wxWindowNR. # NVDA uses the main frame to check for and quit another instance of NVDA. # To remain compatible with older versions of NVDA, create our own wxWindowClassNR. # We don't need to do anything else because wx handles WM_QUIT for all windows. import windowUtils class MessageWindow(windowUtils.CustomWindow): className = u"wxWindowClassNR" messageWindow = MessageWindow(unicode(versionInfo.name)) # initialize wxpython localization support locale = wx.Locale() lang=languageHandler.getLanguage() wxLang=locale.FindLanguageInfo(lang) if not wxLang and '_' in lang: wxLang=locale.FindLanguageInfo(lang.split('_')[0]) if hasattr(sys,'frozen'): locale.AddCatalogLookupPathPrefix(os.path.join(os.getcwdu(),"locale")) if wxLang: try: locale.Init(wxLang.Language) except: log.error("Failed to initialize wx locale",exc_info=True) else: log.debugWarning("wx does not support language %s" % lang) import api import winUser import NVDAObjects.window desktopObject=NVDAObjects.window.Window(windowHandle=winUser.getDesktopWindow()) api.setDesktopObject(desktopObject) api.setFocusObject(desktopObject) api.setNavigatorObject(desktopObject) api.setMouseObject(desktopObject) import JABHandler log.debug("initializing Java Access Bridge support") try: JABHandler.initialize() except NotImplementedError: log.warning("Java Access Bridge not available") except: log.error("Error initializing Java Access Bridge support", exc_info=True) import winConsoleHandler log.debug("Initializing winConsole support") winConsoleHandler.initialize() import UIAHandler log.debug("Initializing UIA support") try: UIAHandler.initialize() except NotImplementedError: log.warning("UIA not available") except: log.error("Error initializing UIA support", exc_info=True) import IAccessibleHandler log.debug("Initializing IAccessible support") IAccessibleHandler.initialize() log.debug("Initializing input core") import inputCore inputCore.initialize() import keyboardHandler log.debug("Initializing keyboard handler") keyboardHandler.initialize() import mouseHandler log.debug("initializing mouse handler") mouseHandler.initialize() import touchHandler log.debug("Initializing touchHandler") try: touchHandler.initialize() except NotImplementedError: pass import globalPluginHandler log.debug("Initializing global plugin handler") globalPluginHandler.initialize() if globalVars.appArgs.install or globalVars.appArgs.installSilent: import wx import gui.installerGui wx.CallAfter(gui.installerGui.doSilentInstall,startAfterInstall=not globalVars.appArgs.installSilent) elif not globalVars.appArgs.minimal: try: # Translators: This is shown on a braille display (if one is connected) when NVDA starts. braille.handler.message(_("NVDA started")) except: log.error("", exc_info=True) if globalVars.appArgs.launcher: gui.LauncherDialog.run() # LauncherDialog will call doStartupDialogs() afterwards if required. else: wx.CallAfter(doStartupDialogs) import queueHandler # Queue the handling of initial focus, # as API handlers might need to be pumped to get the first focus event. queueHandler.queueFunction(queueHandler.eventQueue, _setInitialFocus) import watchdog import baseObject # Doing this here is a bit ugly, but we don't want these modules imported # at module level, including wx. log.debug("Initializing core pump") class CorePump(wx.Timer): "Checks the queues and executes functions." def Notify(self): global _isPumpPending _isPumpPending = False watchdog.alive() try: if touchHandler.handler: touchHandler.handler.pump() JABHandler.pumpAll() IAccessibleHandler.pumpAll() queueHandler.pumpAll() mouseHandler.pumpAll() braille.pumpAll() except: log.exception("errors in this core pump cycle") baseObject.AutoPropertyObject.invalidateCaches() watchdog.asleep() if _isPumpPending and not _pump.IsRunning(): # #3803: A pump was requested, but the timer was ignored by a modal loop # because timers aren't re-entrant. # Therefore, schedule another pump. _pump.Start(PUMP_MAX_DELAY, True) global _pump _pump = CorePump() requestPump() log.debug("Initializing watchdog") watchdog.initialize() try: import updateCheck except RuntimeError: updateCheck=None log.debug("Update checking not supported") else: log.debug("initializing updateCheck") updateCheck.initialize() log.info("NVDA initialized") log.debug("entering wx application main loop") app.MainLoop() log.info("Exiting") if updateCheck: _terminate(updateCheck) _terminate(watchdog) _terminate(globalPluginHandler, name="global plugin handler") _terminate(gui) config.saveOnExit() try: if globalVars.focusObject and hasattr(globalVars.focusObject,"event_loseFocus"): log.debug("calling lose focus on object with focus") globalVars.focusObject.event_loseFocus() except: log.exception("Lose focus error") try: speech.cancelSpeech() except: pass import treeInterceptorHandler _terminate(treeInterceptorHandler) _terminate(IAccessibleHandler, name="IAccessible support") _terminate(UIAHandler, name="UIA support") _terminate(winConsoleHandler, name="winConsole support") _terminate(JABHandler, name="Java Access Bridge support") _terminate(appModuleHandler, name="app module handler") _terminate(NVDAHelper) _terminate(touchHandler) _terminate(keyboardHandler, name="keyboard handler") _terminate(mouseHandler) _terminate(inputCore) _terminate(brailleInput) _terminate(braille) _terminate(speech) _terminate(addonHandler) if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]: try: nvwave.playWaveFile("waves\\exit.wav",async=False) except: pass # #5189: Destroy the message window as late as possible # so new instances of NVDA can find this one even if it freezes during exit. messageWindow.destroy() log.debug("core done")
# -*- coding: utf-8 -*- import utils import re import htmlentitydefs import output import paths import config, languageHandler, locale if config.main == None: languageHandler.setLanguage("system") import platform system = platform.system() import logging as original_logger log = original_logger.getLogger("events") import time import arrow def StripChars(s): """Converts any html entities in s to their unicode-decoded equivalents and returns a string.""" entity_re = re.compile(r"&(#\d+|\w+);") def matchFunc(match): """Nested function to handle a match object. If we match &blah; and it's not found, &blah; will be returned. if we match #\d+, unichr(digits) will be returned. Else, a unicode string will be returned.""" if match.group(1).startswith('#'): return unichr(int(match.group(1)[1:])) replacement = htmlentitydefs.entitydefs.get(match.group(1), "&%s;" % match.group(1)) return replacement.decode('iso-8859-1') return unicode(entity_re.sub(matchFunc, s)) chars = "abcdefghijklmnopqrstuvwxyz"
# -*- coding: utf-8 -*- import markdown import os from codecs import open as _open import languageHandler languageHandler.setLanguage("en") import strings # the list of supported language codes of TW Blue languages = ["en", "es", "fr", "de", "it", "gl", "ja"] # "eu", "ar", "ca", "es", "fi", "fr", "gl", "hu", "it", "pl", "pt", "ru", "tr"] def generate_document(language): reload(languageHandler) languageHandler.setLanguage(language) reload(strings) markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"]) first_html_block = """<!doctype html> <html lang="%s"> <head> <title>%s</title> <meta charset="utf-8"> </head> <body> <header><h1>%s</h1></header> """ % ( language, strings.documentation[0], strings.documentation[0],
def _handleResponse(self, command): #log.info(command) #get current Langue languageHandler.setLanguage("Windows")
def main(): """NVDA's core main loop. This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. Then it initialises the wx application object and installs the core pump timer, which checks the queues and executes functions every 1 ms. Finally, it starts the wx main loop. """ log.debug("Core starting") import config if not globalVars.appArgs.configPath: globalVars.appArgs.configPath=config.getUserDefaultConfigPath(useInstalledPathIfExists=globalVars.appArgs.launcher) #Initialize the config path (make sure it exists) config.initConfigPath() log.info("Config dir: %s"%os.path.abspath(globalVars.appArgs.configPath)) log.debug("loading config") import config config.load() if not globalVars.appArgs.minimal: try: nvwave.playWaveFile("waves\\start.wav") except: pass logHandler.setLogLevelFromConfig() try: lang = config.conf["general"]["language"] import languageHandler log.debug("setting language to %s"%lang) languageHandler.setLanguage(lang) except: log.warning("Could not set language to %s"%lang) import versionInfo log.info("NVDA version %s" % versionInfo.version) log.info("Using Windows version %r" % (sys.getwindowsversion(),)) log.info("Using Python version %s"%sys.version) log.info("Using comtypes version %s"%comtypes.__version__) # Set a reasonable timeout for any socket connections NVDA makes. import socket socket.setdefaulttimeout(10) log.debug("Initializing addons system.") addonHandler.initialize() import appModuleHandler log.debug("Initializing appModule Handler") appModuleHandler.initialize() import NVDAHelper log.debug("Initializing NVDAHelper") NVDAHelper.initialize() import speechDictHandler log.debug("Speech Dictionary processing") speechDictHandler.initialize() import speech log.debug("Initializing speech") speech.initialize() if not globalVars.appArgs.minimal and (time.time()-globalVars.startTime)>5: log.debugWarning("Slow starting core (%.2f sec)" % (time.time()-globalVars.startTime)) # Translators: This is spoken when NVDA is starting. speech.speakMessage(_("Loading NVDA. Please wait...")) import wx log.info("Using wx version %s"%wx.version()) app = wx.App(redirect=False) # HACK: wx currently raises spurious assertion failures when a timer is stopped but there is already an event in the queue for that timer. # Unfortunately, these assertion exceptions are raised in the middle of other code, which causes problems. # Therefore, disable assertions for now. app.SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS) # We do support QueryEndSession events, but we don't want to do anything for them. app.Bind(wx.EVT_QUERY_END_SESSION, lambda evt: None) def onEndSession(evt): # NVDA will be terminated as soon as this function returns, so save configuration if appropriate. config.saveOnExit() speech.cancelSpeech() if not globalVars.appArgs.minimal: try: nvwave.playWaveFile("waves\\exit.wav",async=False) except: pass log.info("Windows session ending") app.Bind(wx.EVT_END_SESSION, onEndSession) import braille log.debug("Initializing braille") braille.initialize() log.debug("Initializing braille input") import brailleInput brailleInput.initialize() import displayModel log.debug("Initializing displayModel") displayModel.initialize() log.debug("Initializing GUI") import gui gui.initialize() # initialize wxpython localization support locale = wx.Locale() lang=languageHandler.getLanguage() if '_' in lang: wxLang=lang.split('_')[0] else: wxLang=lang if hasattr(sys,'frozen'): locale.AddCatalogLookupPathPrefix(os.path.join(os.getcwdu(),"locale")) try: locale.Init(lang,wxLang) except: pass import api import winUser import NVDAObjects.window desktopObject=NVDAObjects.window.Window(windowHandle=winUser.getDesktopWindow()) api.setDesktopObject(desktopObject) api.setFocusObject(desktopObject) api.setNavigatorObject(desktopObject) api.setMouseObject(desktopObject) import JABHandler log.debug("initializing Java Access Bridge support") try: JABHandler.initialize() except NotImplementedError: log.warning("Java Access Bridge not available") except: log.error("Error initializing Java Access Bridge support", exc_info=True) import winConsoleHandler log.debug("Initializing winConsole support") winConsoleHandler.initialize() import UIAHandler log.debug("Initializing UIA support") try: UIAHandler.initialize() except NotImplementedError: log.warning("UIA not available") except: log.error("Error initializing UIA support", exc_info=True) import IAccessibleHandler log.debug("Initializing IAccessible support") IAccessibleHandler.initialize() log.debug("Initializing input core") import inputCore inputCore.initialize() import keyboardHandler log.debug("Initializing keyboard handler") keyboardHandler.initialize() import mouseHandler log.debug("initializing mouse handler") mouseHandler.initialize() import touchHandler log.debug("Initializing touchHandler") try: touchHandler.initialize() except NotImplementedError: pass import globalPluginHandler log.debug("Initializing global plugin handler") globalPluginHandler.initialize() if globalVars.appArgs.install: import wx import gui.installerGui wx.CallAfter(gui.installerGui.doSilentInstall) elif not globalVars.appArgs.minimal: try: # Translators: This is shown on a braille display (if one is connected) when NVDA starts. braille.handler.message(_("NVDA started")) except: log.error("", exc_info=True) if globalVars.appArgs.launcher: gui.LauncherDialog.run() # LauncherDialog will call doStartupDialogs() afterwards if required. else: wx.CallAfter(doStartupDialogs) import queueHandler # Queue the handling of initial focus, # as API handlers might need to be pumped to get the first focus event. queueHandler.queueFunction(queueHandler.eventQueue, _setInitialFocus) import watchdog import baseObject class CorePump(wx.Timer): "Checks the queues and executes functions." def __init__(self,*args,**kwargs): log.debug("Core pump starting") super(CorePump,self).__init__(*args,**kwargs) def Notify(self): try: JABHandler.pumpAll() IAccessibleHandler.pumpAll() queueHandler.pumpAll() mouseHandler.pumpAll() braille.pumpAll() except: log.exception("errors in this core pump cycle") baseObject.AutoPropertyObject.invalidateCaches() watchdog.alive() log.debug("starting core pump") pump = CorePump() pump.Start(1) log.debug("Initializing watchdog") watchdog.initialize() try: import updateCheck except RuntimeError: updateCheck=None log.debug("Update checking not supported") else: log.debug("initializing updateCheck") updateCheck.initialize() log.info("NVDA initialized") log.debug("entering wx application main loop") app.MainLoop() log.info("Exiting") if updateCheck: log.debug("Terminating updateCheck") updateCheck.terminate() log.debug("Terminating watchdog") watchdog.terminate() log.debug("Terminating global plugin handler") globalPluginHandler.terminate() log.debug("Terminating GUI") gui.terminate() config.saveOnExit() try: if globalVars.focusObject and hasattr(globalVars.focusObject,"event_loseFocus"): log.debug("calling lose focus on object with focus") globalVars.focusObject.event_loseFocus() except: log.error("Lose focus error",exc_info=True) try: speech.cancelSpeech() except: pass log.debug("Cleaning up running treeInterceptors") try: import treeInterceptorHandler treeInterceptorHandler.terminate() except: log.error("Error cleaning up treeInterceptors",exc_info=True) log.debug("Terminating IAccessible support") try: IAccessibleHandler.terminate() except: log.error("Error terminating IAccessible support",exc_info=True) log.debug("Terminating UIA support") try: UIAHandler.terminate() except: log.error("Error terminating UIA support",exc_info=True) log.debug("Terminating winConsole support") try: winConsoleHandler.terminate() except: log.error("Error terminating winConsole support",exc_info=True) log.debug("Terminating Java Access Bridge support") try: JABHandler.terminate() except: log.error("Error terminating Java Access Bridge support",exc_info=True) log.debug("Terminating app module handler") appModuleHandler.terminate() log.debug("Terminating NVDAHelper") try: NVDAHelper.terminate() except: log.error("Error terminating NVDAHelper",exc_info=True) log.debug("Terminating touchHandler") try: touchHandler.terminate() except: log.error("Error terminating touchHandler") log.debug("Terminating keyboard handler") try: keyboardHandler.terminate() except: log.error("Error terminating keyboard handler") log.debug("Terminating mouse handler") try: mouseHandler.terminate() except: log.error("error terminating mouse handler",exc_info=True) log.debug("Terminating input core") inputCore.terminate() log.debug("Terminating brailleInput") brailleInput.terminate() log.debug("Terminating braille") try: braille.terminate() except: log.error("Error terminating braille",exc_info=True) log.debug("Terminating speech") try: speech.terminate() except: log.error("Error terminating speech",exc_info=True) try: addonHandler.terminate() except: log.error("Error terminating addonHandler",exc_info=True) if not globalVars.appArgs.minimal: try: nvwave.playWaveFile("waves\\exit.wav",async=False) except: pass log.debug("core done")
stderr_temp.close() #finally, remove the temporal files. TW Blue doesn't need them anymore, and we will get more free space on the harddrive os.remove(stdout_temp.name) os.remove(stderr_temp.name) app = wx.App() #app = wx.App(redirect=True, useBestVisual=True, filename=paths.logs_path('tracebacks.log')) configured = False configs = [] for i in os.listdir(paths.config_path()): if os.path.isdir(paths.config_path(i)): configs.append(i) if len(configs) == 1: manager.manager.set_current_session(configs[0]) config.MAINFILE = "%s/session.conf" % (manager.manager.get_current_session()) config.setup() lang=config.main['general']['language'] languageHandler.setLanguage(lang) sound.setup() output.setup() configured = True else: ssmg = smGUI.sessionManagerWindow() if configured == True or ssmg.ShowModal() == wx.ID_OK: frame = gui.main.mainFrame() frame.Show() frame.showing = True if config.main != None and config.main["general"]["hide_gui"] == True and platform.system() == "Windows": frame.show_hide() frame.Hide() app.SetTopWindow(frame) else: app.Exit()
# coding: UTF-8 # A part of NonVisual Desktop Access (NVDA) # by Takuya Nishimoto (NVDA Japanese Team) # jpDicTest.py for testing source/nvdajp_dic.py # Usage: # > cd jptools # > python jpDicTest.py from __future__ import unicode_literals, print_function import unittest import sys, os sys.path.append(os.path.normpath(os.path.join(os.getcwdu(), 'mocks'))) sys.path.append(r'..\source') sys.path.append(r'..\miscdeps\python') import languageHandler languageHandler.setLanguage('ja') import jpUtils import locale import gettext gettext.translation('nvda',localedir=r'..\source\locale',languages=['ja']).install(True) items = [ ('a', '半角 英字 エー アルファー', '半角 a'), ('A', '半角 英字 大文字 エー アルファー', '半角 A'), ('あ', 'ヒラガナ あ', 'ヒラガナ あ'), ('ア', 'カタカナ ア', 'カタカナ ア'), ('あア', 'ヒラガナ あ カタカナ ア', 'ヒラガナ あ カタカナ ア'), ('を', 'ヒラガナ オワリノ オ', 'ヒラガナ を'), ('ヲ', 'カタカナ オワリノ オ', 'カタカナ ヲ'), ('123', '半角 イチ ニ サン', '半角 123'), ('123', '全角 イチ ニ サン', '全角 123'),
def main(): """NVDA's core main loop. This initializes all modules such as audio, IAccessible, keyboard, mouse, and GUI. Then it initialises the wx application object and sets up the core pump, which checks the queues and executes functions when requested. Finally, it starts the wx main loop. """ log.debug("Core starting") ctypes.windll.user32.SetProcessDPIAware() import config if not globalVars.appArgs.configPath: globalVars.appArgs.configPath=config.getUserDefaultConfigPath(useInstalledPathIfExists=globalVars.appArgs.launcher) #Initialize the config path (make sure it exists) config.initConfigPath() log.info("Config dir: %s"%os.path.abspath(globalVars.appArgs.configPath)) log.debug("loading config") import config config.initialize() if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]: try: nvwave.playWaveFile("waves\\start.wav") except: pass logHandler.setLogLevelFromConfig() try: lang = config.conf["general"]["language"] import languageHandler log.debug("setting language to %s"%lang) languageHandler.setLanguage(lang) except: log.warning("Could not set language to %s"%lang) import versionInfo log.info("NVDA version %s" % versionInfo.version) log.info("Using Windows version %s" % winVersion.winVersionText) log.info("Using Python version %s"%sys.version) log.info("Using comtypes version %s"%comtypes.__version__) import configobj log.info("Using configobj version %s with validate version %s"%(configobj.__version__,configobj.validate.__version__)) # Set a reasonable timeout for any socket connections NVDA makes. import socket socket.setdefaulttimeout(10) log.debug("Initializing add-ons system") addonHandler.initialize() if globalVars.appArgs.disableAddons: log.info("Add-ons are disabled. Restart NVDA to enable them.") import appModuleHandler log.debug("Initializing appModule Handler") appModuleHandler.initialize() import NVDAHelper log.debug("Initializing NVDAHelper") NVDAHelper.initialize() import speechDictHandler log.debug("Speech Dictionary processing") speechDictHandler.initialize() import speech log.debug("Initializing speech") speech.initialize() if not globalVars.appArgs.minimal and (time.time()-globalVars.startTime)>5: log.debugWarning("Slow starting core (%.2f sec)" % (time.time()-globalVars.startTime)) # Translators: This is spoken when NVDA is starting. speech.speakMessage(_("Loading NVDA. Please wait...")) import wx # wxPython 4 no longer has either of these constants (despite the documentation saying so), some add-ons may rely on # them so we add it back into wx. https://wxpython.org/Phoenix/docs/html/wx.Window.html#wx.Window.Centre wx.CENTER_ON_SCREEN = wx.CENTRE_ON_SCREEN = 0x2 log.info("Using wx version %s"%wx.version()) class App(wx.App): def OnAssert(self,file,line,cond,msg): message="{file}, line {line}:\nassert {cond}: {msg}".format(file=file,line=line,cond=cond,msg=msg) log.debugWarning(message,codepath="WX Widgets",stack_info=True) app = App(redirect=False) # We support queryEndSession events, but in general don't do anything for them. # However, when running as a Windows Store application, we do want to request to be restarted for updates def onQueryEndSession(evt): if config.isAppX: # Automatically restart NVDA on Windows Store update ctypes.windll.kernel32.RegisterApplicationRestart(None,0) app.Bind(wx.EVT_QUERY_END_SESSION, onQueryEndSession) def onEndSession(evt): # NVDA will be terminated as soon as this function returns, so save configuration if appropriate. config.saveOnExit() speech.cancelSpeech() if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]: try: nvwave.playWaveFile("waves\\exit.wav",async=False) except: pass log.info("Windows session ending") app.Bind(wx.EVT_END_SESSION, onEndSession) log.debug("Initializing braille input") import brailleInput brailleInput.initialize() import braille log.debug("Initializing braille") braille.initialize() import displayModel log.debug("Initializing displayModel") displayModel.initialize() log.debug("Initializing GUI") import gui gui.initialize() import audioDucking if audioDucking.isAudioDuckingSupported(): # the GUI mainloop must be running for this to work so delay it wx.CallAfter(audioDucking.initialize) # #3763: In wxPython 3, the class name of frame windows changed from wxWindowClassNR to wxWindowNR. # NVDA uses the main frame to check for and quit another instance of NVDA. # To remain compatible with older versions of NVDA, create our own wxWindowClassNR. # We don't need to do anything else because wx handles WM_QUIT for all windows. import windowUtils class MessageWindow(windowUtils.CustomWindow): className = u"wxWindowClassNR" #Just define these constants here, so we don't have to import win32con WM_POWERBROADCAST = 0x218 WM_DISPLAYCHANGE = 0x7e PBT_APMPOWERSTATUSCHANGE = 0xA UNKNOWN_BATTERY_STATUS = 0xFF AC_ONLINE = 0X1 NO_SYSTEM_BATTERY = 0X80 #States for screen orientation ORIENTATION_NOT_INITIALIZED = 0 ORIENTATION_PORTRAIT = 1 ORIENTATION_LANDSCAPE = 2 def __init__(self, windowName=None): super(MessageWindow, self).__init__(windowName) self.oldBatteryStatus = None self.orientationStateCache = self.ORIENTATION_NOT_INITIALIZED self.orientationCoordsCache = (0,0) self.handlePowerStatusChange() def windowProc(self, hwnd, msg, wParam, lParam): post_windowMessageReceipt.notify(msg=msg, wParam=wParam, lParam=lParam) if msg == self.WM_POWERBROADCAST and wParam == self.PBT_APMPOWERSTATUSCHANGE: self.handlePowerStatusChange() elif msg == self.WM_DISPLAYCHANGE: self.handleScreenOrientationChange(lParam) def handleScreenOrientationChange(self, lParam): import ui import winUser # Resolution detection comes from an article found at https://msdn.microsoft.com/en-us/library/ms812142.aspx. #The low word is the width and hiword is height. width = winUser.LOWORD(lParam) height = winUser.HIWORD(lParam) self.orientationCoordsCache = (width,height) if width > height: # If the height and width are the same, it's actually a screen flip, and we do want to alert of those! if self.orientationStateCache == self.ORIENTATION_LANDSCAPE and self.orientationCoordsCache != (width,height): return #Translators: The screen is oriented so that it is wider than it is tall. ui.message(_("Landscape" )) self.orientationStateCache = self.ORIENTATION_LANDSCAPE else: if self.orientationStateCache == self.ORIENTATION_PORTRAIT and self.orientationCoordsCache != (width,height): return #Translators: The screen is oriented in such a way that the height is taller than it is wide. ui.message(_("Portrait")) self.orientationStateCache = self.ORIENTATION_PORTRAIT def handlePowerStatusChange(self): #Mostly taken from script_say_battery_status, but modified. import ui import winKernel sps = winKernel.SYSTEM_POWER_STATUS() if not winKernel.GetSystemPowerStatus(sps) or sps.BatteryFlag is self.UNKNOWN_BATTERY_STATUS: return if sps.BatteryFlag & self.NO_SYSTEM_BATTERY: return if self.oldBatteryStatus is None: #Just initializing the cache, do not report anything. self.oldBatteryStatus = sps.ACLineStatus return if sps.ACLineStatus == self.oldBatteryStatus: #Sometimes, this double fires. This also fires when the battery level decreases by 3%. return self.oldBatteryStatus = sps.ACLineStatus if sps.ACLineStatus & self.AC_ONLINE: #Translators: Reported when the battery is plugged in, and now is charging. ui.message(_("Charging battery. %d percent") % sps.BatteryLifePercent) else: #Translators: Reported when the battery is no longer plugged in, and now is not charging. ui.message(_("Not charging battery. %d percent") %sps.BatteryLifePercent) messageWindow = MessageWindow(unicode(versionInfo.name)) # initialize wxpython localization support locale = wx.Locale() lang=languageHandler.getLanguage() wxLang=locale.FindLanguageInfo(lang) if not wxLang and '_' in lang: wxLang=locale.FindLanguageInfo(lang.split('_')[0]) if hasattr(sys,'frozen'): locale.AddCatalogLookupPathPrefix(os.path.join(os.getcwdu(),"locale")) # #8064: Wx might know the language, but may not actually contain a translation database for that language. # If we try to initialize this language, wx will show a warning dialog. # Therefore treat this situation like wx not knowing the language at all. if not locale.IsAvailable(wxLang.Language): wxLang=None if wxLang: try: locale.Init(wxLang.Language) except: log.error("Failed to initialize wx locale",exc_info=True) else: log.debugWarning("wx does not support language %s" % lang) import api import winUser import NVDAObjects.window desktopObject=NVDAObjects.window.Window(windowHandle=winUser.getDesktopWindow()) api.setDesktopObject(desktopObject) api.setFocusObject(desktopObject) api.setNavigatorObject(desktopObject) api.setMouseObject(desktopObject) import JABHandler log.debug("initializing Java Access Bridge support") try: JABHandler.initialize() except NotImplementedError: log.warning("Java Access Bridge not available") except: log.error("Error initializing Java Access Bridge support", exc_info=True) import winConsoleHandler log.debug("Initializing winConsole support") winConsoleHandler.initialize() import UIAHandler log.debug("Initializing UIA support") try: UIAHandler.initialize() except NotImplementedError: log.warning("UIA not available") except: log.error("Error initializing UIA support", exc_info=True) import IAccessibleHandler log.debug("Initializing IAccessible support") IAccessibleHandler.initialize() log.debug("Initializing input core") import inputCore inputCore.initialize() import keyboardHandler log.debug("Initializing keyboard handler") keyboardHandler.initialize() import mouseHandler log.debug("initializing mouse handler") mouseHandler.initialize() import touchHandler log.debug("Initializing touchHandler") try: touchHandler.initialize() except NotImplementedError: pass import globalPluginHandler log.debug("Initializing global plugin handler") globalPluginHandler.initialize() if globalVars.appArgs.install or globalVars.appArgs.installSilent: import gui.installerGui wx.CallAfter(gui.installerGui.doSilentInstall,startAfterInstall=not globalVars.appArgs.installSilent) elif globalVars.appArgs.portablePath and (globalVars.appArgs.createPortable or globalVars.appArgs.createPortableSilent): import gui.installerGui wx.CallAfter(gui.installerGui.doCreatePortable,portableDirectory=globalVars.appArgs.portablePath, silent=globalVars.appArgs.createPortableSilent,startAfterCreate=not globalVars.appArgs.createPortableSilent) elif not globalVars.appArgs.minimal: try: # Translators: This is shown on a braille display (if one is connected) when NVDA starts. braille.handler.message(_("NVDA started")) except: log.error("", exc_info=True) if globalVars.appArgs.launcher: gui.LauncherDialog.run() # LauncherDialog will call doStartupDialogs() afterwards if required. else: wx.CallAfter(doStartupDialogs) import queueHandler # Queue the handling of initial focus, # as API handlers might need to be pumped to get the first focus event. queueHandler.queueFunction(queueHandler.eventQueue, _setInitialFocus) import watchdog import baseObject # Doing this here is a bit ugly, but we don't want these modules imported # at module level, including wx. log.debug("Initializing core pump") class CorePump(gui.NonReEntrantTimer): "Checks the queues and executes functions." def run(self): global _isPumpPending _isPumpPending = False watchdog.alive() try: if touchHandler.handler: touchHandler.handler.pump() JABHandler.pumpAll() IAccessibleHandler.pumpAll() queueHandler.pumpAll() mouseHandler.pumpAll() braille.pumpAll() except: log.exception("errors in this core pump cycle") baseObject.AutoPropertyObject.invalidateCaches() watchdog.asleep() if _isPumpPending and not _pump.IsRunning(): # #3803: Another pump was requested during this pump execution. # As our pump is not re-entrant, schedule another pump. _pump.Start(PUMP_MAX_DELAY, True) global _pump _pump = CorePump() requestPump() log.debug("Initializing watchdog") watchdog.initialize() try: import updateCheck except RuntimeError: updateCheck=None log.debug("Update checking not supported") else: log.debug("initializing updateCheck") updateCheck.initialize() log.info("NVDA initialized") postNvdaStartup.notify() log.debug("entering wx application main loop") app.MainLoop() log.info("Exiting") if updateCheck: _terminate(updateCheck) _terminate(watchdog) _terminate(globalPluginHandler, name="global plugin handler") _terminate(gui) config.saveOnExit() try: if globalVars.focusObject and hasattr(globalVars.focusObject,"event_loseFocus"): log.debug("calling lose focus on object with focus") globalVars.focusObject.event_loseFocus() except: log.exception("Lose focus error") try: speech.cancelSpeech() except: pass import treeInterceptorHandler _terminate(treeInterceptorHandler) _terminate(IAccessibleHandler, name="IAccessible support") _terminate(UIAHandler, name="UIA support") _terminate(winConsoleHandler, name="winConsole support") _terminate(JABHandler, name="Java Access Bridge support") _terminate(appModuleHandler, name="app module handler") _terminate(NVDAHelper) _terminate(touchHandler) _terminate(keyboardHandler, name="keyboard handler") _terminate(mouseHandler) _terminate(inputCore) _terminate(brailleInput) _terminate(braille) _terminate(speech) _terminate(addonHandler) if not globalVars.appArgs.minimal and config.conf["general"]["playStartAndExitSounds"]: try: nvwave.playWaveFile("waves\\exit.wav",async=False) except: pass # #5189: Destroy the message window as late as possible # so new instances of NVDA can find this one even if it freezes during exit. messageWindow.destroy() log.debug("core done")
def setUp(self): """ `setLocale` doesn't change current NVDA language, so reset the locale using `setLanguage` to the current language for each test. """ languageHandler.setLanguage(languageHandler.getLanguage())