natlinkstatus

The natlinkstatus module keeps the status information of natlink

natlinkstatus module

The following functions are provided in this module:

The functions below are put into the class NatlinkStatus.

The functions below should not change anything in settings, only get information.

getDNSInstallDir:

removed, not needed any more

getDNSIniDir:

returns the directory where the NatSpeak INI files are located, notably nssystem.ini and nsapps.ini. Got from loader.

getDNSVersion:

returns the in the version number of NatSpeak, as an integer. So …, 13, 15, … no distinction is made here between different subversions. got indirectly from loader

getWindowsVersion:

see source below

get_language:

returns the 3 letter code of the language of the speech profile that is open: ‘enx’, ‘nld’, “fra”, “deu”, “ita”, “esp”

get it from loader (property), is updated when user profile changes (on_change_callback) returns ‘enx’ when Dragon is not running.

get_profile, get_user:

returns the directory of the current user profile information and returns the name of the current user This information is collected from natlink.getCurrentUser(), or from the args in on_change_callback, with type == ‘user’

get_load_on_begin_utterance and set_load_on_begin_utterance:

returns value of this property of the natlinkmain (loader) instance. True or False, or a (small) positive int, decreasing each utterance.

or explicitly set this property.

getPythonVersion:

return two character version, so without the dot! eg ‘38’,

Note, no indication of 32 bit version, so no ‘38-32’

getUserDirectory: get the Natlink user directory,

Especially Dragonfly users will use this directory for putting their grammar files in. Also users that have their own custom grammar files can use this user directory

getUnimacroDirectory: get the directory where the Unimacro system is.

When git cloned, relative to the Core directory, otherwise somewhere or in the site-packages (if pipped). This grammar will (and should) hold the _control.py grammar and needs to be included in the load directories list of James’ natlinkmain

getUnimacroGrammarsDirectory: get the directory, where the user can put his Unimacro grammars. This directory will be

located in the ActiveGrammars subdirectory of the ~/.unimacro’ or `%NATLINK_USERDIR%/.unimacro).

getUnimacroUserDirectory: get the directory of Unimacro INI files, if not return ‘’ or

the Unimacro user directory

getVocolaDirectory: get the directory where the Vocola system is. When cloned from git, in Vocola, relative to

the Core directory. Otherwise (when pipped) in some site-packages directory. It holds (and should hold) the grammar _vocola_main.py.

getVocolaUserDirectory: get the directory of Vocola User files, if not return ‘’
(if run from natlinkconfigfunctions use getVocolaDirectoryFromIni, which checks inifile

at each call…)

getVocolaGrammarsDirectory: get the directory, where the compiled Vocola grammars are/will be.

This will be the CompiledGrammars subdirectory of ~/.vocolaGrammars or %NATLINK_USERDIR%/.vocola.

getVocolaTakesLanguages: additional settings for Vocola

new 2014/2022 getDNSName: return “NatSpeak” for versions <= 11 and “Dragon” for 12 (on) (obsolete in 2022) getAhkExeDir: return the directory where AutoHotkey is found (only needed when not in default) getAhkUserDir: return User Directory of AutoHotkey, not needed when it is in default. get_language and other properties, see above.

class NatlinkStatus(*args, **kwargs)[source]

this class holds the Natlink status functions.

This class is a Singleton, which means that all instances are the same object.

Some information is retrieved from the loader, the natlinkmain (Singleton) instance.

In natlinkconfigfunctions.py, NatlinkStatus is subclassed for configuration purposes. in the PyTest folder there are/come test functions in TestNatlinkStatus

UnimacroIsEnabled()[source]

UnimacroIsEnabled: see if UnimacroDirectory and UnimacroUserDirectory are there

_control.py should be in the UnimacroDirectory.

VocolaIsEnabled()[source]

Return True if Vocola is enables

To be so, 1. the VocolaUserDirectory (where the vocola command files (.vcl) are located) should be defined in the user config file 2. the VocolaDirectory should be found, and hold ‘_vocola_main.py’

getDNSIniDir()[source]

get the path (one above the users profile paths) where the INI files should be located

static getDNSName()[source]

return NatSpeak for versions <= 11, and Dragon for versions >= 12

getDNSVersion()[source]

find the correct DNS version number (as an integer)

2022: extract from the dragonIniDir setting in the registry, via loader function

getDragonflyUserDirectory()[source]

return the path to the Dragonfly User directory

Dragonfly users can also choose for UserDirectory.

getExtraGrammarDirectories()[source]

record grammar directories that are unknown to natlinkstatus and natlinkconfigfunctions

These directories can be entered “manually” in the natlink.ini file

getNatlinkDirectory()[source]

return the path of the NatlinkDirectory, where the _natlink_core.pyd package (C++ code) is

getNatlinkIni()[source]

return the path of the natlink.ini file

getNatlinkStatusDict()[source]

return actual status in a dict

Most values come via properties…

get the directory where “natlink.ini” should be stored

This must be a local directory, default ~, but can be changed by setting NATLINK_USERDIR to for example ~/Documents.

Other directories that are created and checked by packages, and should be local, can be stored here, for example VocolaGrammarsDirectory (VocolaGrammars) and UnimacroGrammarsDirectory (UnimacroGrammars).

getNatlinkcoreDirectory()[source]

return the path of the natlinkcore package directory, same as thisDir!

getPythonVersion()[source]

get the version of python

Check if the version is supported on the “lower” side.

length 2, without “.”, so “38” etc.

getShiftKey()[source]

return the shiftkey, for setting in natlinkmain when user language changes.

used for self.playString in natlinkutils, for the dropping character bug. (dec 2015, QH).

getUnimacroDirectory()[source]

return the path to the UnimacroDirectory

This is the directory where the _control.py grammar is, and is normally got via pip install unimacro

getUnimacroGrammarsDirectory()[source]

return the path to the directory where the ActiveGrammars of Unimacro are located.

Expected in “UnimacroGrammars” of the natlink user directory (May 2022)

getUserDirectory()[source]

return the path to the Natlink User directory

this one is not any more for Unimacro, but for User specified grammars, also Dragonfly

should be set in configurenatlink, otherwise ignore…

getVocolaGrammarsDirectory()[source]

return the VocolaGrammarsDirectory, but only if Vocola is enabled

If so, the subdirectory VocolaGrammars is created if not there yet.

The path of this “VocolaGrammars” directory is returned.

If Vocola is not enabled, or anything goes wrong, return “”

getVocolaTakesLanguages()[source]

gets and value for distinction of different languages in Vocola If Vocola is not enabled, this option will also return False

getVocolaTakesUnimacroActions()[source]

gets and value for optional Vocola takes Unimacro actions If Vocola is not enabled, this option will also return False

static getWindowsVersion()[source]

extract the windows version

return 1 of the predefined values above, or just return what the system call returns

property load_on_begin_utterance: Any

inspect current value of this loader setting

refresh()[source]

rerun the __init__, refreshing all variables

This should be done only from the natlinkconfigfunctions.py, in the configure phase of Natlink