예제 #1
0
def getInstalledUserConfigPath() -> Optional[str]:
	try:
		k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, RegistryKey.NVDA.value)
	except FileNotFoundError:
		log.debug("Could not find nvda registry key, NVDA is not currently installed")
		return None
	except WindowsError:
		log.error("Could not open nvda registry key", exc_info=True)
		return None

	try:
		configInLocalAppData = bool(winreg.QueryValueEx(k, CONFIG_IN_LOCAL_APPDATA_SUBKEY)[0])
	except FileNotFoundError:
		log.debug("Installed user config is not in local app data")
		configInLocalAppData = False
	except WindowsError:
		log.error(
			f"Could not query if user config in local app data {CONFIG_IN_LOCAL_APPDATA_SUBKEY}",
			exc_info=True
		)
		configInLocalAppData = False
	configParent = shlobj.SHGetKnownFolderPath(
		shlobj.FolderId.LOCAL_APP_DATA if configInLocalAppData else shlobj.FolderId.ROAMING_APP_DATA
	)
	try:
		return os.path.join(configParent, "nvda")
	except WindowsError:
		# (#13242) There is some uncertainty as to how this could be caused
		log.debugWarning("Installed user config is not in local app data", exc_info=True)
		return None
예제 #2
0
	def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		self.local_machine = local_machine.LocalMachine()
		self.slave_session = None
		self.master_session = None
		self.create_menu()
		self.connecting = False
		self.url_handler_window = url_handler.URLHandlerWindow(callback=self.verify_connect)
		url_handler.register_url_handler()
		self.master_transport = None
		self.slave_transport = None
		self.server = None
		self.hook_thread = None
		self.sending_keys = False
		self.key_modified = False
		self.sd_server = None
		self.sd_relay = None
		self.sd_bridge = None
		cs = configuration.get_config()['controlserver']
		if hasattr(shlobj, 'SHGetKnownFolderPath'):
			self.temp_location = os.path.join(shlobj.SHGetKnownFolderPath(shlobj.FolderId.PROGRAM_DATA), 'temp')
		else:
			self.temp_location = os.path.join(shlobj.SHGetFolderPath(0, shlobj.CSIDL_COMMON_APPDATA), 'temp')
		self.ipc_file = os.path.join(self.temp_location, 'remote.ipc')
		if globalVars.appArgs.secure:
			self.handle_secure_desktop()
		if cs['autoconnect'] and not self.master_session and not self.slave_session:
			self.perform_autoconnect()
		self.sd_focused = False
예제 #3
0
파일: fileUtils.py 프로젝트: steverep/nvda
 def funcWrapper(filePath, *attributes):
     nativeSys32 = shlobj.SHGetKnownFolderPath(shlobj.FolderId.SYSTEM)
     if (systemUtils.hasSyswow64Dir()
             # Path's returned from `appModule.appPath` and `shlobj.SHGetKnownFolderPath` often differ in case
             and filePath.casefold().startswith(nativeSys32.casefold())):
         with winKernel.suspendWow64Redirection():
             return func(filePath, *attributes)
     else:
         return func(filePath, *attributes)
예제 #4
0
파일: __init__.py 프로젝트: steverep/nvda
def getInstalledUserConfigPath():
	try:
		k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, NVDA_REGKEY)
		configInLocalAppData = bool(winreg.QueryValueEx(k, CONFIG_IN_LOCAL_APPDATA_SUBKEY)[0])
	except WindowsError:
		configInLocalAppData=False
	configParent = shlobj.SHGetKnownFolderPath(
		shlobj.FolderId.LOCAL_APP_DATA if configInLocalAppData else shlobj.FolderId.ROAMING_APP_DATA
	)
	try:
		return os.path.join(configParent, "nvda")
	except WindowsError:
		return None
 def getVlcSettingsFolderPath(self):
     try:
         if hasattr(shlobj, "SHGetKnownFolderPath"):
             configParent = shlobj.SHGetKnownFolderPath(
                 shlobj.FolderId.ROAMING_APP_DATA)
         else:
             configParent = shlobj.SHGetFolderPath(0, shlobj.CSIDL_APPDATA)
     except WindowsError:
         log.warning("VLC settings directory not found")
         return None
     dir = os.path.join(configParent, "vlc")
     if os.path.exists(dir):
         return dir
     return None
예제 #6
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.local_machine = local_machine.LocalMachine()
     self.slave_session = None
     self.master_session = None
     self.create_menu()
     self.connecting = False
     self.url_handler_window = url_handler.URLHandlerWindow(
         callback=self.verify_connect)
     url_handler.register_url_handler()
     self.master_transport = None
     self.slave_transport = None
     self.server = None
     self.hook_thread = None
     self.sending_keys = False
     self.key_modified = False
     self.sd_server = None
     self.sd_relay = None
     self.sd_bridge = None
     try:
         configuration.get_config()
     except configobj.ParseError:
         os.remove(
             os.path.abspath(
                 os.path.join(globalVars.appArgs.configPath,
                              configuration.CONFIG_FILE_NAME)))
         queueHandler.queueFunction(
             queueHandler.eventQueue, wx.CallAfter, wx.MessageBox,
             _("Your NVDA Remote configuration was corrupted and has been reset."
               ), _("NVDA Remote Configuration Error"),
             wx.OK | wx.ICON_EXCLAMATION)
     cs = configuration.get_config()['controlserver']
     if hasattr(shlobj, 'SHGetKnownFolderPath'):
         self.temp_location = os.path.join(
             shlobj.SHGetKnownFolderPath(shlobj.FolderId.PROGRAM_DATA),
             'temp')
     else:
         self.temp_location = os.path.join(
             shlobj.SHGetFolderPath(0, shlobj.CSIDL_COMMON_APPDATA), 'temp')
     self.ipc_file = os.path.join(self.temp_location, 'remote.ipc')
     if globalVars.appArgs.secure:
         self.handle_secure_desktop()
     if cs['autoconnect'] and not self.master_session and not self.slave_session:
         self.perform_autoconnect()
     self.sd_focused = False
예제 #7
0
def hasSyswow64Dir() -> bool:
    """Returns `True` if the current system has separate system32 directories for 32-bit processes."""
    nativeSys32 = shlobj.SHGetKnownFolderPath(shlobj.FolderId.SYSTEM)
    Syswow64Sys32 = shlobj.SHGetKnownFolderPath(shlobj.FolderId.SYSTEM_X86)
    return nativeSys32 != Syswow64Sys32