def toggleRemanenceActivation(self): if self.taskTimer is not None: self.taskTimer.Stop() self.TaskTimer = None if self.remanenceActivation is False: self.remanenceActivation = True if (_addonConfigManager.getRemanenceAtNVDAStart() and not self.hasPreviousRemanenceActivationOn): # don's say first activation msg = None self.hasPreviousRemanenceActivationOn = True else: # Translators: message to user to report keys remanence is on. msg = _("Keys's remanence activation on") specialForGmail.initialize() else: self.stopRemanence() self.remanenceActivation = False # Translators: message to user to report keys remanence is off. msg = _("Keys's remanence activation off") specialForGmail.terminate() curAddon = addonHandler.getCodeAddon() addonSummary = curAddon.manifest['summary'] if msg is not None: queueHandler.queueFunction(queueHandler.eventQueue, ui.message, "%s - %s" % (addonSummary, msg)) core.callLater(30, ui.message, "%s - %s" % (addonSummary, msg))
def __init__(self, addonName=None, updateInfosFile=None, auto=True, releaseToDev=False): self.addon = None if addonName is None: # get current add-on self.addon = addonHandler.getCodeAddon() else: # find add-on in available add-ons for addon in addonHandler.getAvailableAddons(): if addon.manifest["name"] == addonName: self.addon = addon break if self.addon is None: log.warning("CheckForAddonUpdate: no add-on") return log.warning("Check for %s add-on update" % self.addon.manifest["name"]) self.addonSummary = self.addon.manifest["summary"] self.auto = auto self.releaseToDev = releaseToDev self.destPath = tempfile.mktemp(prefix="myAddons-", suffix=".latest") self.updateInfosFile = updateInfosFile self.title = _("{summary} - update").format(summary=self.addonSummary) # get latest addon update infos latestUpdateInfos = self.getLatestUpdateInfos(self.updateInfosFile) if latestUpdateInfos is None: return # check if service is in maintenance if latestUpdateInfos.get("inMaintenance") and latestUpdateInfos[ "inMaintenance"]: # noqa:E501 if auto: return gui.messageBox( _("The service is temporarily under maintenance. Please, try again later." ), # noqa:E501 self.title, wx.OK | wx.ICON_INFORMATION) return addonUpdateInfos = latestUpdateInfos.get(self.addon.manifest["name"]) if addonUpdateInfos is None: # no update for this add-on wx.CallAfter(self.upToDateDialog, self.auto) return newUpdate = self.checkForNewUpdate(addonUpdateInfos) if newUpdate is None: self.upToDateDialog(self.auto) return (version, url, minimumNVDAVersion, lastTestedNVDAVersion) = newUpdate if not checkCompatibility(self.addon.manifest["summary"], minimumNVDAVersion, lastTestedNVDAVersion, auto): return url = "{baseURL}/{url}/{addonName}-{version}.nvda-addon".format( baseURL=latestUpdateInfos["baseURL"], addonName=self.addon.manifest["name"], url=url, version=version) self.availableUpdateDialog(version, url)
def getKeyboardKeysIniFilePath(): from languageHandler import curLang langs = [ curLang, ] addonFolderPath = addonHandler.getCodeAddon().path lang = curLang if '_' in lang: langs.append(lang.split("_")[0]) langs.append("en") for lang in langs: if py3: # for python 3 langDir = os.path.join(addonFolderPath, "locale", lang) else: # for python 2 langDir = os.path.join(addonFolderPath, "locale", lang.encode("utf-8")) if os.path.exists(langDir): file = os.path.join(langDir, "keyboard.ini") if os.path.isfile(file): log.debugWarning( "keyboard.ini file loaded from locale\\%s folder" % lang) return file log.error("keyboard.ini file not found") return ""
def onInstall(): if (version_year, version_major) < (year, major): gui.messageBox(_( "This version of NVDA is incompatible. To install the add-on, NVDA version {year}.{major} or higher is required. Please update NVDA or download an older version of the add-on here: \n{link}" ).format( year=year, major=major, link="https://github.com/jawhien/extendedTotalCmd/releases/tag/2.5" ), _("Error"), style=wx.OK | wx.ICON_ERROR) raise RuntimeError("Incompatible NVDA version") manifest = addonHandler.getCodeAddon().manifest # Translators: The text of the dialog shown during add-on installation. message = _(""" {name} - this free add-on for NVDA. You can make a donation to the author to help further development of this add-on and other free software. You want to make a donation now? For transaction you will be redirected to the website of the developer.""" ).format(name=manifest['summary']) if gui.messageBox(message, caption=_("Request donations for {name}").format( name=manifest['summary']), style=wx.YES_NO | wx.ICON_QUESTION) == wx.YES: webbrowser.open(donations_url)
def __init__(self, duration, announce, ringCount, delayBetweenRings, delayBeforeEndDuration=None): # duration in seconds self.duration = int(duration * 60) # vocal announce to be spoken at the end of duration self.announce = announce # number of rings self.ringCount = ringCount # delay between ring self.delayBetweenRings = delayBetweenRings # delay before end duration in secondes self.delayBeforeEndDuration = delayBeforeEndDuration # ring sound file path = addonHandler.getCodeAddon().path self.ringFile = os.path.join(path, "sounds", "ringin.wav") if self.delayBeforeEndDuration is None: self.speakAnnounceTimer = wx.CallLater(int(1000 * self.duration), self.speakAnnounce) else: self.speakAnnounceTimer = wx.CallLater( int(1000 * (self.duration - int(60 * self.delayBeforeEndDuration))), self.speakAnnounceBeforeEnd) self.ringTimer = None self.startTime = int(time.time())
def _loadStringsDic(): global _stringsDics printDebug("vlc_strings: _loadStringsDic") if _stringsDics is not None: printDebug("_loadStringsDic: allready loaded") return # get label to identify vlc language label = _getRandomCheckButtonLabel() if label is None: printDebug("Random Check button is not found") return printDebug("_loadStringsDic: randomCheckButton description= %s" % label) printDebug("_loadStringsDic: search vlc language") # set path of strings ini files directory currAddon = addonHandler.getCodeAddon() stringsIniFilesDir = os.path.join(currAddon.path, _stringsIniFilesDirName) # get list of all strings ini files stringsIniFilesList = _getStringsIniFilesList(stringsIniFilesDir) # search for vlc language languageFound = False for file in stringsIniFilesList: stringsIniFile = os.path.join(stringsIniFilesDir, file) conf = loadFileConfig(stringsIniFile) if conf is None: continue if conf[SCTN_VLC][ID_RandomCheckButtonDescription] == label: # language found log.warning("VLCAccessEnhancement: VLC language found= %s" % conf[SCTN_Main][ID_LanguageName]) # noqa:E501 languageFound = True break if not languageFound: log.warning("_loadStringsDic: no language found") return _stringsDics = conf.copy() printDebug("_loadStringsDic: loaded")
def loadSettings(self): addonConfigFile = os.path.join(globalVars.appArgs.configPath, self.configFileName) configFileExists = False if os.path.exists(addonConfigFile): baseConfig = BaseAddonConfiguration(addonConfigFile) if baseConfig[SCT_General][ ID_ConfigVersion] != self._currentConfigVersion: # old config file must not exist here. Must be deleted os.remove(addonConfigFile) log.warning("%s: Previous config file removed : %s" % (_addonName, addonConfigFile)) # noqa:E501 else: configFileExists = True self.addonConfig = self._versionToConfiguration[ self._currentConfigVersion](addonConfigFile) # noqa:E501 if self.addonConfig.errors != []: log.warning("%s: Addon configuration file error" % _addonName) self.addonConfig = None return curPath = addonHandler.getCodeAddon().path oldConfigFile = os.path.join(curPath, self.configFileName) if os.path.exists(oldConfigFile): if not configFileExists: self.mergeSettings(oldConfigFile) os.remove(oldConfigFile) if not configFileExists: self.saveSettings(True) self.restorePreviousAutoReadingSynth()
def loadSettings(self): addonConfigFile = os.path.join(globalVars.appArgs.configPath, self.configFileName) configFileExists = False if os.path.exists(addonConfigFile): baseConfig = BaseAddonConfiguration(addonConfigFile) if baseConfig[SCT_General][ID_ConfigVersion] != self._currentConfigVersion : # old config file must not exist here. Must be deleted os.remove(addonConfigFile) log.warning(" Old config file removed") else: configFileExists = True self.addonConfig = self._versionToConfiguration[self._currentConfigVersion](addonConfigFile) if self.addonConfig.errors != []: log.warning("Addon configuration file error") self.addonConfig = None return curPath = addonHandler.getCodeAddon().path oldConfigFileName = "addonConfig_old.ini" oldConfigFile = os.path.join(curPath, oldConfigFileName) if os.path.exists(oldConfigFile): if not configFileExists: self.mergeSettings(oldConfigFile) self.saveSettings() os.remove(oldConfigFile) if not configFileExists: self.saveSettings()
def onInstall(): manifest = addonHandler.getCodeAddon().manifest message = _(""" {name} is a free add-on for NVDA. You can make a donation to its author to support further developments of this add-on and other free software products. Do you want to donate now? (you will be redirected to the Paypal website).""").format(**manifest) if gui.messageBox(message, caption=_("Request for Contributions to {name}").format(name=manifest['name']), style=wx.YES_NO|wx.ICON_QUESTION) == wx.YES: webbrowser.open(DONATIONS_URL)
def __init__(self, addon=None): printDebug("VLCSettings __init__") self.addon = addon if addon else addonHandler.getCodeAddon() self.addonDir = self.addon.path self.vlcSettingsDir = self.getVlcSettingsFolderPath() if self.vlcInitialized: printDebug("VLCSettings: VLC initialized") else: printDebug("VLCSettings: VLC not initialized")
def __init__(self, ringCount=3, delayBetweenRings=2, ringWavFile=None): threading.Thread.__init__(self) self.ringCount = ringCount self.delayBetweenRings = delayBetweenRings self.ringWavFile = ringWavFile if self.ringWavFile is None: path = addonHandler.getCodeAddon().path self.ringWavFile = os.path.join(path, "sounds", "ringin.wav") self._stopevent = threading.Event()
def getAddonPath(addon=None): if addon is None: addon = addonHandler.getCodeAddon() if sys.version.startswith("3"): # for python 3 addonPath = addon.path else: # for python 2 addonPath = addon.path.encode("mbcs") return addonPath
def get_stringsIniFilePath(appLanguage): if appLanguage == "": return None _addonDir = addonHandler.getCodeAddon().path file = os.path.join(_addonDir, _stringsIniFilesDirName, _stringsFileBaseName + str(appLanguage) + ".ini") if not os.path.exists(file): log.error("No strings Ini file: {}".format(file)) return None return file
def __init__(self): global _addonConfigManager self.curAddon = addonHandler.getCodeAddon() self.addonName = self.curAddon.manifest["name"] from keyLabels import localizedKeyLabels self.basicLocalizedKeyLabels = localizedKeyLabels.copy() self.restoreAddonProfilesConfig(self.addonName) self.loadSettings() self.setIsTestVersionFlag() config.post_configSave.register(self.handlePostConfigSave)
def __init__(self, parent, informationLabel="", information=""): if InformationDialog._instance is not None: return InformationDialog._instance = self curAddon = addonHandler.getCodeAddon() summary = curAddon.manifest['summary'] title = self.title % summary super(InformationDialog, self).__init__(parent, wx.ID_ANY, title) self.informationLabel = informationLabel self.information = information self.doGui()
def onSeeHistory(self, evt): addon = addonHandler.getCodeAddon() from languageHandler import curLang theFile = os.path.join(addon.path, "doc", curLang, "changes.html") if not os.path.exists(theFile): lang = curLang.split("_")[0] theFile = os.path.join(addon.path, "doc", lang, "changes.html") if not os.path.exists(theFile): lang = "en" theFile = os.path.join(addon.path, "doc", lang, "changes.html") os.startfile(theFile)
def __init__(self): curAddon = addonHandler.getCodeAddon() self.addonDir = curAddon.path localeSettingsFile = self.getLocaleSettingsIniFilePath() if localeSettingsFile is None: printDebug("LocaleSettings __init__ :Default config") self.conf = None else: self.conf = ConfigObj(localeSettingsFile, encoding="utf-8", list_values=False) self.loadScriptGestures()
def _makeHTML(addon, lang): # Translators: title of dialog dialogTitle = _("Creation of HTML documentation files") if "doc" not in os.listdir(addon.path): gui.messageBox( # Translators: message to user no doc folder _("No documentation file to convert"), dialogTitle, wx.OK | wx.ICON_ERROR) return docFolder = os.path.join(addon.path, "doc") dirList = getDocLanguages(addon) docDirs = [] if lang == "all": for item in dirList: theDir = os.path.join(docFolder, item) docDirs.append(theDir) else: for item in dirList: if (item == lang or "_" in item and item.split("_")[0] == lang): theDir = os.path.join(docFolder, item) docDirs.append(theDir) (mdCount, t2tCount) = generateHTMLFiles(addon, docDirs) n = mdCount+t2tCount if n == 0: gui.messageBox( # Translators: message to user no converted document _("No html file converted"), dialogTitle, wx.OK) else: # copy css style file curAddon = addonHandler.getCodeAddon() if mdCount: source = os.path.join(curAddon.path, "doc", "style_md.css") dest = os.path.join(docFolder, "style_md.css") try: shutil.copy(source, dest) except: # noqa:E722 pass elif t2tCount: source = os.path.join(curAddon.path, "doc", "style_t2t.css") dest = os.path.join(docFolder, "style_t2t.css") try: shutil.copy(source, dest) except: # noqa:E722 pass gui.messageBox( # Translators: message to user to report number of converted documents _("%s files converted") % n, dialogTitle, wx.OK) # clean up clean(addon)
def getSymbolCategoriesDicPath(self): userFile = self.getUserSymbolCategoriesFile(getLanguage()) if userFile is not None: return userFile localeList = [getLanguage()] if '_' in getLanguage(): localeList.append(getLanguage().split('_')[0]) localeList.append("en") addonFolderPath = addonHandler.getCodeAddon().path fileName = ".".join(symbolCategoriesFile) for locale in localeList: file = os.path.join(addonFolderPath, "locale", locale, fileName) if os.path.isfile(file): return file return None
def initialize(): global _state, _stateFilename addonPath = addonHandler.getCodeAddon().path _stateFilename = os.path.join(addonPath, "updateCheckState.pickle") try: # 9038: Python 3 requires binary format when working with pickles. with open(_stateFilename, "rb") as f: _state = pickle.load(f) except: # noqa:E722 log.debugWarning("update state file don't exist: initialization with default values", exc_info=False) # noqa:E501 # Defaults. _state = { "lastCheck": 0, "remindUpdate": False, }
def restorePreviousAutoReadingSynth(self): curPath = addonHandler.getCodeAddon().path previousFile = os.path.join(curPath, self.autoReadingSynthFileName) path = globalVars.appArgs.configPath if os.path.exists(previousFile): # move it to user config folder import shutil try: path = globalVars.appArgs.configPath shutil.copy(previousFile, path) os.remove(previousFile) log.warning("%s file copied in %s and deleted" % (path, previousFile)) except: # noqa:E722 log.warning("Error: %s file cannot be move to %s " % (previousFile, path))
def getTextAnalysisIniFilePath(): from languageHandler import getLanguage lang = getLanguage() langs = [lang, ] addonFolderPath = addonHandler.getCodeAddon().path if '_' in lang: langs.append(lang.split("_")[0]) langs.append("en") for lang in langs: langDir = os.path.join(addonFolderPath, "locale", lang) if os.path.exists(langDir): file = os.path.join(langDir, "textAnalysis.ini") if os.path.isfile(file): log.debugWarning("textAnalyzis.ini file loaded from locale\\%s folder" % lang) return file log.error("textAnalysis.ini file not found") return ""
def getSupportedLanguages(): printDebug("getSupportedLanguages") # set path of strings ini files directory currAddon = addonHandler.getCodeAddon() stringsIniFilesDir = os.path.join(currAddon.path, _stringsIniFilesDirName) # get list of all strings ini files stringsIniFilesList = _getStringsIniFilesList(stringsIniFilesDir) # search for vlc language supportedLanguages = [] for file in stringsIniFilesList: stringsIniFile = os.path.join(stringsIniFilesDir, file) conf = loadFileConfig(stringsIniFile) if conf is None: continue lang1 = conf[SCTN_Main]["LanguageName"] temp = file.split("-")[-1] lang2 = temp.split(".")[0] supportedLanguages.append((lang1, lang2)) return supportedLanguages
def getQualifiedDriverClassNameForStats(cls): """ fetches the name from a given synthDriver or brailleDisplay class, and appends core for in-built code, the add-on name for code from an add-on, or external for code in the NVDA user profile. Some examples: espeak (core) newfon (external) eloquence (addon:CodeFactory) noBraille (core) """ name = cls.name try: addon = getCodeAddon(cls) except AddonError: addon = None if addon: return "%s (addon:%s)" % (name, addon.name) path = inspect.getsourcefile(cls) if isPathExternalToNVDA(path): return "%s (external)" % name return "%s (core)" % name
def toGetUpdate(self, evt): version = addonHandler.getCodeAddon().manifest["version"] h = "iuuqt;00bqj/hjuivc/dpn0sfqpt0Disjtujbomn0rvjdlmzSfbdiWpdbcvmbsz0sfmfbtft0mbuftu" req = Request("".join(map(lambda x: chr(ord(x) - 1), h))) res = urlopen(req) results = {} results.update(json.load(res)) res.close() ASSETS = results.get("assets") browserDownloadUrl = ASSETS[0].get("browser_download_url") remoteVersion = re.search( "(?P<name>)-(?P<version>.*).nvda-addon", browserDownloadUrl.split("/")[-1]).groupdict()["version"] if remoteVersion != version: wx.CallAfter(self.onCheckUpdatesDialog, None) else: ui.browseableMessage( _("The current version {ver} is the latest.").format( ver=version), _("qrVocabulary is up to date!"))
def getQualifiedDriverClassNameForStats(cls): """ fetches the name from a given synthDriver or brailleDisplay class, and appends core for in-built code, the add-on name for code from an add-on, or external for code in the NVDA user profile. Some examples: espeak (core) newfon (external) eloquence (addon:CodeFactory) noBraille (core) """ name=cls.name try: addon=getCodeAddon(cls) except AddonError: addon=None if addon: return "%s (addon:%s)"%(name,addon.name) path=inspect.getsourcefile(cls) if isPathExternalToNVDA(path): return "%s (external)"%name return "%s (core)"%name
class EmuleRowWithFakeNavigation(RowWithFakeNavigation): scriptCategory = addonHandler.getCodeAddon().manifest["summary"] def initOverlayClass(self): modifiers = ("control", "shift") for n in range(10): for modifier in modifiers: gesture = "kb:NVDA+{mod}+{num}".format(mod=modifier, num=n) self.bindGesture(gesture, "readColumn") self.bindGesture("kb:NVDA+shift+c", "copyColumn") @script( # Translators: Message presented in input help mode. description=_("Reads the specified column for the current list item.") ) def script_readColumn(self, gesture): col = int(gesture.mainKeyName[-1]) if col == 0: col += 10 if "shift" in gesture.modifierNames: col += 10 self._moveToColumnNumber(col) @script( # Translators: Message presented in input help mode. description=_("Copies the last read column of the selected list item to clipboard.") ) def script_copyColumn(self, gesture): try: col = api.getNavigatorObject().columnNumber except NotImplementedError: pass try: header = self._getColumnHeader(col) subitem = self._getColumnContent(col) column = ": ".join([header, subitem]) except Exception: return if api.copyToClip(column): # Translators: Message presented when the current column of the list item is copied to clipboard. ui.message(_("%s copied to clipboard") % column)
def getSymbolCategoriesDicPath(self): userFile = self.getUserSymbolCategoriesFile(curLang) if userFile is not None: return userFile localeList = [curLang] if '_' in curLang: localeList.append(curLang.split('_')[0]) localeList.append("en") addonFolderPath = addonHandler.getCodeAddon().path fileName = ".".join(symbolCategoriesFile) for locale in localeList: if py3: # for python 3 file = os.path.join(addonFolderPath, "locale", locale, fileName) else: # for python 2 file = os.path.join(addonFolderPath, "locale", locale.encode("utf-8"), fileName) if os.path.isfile(file): return file return None
def reportAnalysis(count, textList, description=False): if len(textList) == 0: return if description: ui.message(", ".join(textList)) elif _NVDAConfigManager.reportByBeep(): (freq, length) = _NVDAConfigManager.getBeepFrequencyAndLength() tones.beep(freq, length) elif _NVDAConfigManager.reportBySound(): fileName = _NVDAConfigManager.getSoundFileName() path = addonHandler.getCodeAddon().path file = os.path.join(path, "sounds", "text analyzer alerts", fileName) nvwave.playWaveFile(file) elif _NVDAConfigManager.reportByAlertMessage(): msg = _NVDAConfigManager.getAlertMessage() if msg == "": # Translators: default alert message when text analyzer detect something. msg = _("Alert") ui.message(msg) elif _NVDAConfigManager.reportByNumber(): ui.message(_("%s analyzis's detections") % count) else: ui.message(", ".join(textList))
def makeAddonWindowTitle(dialogTitle): curAddon = addonHandler.getCodeAddon() addonSummary = curAddon.manifest['summary'] return "%s - %s" % (addonSummary, dialogTitle)
# -*- coding: utf-8 -*- # Clock Add-on for NVDA # Author: Hrvoje Katich # Copyright 2013-2018, released under GPL. import os import glob import addonHandler PLUGIN_DIR = os.path.join(addonHandler.getCodeAddon().path, "globalPlugins", "clock") SOUNDS_DIR = os.path.join(PLUGIN_DIR, "waves") LIST_SOUNDS = [ os.path.split(path)[-1] for path in glob.glob(os.path.join(SOUNDS_DIR, '*.wav')) ] ALARMS_DIR = os.path.join(PLUGIN_DIR, "alarms") LIST_ALARMS = [ os.path.split(path)[-1] for path in glob.glob(os.path.join(ALARMS_DIR, '*.wav')) ]
# -*- coding: UTF-8 -*- # NVDA Dev & Test Toolbox add-on for NVDA # Copyright (C) 2020-2021 Cyrille Bougot # This file is covered by the GNU General Public License. from types import MethodType import globalPluginHandler import addonHandler import scriptHandler from scriptHandler import script import inputCore import ui ADDON_SUMMARY = addonHandler.getCodeAddon ().manifest["summary"] SCRIPT_WITHOUT_DESC_CATEGORY = _("Scripts without description (modify at your own risk!)") _originalMethod = inputCore.manager._handleInputHelp def newHandleInputHelp(self, gesture, onlyLog=False): script = gesture.script scriptName = scriptHandler.getScriptName(script) if script else '' addDesc = ( # The script must exist script # And the script must not be input help script and scriptName != "toggleInputHelp" # And the script must not have already a description. and not getattr(script, '__doc__', None) )
import ui import speech import sayAllHandler from scriptHandler import willSayAllResume, script from cursorManager import CursorManager from logHandler import log from .skipTranslation import translate addonHandler.initTranslation() ### Constants PLACE_MARKERS_PATH = os.path.join(os.path.dirname(__file__), "savedPlaceMarkers").decode("mbcs") SEARCH_FOLDER = os.path.join(PLACE_MARKERS_PATH, "search") BOOKMARKS_FOLDER = os.path.join(PLACE_MARKERS_PATH, "bookmarks") CONFIG_PATH = globalVars.appArgs.configPath ADDON_SUMMARY = addonHandler.getCodeAddon().manifest["summary"] def createSearchFolder(): if os.path.isdir(SEARCH_FOLDER): return try: os.makedirs(SEARCH_FOLDER) except Exception as e: log.debugWarning("Error creating search folder", exc_info=True) raise e def createBookmarksFolder(): if os.path.isdir(BOOKMARKS_FOLDER): return try: os.makedirs(BOOKMARKS_FOLDER)