Esempio n. 1
0
def promptMask(webModule):
	ref = webModule.getLayer("addon", raiseIfMissing=True).storeRef
	if ref[0] != "addons":
		raise ValueError("ref={!r}".format(ref))
	addonName = ref[1]
	for addon in addonHandler.getRunningAddons():
		if addon.name == addonName:
			addonSummary = addon.manifest["summary"]
			break
	else:
		raise LookupError("addonName={!r}".format(addonName))
	log.info(u"Proposing to mask {!r} from addon {!r}".format(webModule, addonName))
	msg = _(
		u"""This web module comes with the add-on {addonSummary}.
It cannot be modified at its current location.

Do you want to make a copy in your scratchpad?
"""
	).format(addonSummary=addonSummary)
	return gui.messageBox(
		parent=gui.mainFrame,
		message=msg,
		caption=_("Warning"),
		style=wx.ICON_WARNING | wx.YES | wx.NO
	) == wx.YES
Esempio n. 2
0
def addConfigDirsToPythonPackagePath(module, subdir=None):
	"""Add the configuration directories to the module search path (__path__) of a Python package.
	C{subdir} is added to each configuration directory. It defaults to the name of the Python package.
	@param module: The root module of the package.
	@type module: module
	@param subdir: The subdirectory to be used, C{None} for the name of C{module}.
	@type subdir: str
	"""
	if isAppX or globalVars.appArgs.disableAddons:
		return
	# FIXME: this should not be coupled to the config module....
	import addonHandler
	for addon in addonHandler.getRunningAddons():
		addon.addToPackagePath(module)
	if globalVars.appArgs.secure or not conf['development']['enableScratchpadDir']:
		return
	if not subdir:
		subdir = module.__name__
	fullPath=os.path.join(getScratchpadDir(),subdir)
	# Ensure this directory exists otherwise pkgutil.iter_importers may emit None for missing paths.
	if not os.path.isdir(fullPath):
		os.makedirs(fullPath)
	# Insert this path at the beginning  of the module's search paths.
	# The module's search paths may not be a mutable  list, so replace it with a new one 
	pathList=[fullPath]
	pathList.extend(module.__path__)
	module.__path__=pathList
Esempio n. 3
0
def addConfigDirsToPythonPackagePath(module, subdir=None):
	"""Add the configuration directories to the module search path (__path__) of a Python package.
	C{subdir} is added to each configuration directory. It defaults to the name of the Python package.
	@param module: The root module of the package.
	@type module: module
	@param subdir: The subdirectory to be used, C{None} for the name of C{module}.
	@type subdir: str
	"""
	if isAppX or globalVars.appArgs.disableAddons:
		return
	# FIXME: this should not be coupled to the config module....
	import addonHandler
	for addon in addonHandler.getRunningAddons():
		addon.addToPackagePath(module)
	if globalVars.appArgs.secure or not conf['development']['enableScratchpadDir']:
		return
	if not subdir:
		subdir = module.__name__
	fullPath=os.path.join(getScratchpadDir(),subdir)
	# Python 2.x doesn't properly handle unicode import paths, so convert them.
	fullPath=fullPath.encode("mbcs")
	# Insert this path at the beginning  of the module's search paths.
	# The module's search paths may not be a mutable  list, so replace it with a new one 
	pathList=[fullPath]
	pathList.extend(module.__path__)
	module.__path__=pathList
Esempio n. 4
0
 def __get_resource_paths(self):
     paths = []
     for addon in addonHandler.getRunningAddons():
         if not data_addon_name_pattern.match(addon.name):
             continue
         for name in ["data", "langdata"]:
             data_path = os.path.join(addon.path, name)
             if os.path.isdir(data_path):
                 paths.append(data_path.encode("UTF-8"))
     return paths
Esempio n. 5
0
	def __init__(self):
		self.__lib=load_tts_library()
		self.__cancel_flag=threading.Event()
		self.__player=audio_player(self.__cancel_flag)
		self.__sample_rate_callback=sample_rate_callback(self.__lib,self.__player)
		self.__c_sample_rate_callback=RHVoice_callback_types.set_sample_rate(self.__sample_rate_callback)
		self.__speech_callback=speech_callback(self.__lib,self.__player,self.__cancel_flag)
		self.__c_speech_callback=RHVoice_callback_types.play_speech(self.__speech_callback)
		self.__mark_callback=mark_callback(self.__lib)
		self.__c_mark_callback=RHVoice_callback_types.process_mark(self.__mark_callback)
		resource_paths=[os.path.join(addon.path,"data").encode("UTF-8") for addon in addonHandler.getRunningAddons() if (addon.name.startswith("RHVoice-language") or addon.name.startswith("RHVoice-voice"))]
		c_resource_paths=(c_char_p*(len(resource_paths)+1))(*(resource_paths+[None]))
		init_params=RHVoice_init_params(None,
										config_path.encode("utf-8"),
										c_resource_paths,
										RHVoice_callbacks(self.__c_sample_rate_callback,
															  self.__c_speech_callback,
														  self.__c_mark_callback,
														  cast(None,RHVoice_callback_types.word_starts),
														  cast(None,RHVoice_callback_types.word_ends),
														  cast(None,RHVoice_callback_types.sentence_starts),
														  cast(None,RHVoice_callback_types.sentence_ends),
														  cast(None,RHVoice_callback_types.play_audio)),
										0)
		self.__tts_engine=self.__lib.RHVoice_new_tts_engine(byref(init_params))
		if not self.__tts_engine:
			raise RuntimeError("RHVoice: initialization error")
		nvda_language=languageHandler.getLanguage().split("_")[0]
		number_of_voices=self.__lib.RHVoice_get_number_of_voices(self.__tts_engine)
		native_voices=self.__lib.RHVoice_get_voices(self.__tts_engine)
		self.__voice_languages=dict()
		self.__languages=set()
		for i in range(number_of_voices):
			native_voice=native_voices[i]
			self.__voice_languages[native_voice.name.decode("utf-8")]=native_voice.language.decode("utf-8")
			self.__languages.add(native_voice.language.decode("utf-8"))
		self.__profile=None
		self.__profiles=list()
		number_of_profiles=self.__lib.RHVoice_get_number_of_voice_profiles(self.__tts_engine)
		native_profile_names=self.__lib.RHVoice_get_voice_profiles(self.__tts_engine)
		for i in range(number_of_profiles):
			name=native_profile_names[i].decode("utf-8")
			self.__profiles.append(name)
			if (self.__profile is None) and (nvda_language==self.__voice_languages[name.split("+")[0]]):
				self.__profile=name
		if self.__profile is None:
			self.__profile=self.__profiles[0]
		self.__rate=50
		self.__pitch=50
		self.__volume=50
		self.__tts_queue=Queue.Queue()
		self.__tts_thread=TTSThread(self.__tts_queue)
		self.__tts_thread.start()
		log.info("Using RHVoice version {}".format(self.__lib.RHVoice_get_version()))
def checkWindowListAddonInstalled():
	h = winUser.getForegroundWindow()
	addonCheckList = [
		"fakeClipboardAnouncement",
		"listDesFenetres",
		"ListeIconesZoneNotification",
		"DitDossierOuvrirEnregistrer"]
	for addon in addonHandler.getRunningAddons():
		if addon.manifest["name"] in addonCheckList:
			# Translators: message of message box
			msg = _("Attention, you must uninstall %s addon because it is now included in this addon.")  # noqa:E501
			gui.messageBox(msg % addon.manifest["name"])
			break
	winUser.setForegroundWindow(h)
Esempio n. 7
0
def addConfigDirsToPythonPackagePath(module, subdir=None):
	"""Add the configuration directories to the module search path (__path__) of a Python package.
	C{subdir} is added to each configuration directory. It defaults to the name of the Python package.
	@param module: The root module of the package.
	@type module: module
	@param subdir: The subdirectory to be used, C{None} for the name of C{module}.
	@type subdir: str
	"""
	if not subdir:
		subdir = module.__name__
	# Python 2.x doesn't properly handle unicode import paths, so convert them.
	dirs = [dir.encode("mbcs") for dir in getConfigDirs(subdir)]
	dirs.extend(module.__path__ )
	module.__path__ = dirs
	# FIXME: this should not be coupled to the config module....
	import addonHandler
	for addon in addonHandler.getRunningAddons():
		addon.addToPackagePath(module)
Esempio n. 8
0
def addConfigDirsToPythonPackagePath(module, subdir=None):
    """Add the configuration directories to the module search path (__path__) of a Python package.
	C{subdir} is added to each configuration directory. It defaults to the name of the Python package.
	@param module: The root module of the package.
	@type module: module
	@param subdir: The subdirectory to be used, C{None} for the name of C{module}.
	@type subdir: str
	"""
    if not subdir:
        subdir = module.__name__
    # Python 2.x doesn't properly handle unicode import paths, so convert them.
    dirs = [dir.encode("mbcs") for dir in getConfigDirs(subdir)]
    dirs.extend(module.__path__)
    module.__path__ = dirs
    # FIXME: this should not be coupled to the config module....
    import addonHandler
    for addon in addonHandler.getRunningAddons():
        addon.addToPackagePath(module)
Esempio n. 9
0
hSpeechClass = None
installResources = None
speakingInstance = None
onIndexReached = None
bgThread = None
pcmBufLen = 8192
pcmBuf = None
markBuf = None
markBufSize = 100
feedBuf = None
bgQueue = None
player = None

# Vocalizer voices
availableVoices = [
    addon.path for addon in addonHandler.getRunningAddons()
    if addon.name.startswith("vocalizer-expressive-voice")
]
freedomScientificVoices = os.path.join(os.getenv("PROGRAMDATA",
                                                 ""), "Freedom Scientific",
                                       "VocalizerExpressive", "2.2",
                                       "languages")
try:
    if os.listdir(freedomScientificVoices):
        availableVoices.append(freedomScientificVoices)
except IOError:
    pass


def preInitialize():
    global msvcrDll, veDll, platformDll, hSpeechClass, installResources
Esempio n. 10
0
 def __init__(self):
     self.__lib = load_tts_library()
     self.__cancel_flag = threading.Event()
     self.__player = audio_player(self.__cancel_flag)
     self.__sample_rate_callback = sample_rate_callback(
         self.__lib, self.__player)
     self.__c_sample_rate_callback = RHVoice_callback_types.set_sample_rate(
         self.__sample_rate_callback)
     self.__speech_callback = speech_callback(self.__lib, self.__player,
                                              self.__cancel_flag)
     self.__c_speech_callback = RHVoice_callback_types.play_speech(
         self.__speech_callback)
     self.__mark_callback = mark_callback(self.__lib)
     self.__c_mark_callback = RHVoice_callback_types.process_mark(
         self.__mark_callback)
     resource_paths = [
         os.path.join(addon.path, "data").encode("UTF-8")
         for addon in addonHandler.getRunningAddons()
         if (addon.name.startswith("RHVoice-language")
             or addon.name.startswith("RHVoice-voice"))
     ]
     c_resource_paths = (c_char_p * (len(resource_paths) + 1))(
         *(resource_paths + [None]))
     init_params = RHVoice_init_params(
         None, config_path.encode("utf-8"), c_resource_paths,
         RHVoice_callbacks(
             self.__c_sample_rate_callback, self.__c_speech_callback,
             self.__c_mark_callback,
             cast(None, RHVoice_callback_types.word_starts),
             cast(None, RHVoice_callback_types.word_ends),
             cast(None, RHVoice_callback_types.sentence_starts),
             cast(None, RHVoice_callback_types.sentence_ends),
             cast(None, RHVoice_callback_types.play_audio)), 0)
     self.__tts_engine = self.__lib.RHVoice_new_tts_engine(
         byref(init_params))
     if not self.__tts_engine:
         raise RuntimeError("RHVoice: initialization error")
     nvda_language = languageHandler.getLanguage().split("_")[0]
     number_of_voices = self.__lib.RHVoice_get_number_of_voices(
         self.__tts_engine)
     native_voices = self.__lib.RHVoice_get_voices(self.__tts_engine)
     self.__voice_languages = dict()
     self.__languages = set()
     for i in xrange(number_of_voices):
         native_voice = native_voices[i]
         self.__voice_languages[native_voice.name] = native_voice.language
         self.__languages.add(native_voice.language)
     self.__profile = None
     self.__profiles = list()
     number_of_profiles = self.__lib.RHVoice_get_number_of_voice_profiles(
         self.__tts_engine)
     native_profile_names = self.__lib.RHVoice_get_voice_profiles(
         self.__tts_engine)
     for i in xrange(number_of_profiles):
         name = native_profile_names[i]
         self.__profiles.append(name)
         if (self.__profile is
                 None) and (nvda_language
                            == self.__voice_languages[name.split("+")[0]]):
             self.__profile = name
     if self.__profile is None:
         self.__profile = self.__profiles[0]
     self.__rate = 50
     self.__pitch = 50
     self.__volume = 50
     self.__tts_queue = Queue.Queue()
     self.__tts_thread = TTSThread(self.__tts_queue)
     self.__tts_thread.start()
     log.info("Using RHVoice version {}".format(
         self.__lib.RHVoice_get_version()))