Skip to content

Commit c2a60c3

Browse files
committed
updated the installTasks to avoid delete internal libraries inside synthDrivers/ibmtts when reinstalling the add-on
1 parent c0efb5f commit c2a60c3

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

addon/installTasks.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,37 @@
22
#Copyright (C) 2009 - 2019 David CM, released under the GPL.
33
# Author: David CM <[email protected]> and others.
44
# note: this file doesn't get settings from the base profile to avoid issues when updating from older versions.
5-
6-
from synthDrivers._settingsDB import appConfig
7-
import gui, os, wx, addonHandler
5+
from logHandler import log
6+
from synthDrivers._settingsDB import appConfig, DEFAULT_LIB_FOLDER
7+
import globalVars, gui, os, shutil, wx, addonHandler
88
addonHandler.initTranslation()
99

10+
11+
def preserveFiles(addonName, folder):
12+
"""
13+
addonName: the name (identifier) of the addon
14+
folder: a path for a folder inside the addonName directory.
15+
"""
16+
absFolderPath = os.path.abspath(os.path.join(globalVars.appArgs.configPath, "addons", addonName, folder))
17+
tempFolder = os.path.abspath(os.path.join(globalVars.appArgs.configPath, "addons", addonName + addonHandler.ADDON_PENDINGINSTALL_SUFFIX, folder))
18+
if os.path.isdir(absFolderPath):
19+
if os.path.isdir(tempFolder):
20+
shutil.rmtree(tempFolder)
21+
os.rename(absFolderPath, tempFolder)
22+
1023
msg=""
1124
if not os.path.exists(os.path.join(os.path.dirname(__file__), 'synthDrivers', appConfig.TTSPath, appConfig.dllName)):
1225
# Translators: the message shown if the driver can't find libraries during installation.
1326
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.
1427
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""")
1528

16-
# Translators: message box when user is installing the addon in NVDA.
17-
#msg += _("""if you are using another copy of IBMTTS or similar with a different name, you should not load this driver in the same NVDA session. If you do it, NVDA will fail.
18-
#To resolve it switch to another synthesizer (E.G espeak) then restart NVDA. Afther that, you can use this new driver.""")
1929

2030
def onInstall():
21-
if msg!="":
31+
try:
32+
preserveFiles("IBMTTS", fr"synthDrivers\{DEFAULT_LIB_FOLDER}")
33+
except:
34+
log.warning("error backing data", exc_info=True)
35+
if msg != "":
2236
gui.messageBox(msg,
2337
# Translators: title of message box when user is installing NVDA
2438
_("IBMTTS driver for NVDA"), wx.OK)

addon/synthDrivers/_settingsDB.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
#synthDrivers/settingsDB.py
55

66
from ._configHelper import configSpec, registerConfig, boolValidator
7+
DEFAULT_LIB_FOLDER = 'ibmtts'
78

89
# Add-on config database
910
@configSpec("ibmeci")
1011
class _AppConfig:
1112
dllName = ("string(default='eci.dll')", True)
12-
TTSPath = ("string(default='ibmtts')", True)
13+
TTSPath = ("string(default=DEFAULT_LIB_FOLDER)", True)
1314
autoUpdate = ('boolean(default=True)', True, boolValidator)
1415
appConfig = registerConfig(_AppConfig)
1516

0 commit comments

Comments
 (0)