__init__.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:dictationbridge-nvda 作者: dictationbridge 项目源码 文件源码
def _onInstallDragonCommands():
    si = subprocess.STARTUPINFO()
    si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    si.wShowWindow = subprocess.SW_HIDE
    dragonDir = r"C:\Program Files (x86)\Nuance\NaturallySpeaking15\Program"
    #Translators: Title of an error dialog shown in dictation bridge.
    DB_ERROR_TITLE = _("Dictation Bridge Error")
    if not os.path.exists(dragonDir):
        dragonDir.replace(r" (x86)", "")
    if not os.path.exists(dragonDir):
        #Translators: Message given to the user when the addon can't find an installed copy of dragon.
        gui.messageBox(_("Cannot find dragon installed on your machine. Please install dragon and then try this process again."),
            DB_ERROR_TITLE)
        return
    xml2dat = os.path.join(dragonDir, "mycmdsxml2dat.exe")
    nsadmin = os.path.join(dragonDir, "nsadmin.exe")

    #Translators: The official name of Dragon in your language, this probably should be left as Dragon.
    thisProgram = _("Dragon")
    if os.path.exists(os.path.join(addonRootDir, "dragon_dictationBridgeCommands.dat")):
            os.remove(os.path.join(addonRootDir, "dragon_dictationBridgeCommands.dat"))
    try:
        subprocess.check_call([
            xml2dat,
            os.path.join(addonRootDir, "dragon_dictationBridgeCommands.dat"),
            os.path.join(addonRootDir, "dragon_dictationBridgeCommands.xml"),
            ], startupinfo=si)
        #Fixme: might need to get the users language, and put them there for non-english locales.
        d=config.execElevated(nsadmin,
            ["/commands", os.path.join(addonRootDir, "dragon_dictationBridgeCommands.dat"), "/overwrite=yes"],
            wait=True, handleAlreadyElevated=True)

        successDialog(thisProgram)
    except:
        #Translators: Message shown if dragon commands failed to install.
        gui.messageBox(_("There was an error while performing the addition of dragon commands into dragon. Are you running as an administrator? If so, please send the error in your log to the dictation bridge team as a bug report."),
            DB_ERROR_TITLE)
        raise
    finally:
        if os.path.exists(os.path.join(addonRootDir, "dragon_dictationBridgeCommands.dat")):
            os.remove(os.path.join(addonRootDir, "dragon_dictationBridgeCommands.dat"))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号