Skip to content

Commit

Permalink
* avoid importing add-on modules on installTasks.py, this should fix #85
Browse files Browse the repository at this point in the history
.

* now the availability of the libraries should be detected properly during add-on installation.
* small correction on _settingsDB.py
  • Loading branch information
davidacm committed Jun 30, 2023
1 parent 9f13012 commit b37190d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
32 changes: 21 additions & 11 deletions addon/installTasks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# -*- coding: UTF-8 -*-
#Copyright (C) 2009 - 2019 David CM, released under the GPL.
# Author: David CM <[email protected]> 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()


Expand All @@ -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
)
3 changes: 1 addition & 2 deletions addon/synthDrivers/_settingsDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit b37190d

Please sign in to comment.