Natlinkstatus

The natlinkstatus module keeps the status information of natlink

natlinkstatus module

Normal use:

` from natlinkcore import natlinkstatus ... status = natlinkstatus.NatlinkStatus() `

Then the following functions (methods) can be called:

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.

This directory is normally in the site-packages area of Python (name “unimacro”), but can be “linked” to your cloned source code when you installed the packages with “pip install -e .”

getUnimacroGrammarsDirectory: * removed *

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

the Unimacro user directory

getUnimacroDataDirectory: get the directory where Unimacro grammars can store data, this should be per computer, and is set

into the natlink_settingsdir area

getUnimacroGrammarsDirectory: get the directory where Unimacro grammars are (by default) located in the python site-packagers directory ‘unimacro’

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_SETTINGSDIR%/.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

dragonflyIsEnabled()[source]

dragonflyIsEnabled: return True if DragonflyDirectory and DragonflyUserDirectory are there

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

getDragonflyDirectory()[source]

return the path to the DragonflyDirectory

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

getDragonflyUserDirectory()[source]

return the path to the Dragonfly User directory

Dragonfly users can also choose for UserDirectory.

getDtactionsDirectory()[source]

dtactions directory should be found with an import (like getUnimacroDirectory)

getExtraGrammarDirectories()[source]

record grammar directories that are unknown to natlinkstatus and natlinkconfigfunctions

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

getLogging()[source]

Retuns the natlink logging output

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_SETTINGSDIR to for example ~/Documents/.natlink.

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

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).

getUnimacroDataDirectory()[source]

return the path to the directory where grammars can store data.

Expected in “UnimacroData” of the natlink user directory (November 2022)

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 UnimacroGrammarDirectory

This is the directory UnimacroGrammars below the unimacro directory (most in site-packages) is normally got via pip install unimacro

Can be changed manually in “natlink.ini” as “unimacrogrammarsdirectory = dir-of-your-choice”. (section: [unimacro])

Note: unimacro grammars can also be put into other “[directories]” in your natlink.ini file.

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

getdragonflydirectory()

return the path to the DragonflyDirectory

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

getdragonflyuserdirectory()

return the path to the Dragonfly User directory

Dragonfly users can also choose for UserDirectory.

getdtactionsdirectory()

dtactions directory should be found with an import (like getUnimacroDirectory)

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

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

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

getnatlinkcoredirectory()

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

getnatlinkdirectory()

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

getnatlinkini()

return the path of the natlink.ini file

getunimacrodatadirectory()

return the path to the directory where grammars can store data.

Expected in “UnimacroData” of the natlink user directory (November 2022)

getunimacrodirectory()

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()

return the path to the UnimacroGrammarDirectory

This is the directory UnimacroGrammars below the unimacro directory (most in site-packages) is normally got via pip install unimacro

Can be changed manually in “natlink.ini” as “unimacrogrammarsdirectory = dir-of-your-choice”. (section: [unimacro])

Note: unimacro grammars can also be put into other “[directories]” in your natlink.ini file.

getuserdirectory()

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()

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 “”

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

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’