From b37190dc85c4bc700a7037e0fca40e701d7ed22e Mon Sep 17 00:00:00 2001 From: davidacm Date: Thu, 29 Jun 2023 19:06:29 -0600 Subject: [PATCH] * avoid importing add-on modules on installTasks.py, this should fix #85. * now the availability of the libraries should be detected properly during add-on installation. * small correction on _settingsDB.py --- addon/installTasks.py | 32 ++++++++++++++++++++----------- addon/synthDrivers/_settingsDB.py | 3 +-- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/addon/installTasks.py b/addon/installTasks.py index 23118d7..e81f20d 100644 --- a/addon/installTasks.py +++ b/addon/installTasks.py @@ -1,10 +1,13 @@ # -*- coding: UTF-8 -*- #Copyright (C) 2009 - 2019 David CM, released under the GPL. # Author: David CM and others. + # note: this file doesn't get settings from the base profile to avoid issues when updating from older versions. + from logHandler import log -from synthDrivers._settingsDB import appConfig, DEFAULT_LIB_FOLDER -import globalVars, gui, os, shutil, wx, addonHandler + +import config, globalVars, gui, os, shutil, wx, addonHandler + addonHandler.initTranslation() @@ -20,19 +23,26 @@ def preserveFiles(addonName, folder): shutil.rmtree(tempFolder) os.rename(absFolderPath, tempFolder) -msg="" -if not os.path.exists(os.path.join(os.path.dirname(__file__), 'synthDrivers', appConfig.TTSPath, appConfig.dllName)): - # Translators: the message shown if the driver can't find libraries during installation. - msg = _("""The synthesizer won't be available until you set IBMTTS files. NVDA won't show this synthesizer in teh synthesizers lists because you need to set the IBMTTS files location first. - To do it open the NVDA settings dialog, select IBMTTS category and use the "Browse for IBMTTS library" button to select the IBMTTS files folder.\n""") +try: + TTSPath = config.conf['ibmeci']['TTSPath'] + dllName = config.conf['ibmeci']['dllName'] +except: + TTSPath = "ibmtts" + dllName = "eci.dll" def onInstall(): try: - preserveFiles("IBMTTS", fr"synthDrivers\{DEFAULT_LIB_FOLDER}") + preserveFiles("IBMTTS", r"synthDrivers\ibmtts") except: log.warning("error backing data", exc_info=True) - if msg != "": - gui.messageBox(msg, + + if not os.path.exists(os.path.join(os.path.dirname(__file__), 'synthDrivers', TTSPath, dllName)): + # Translators: the message shown if the driver can't find libraries during installation. + msg = _("""The synthesizer won't be available until you set IBMTTS files. NVDA won't show this synthesizer in teh synthesizers lists because you need to set the IBMTTS files location first. + To do it open the NVDA settings dialog, select IBMTTS category and use the "Browse for IBMTTS library" button to select the IBMTTS files folder.\n""") + gui.messageBox( + msg, # Translators: title of message box when user is installing NVDA - _("IBMTTS driver for NVDA"), wx.OK) + _("IBMTTS driver for NVDA"), wx.OK + ) diff --git a/addon/synthDrivers/_settingsDB.py b/addon/synthDrivers/_settingsDB.py index be04f2b..6d4b7f8 100644 --- a/addon/synthDrivers/_settingsDB.py +++ b/addon/synthDrivers/_settingsDB.py @@ -4,13 +4,12 @@ #synthDrivers/settingsDB.py from ._configHelper import configSpec, registerConfig, boolValidator -DEFAULT_LIB_FOLDER = 'ibmtts' # Add-on config database @configSpec("ibmeci") class _AppConfig: dllName = ("string(default='eci.dll')", True) - TTSPath = ("string(default=DEFAULT_LIB_FOLDER)", True) + TTSPath = ("string(default='ibmtts')", True) autoUpdate = ('boolean(default=True)', True, boolValidator) appConfig = registerConfig(_AppConfig)