Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dr16issues, starting to solve several issues that arose with Dragon 16 #70

Merged
merged 25 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a0ad16f
was lost in the flow, reentered from natlinkcore repository
quintijn Feb 2, 2024
cf994d4
entered getUnimacroGrammarsDirectory, and a lot of tidying up
quintijn Feb 2, 2024
eb6845c
multiple changes in natlinkstatus.py and natlinkconfigfunctions.py, l…
quintijn Feb 3, 2024
74f2554
add 2 tests execscriptest.py is ok, buttonclicktest.py fails. The cau…
quintijn Feb 3, 2024
3cfc5ce
the buttonclicktest.py shows the bug when natlink.playEvents is called.
quintijn Feb 4, 2024
2bf1f67
also enter dragonfly (dragonfly2) in the config procedure, including …
quintijn Feb 6, 2024
9b21667
add a few changes to nsformat.py (a\\determiner and I\\pronoun
quintijn Feb 8, 2024
10de328
small change in nsformat.py (formatPassword)
quintijn Feb 8, 2024
4cf7806
use pythong logging module to report output of pip etc.
dougransom Feb 17, 2024
15f8045
command line uses logging.
dougransom Feb 17, 2024
c53e016
logging to cli.
dougransom Feb 17, 2024
9932390
Merge branch 'dr16issues' of https://github.com/dougransom/natlinkcor…
dougransom Feb 17, 2024
761393e
tweak.
dougransom Feb 17, 2024
981733c
a few documentation details...
quintijn Feb 21, 2024
99b196a
try to catch an error when unloading a grammar, when it is not (corre…
quintijn Feb 21, 2024
c94dfe0
adapt load_or_reload_module function with force_load, so it works fro…
quintijn Feb 21, 2024
46d3213
Merge branch 'dr16issues' of github.com:dougransom/natlinkcore into d…
quintijn Feb 21, 2024
a82ff71
Merge branch 'main' into dr16issues
quintijn Feb 21, 2024
adecae7
Merge branch 'dictation-toolbox:main' into dr16issues
quintijn Feb 21, 2024
9636078
trying to get documentation (sphinx) up and running (not successful)
quintijn Feb 23, 2024
34420ca
tidying up a few messages natlinktimer.py
quintijn Feb 27, 2024
76cc9dd
small fix in natlinkstatus.py
quintijn Feb 29, 2024
32c1184
make a small test at bottom (buttonClick should be caught in __init__…
quintijn Feb 29, 2024
9a7d525
setting default port for settings.debugadapterprotocol to 7474...
quintijn Mar 2, 2024
433f59e
effort to fix a test error with test_natlinktimer.py failed.
quintijn Mar 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/natlinkcore/configure/natlinkconfig_gui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pylint:disable=W0621, W0703
#pylint:disable=W0621, W0703, W0603
import sys
import platform

Expand Down Expand Up @@ -116,7 +116,7 @@ def OpenNatlinkConfig(values, event):
try:
while True:
event, values = window.read()
if (event == '-WINDOW CLOSE ATTEMPTED-' or event == 'Exit') and not Thread_Running:
if (event in ['-WINDOW CLOSE ATTEMPTED-', 'Exit']) and not Thread_Running:
break
# Hidden Columns logic
# TODO: if project is enabled, update the project state to enabled.
Expand All @@ -140,7 +140,7 @@ def OpenNatlinkConfig(values, event):
Thread_Running = not Thread_Running

elif Thread_Running:
choice = sg.popup(f'Please Wait: Pip install is in progress', keep_on_top=True, custom_text=('Wait','Force Close'))
choice = sg.popup('Please Wait: Pip install is in progress', keep_on_top=True, custom_text=('Wait','Force Close'))
if choice == 'Force Close':
break

Expand Down
40 changes: 39 additions & 1 deletion src/natlinkcore/configure/natlinkconfigfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Quintijn Hoogenboom, January 2008 (...), August 2022
#

#pylint:disable=C0302, W0702, R0904, C0116, W0613, R0914, R0912
#pylint:disable=C0302, W0702, R0904, C0116, W0613, R0914, R0912, R1732, W1514, W0107
"""With the functions in this module Natlink can be configured.

These functions are called in different ways:
Expand Down Expand Up @@ -308,6 +308,44 @@ def disable_unimacro(self, arg=None):
self.config_remove('directories', 'unimacrodirectory') # could still be there...
self.status.refresh()

### Dragonfly:

def enable_dragonfly(self, arg):
dragonfly_user_dir = self.status.getDragonflyUserDirectory()
if dragonfly_user_dir and isdir(dragonfly_user_dir):
print(f'DragonflyUserDirectory is already defined: "{dragonfly_user_dir}"\n\tto change, first clear (option "D") and then set again')
print('\nWhen you want to upgrade Dragonfly, also first clear ("D"), then choose this option ("d") again.\n')
return

df_dir = self.status.getDragonflyDirectory()
if df_dir:
print('==== instal and/or update dragonfly2====\n')
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "dragonfly2"])
except subprocess.CalledProcessError:
print('====\ncould not pip install --upgrade dragonfly2\n====\n')
return
else:
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "dragonfly2"])
except subprocess.CalledProcessError:
print('====\ncould not pip install dragonfly2\n====\n')
return
self.status.refresh() # refresh status
df_dir = self.status.getDragonflyDirectory()

self.setDirectory('DragonflyUserDirectory', arg)
dragonfly_user_dir = self.config_get('dragonfly', 'dragonflyuserdirectory')
if not dragonfly_user_dir:
return


def disable_dragonfly(self, arg=None):
"""disable dragonfly, do not expect arg
"""
self.config_remove('directories', 'dragonflyuserdirectory') # could still be there...
self.status.refresh()


def enable_vocola(self, arg):
"""enable vocola, by setting arg (prompting if False), and other settings
Expand Down
26 changes: 22 additions & 4 deletions src/natlinkcore/natlinkstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class NatlinkStatus(metaclass=singleton.Singleton):

"""
known_directory_options = ['userdirectory', 'dragonflyuserdirectory',
'unimacrodirectory',
'unimacrodirectory', 'unimacrogrammarsdirectory',
'vocoladirectory', 'vocolagrammarsdirectory']

def __init__(self):
Expand All @@ -165,6 +165,9 @@ def __init__(self):
## Dragonfly
self.DragonflyDirectory = None
self.DragonflyUserDirectory = None
## dtactions
self.DtactionsDirectory = None

## AutoHotkey:
self.AhkUserDir = None
self.AhkExeDir = None
Expand Down Expand Up @@ -500,12 +503,12 @@ def getDragonflyDirectory(self):
if self.DragonflyDirectory is not None:
return self.DragonflyDirectory
try:
import dragonfly
import dragonfly2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi guys. This is an error, just FYI. Dragonfly is always imported with import dragonfly. dragonfly2 is one of the two package names, used only when installing via pip. Sorry for the confusion!

except ImportError:
self.DragonflyDirectory = ""
return ""

self.DragonflyDirectory = str(Path(dragonfly.__file__).parent)
self.DragonflyDirectory = str(Path(dragonfly2.__file__).parent)
return self.DragonflyDirectory


Expand Down Expand Up @@ -597,6 +600,20 @@ def getVocolaGrammarsDirectory(self):
self.VocolaGrammarsDirectory = voc_grammars_dir
return voc_grammars_dir

def getDtactionsDirectory(self):
"""dtactions directory should be found with an import (like getUnimacroDirectory)
"""

if self.DtactionsDirectory is not None:
return self.DtactionsDirectory
try:
import dtactions
except ImportError:
self.DtactionsDirectory = ""
return ""
self.DtactionsDirectory = dtactions.__path__[-1]
return self.DtactionsDirectory

def getAhkUserDir(self):
return self.getAhkUserDirFromIni()

Expand Down Expand Up @@ -733,6 +750,7 @@ def getNatlinkStatusDict(self):
'UserDirectory',
'DragonflyDirectory', 'DragonflyUserDirectory',
'ExtraGrammarDirectories',
'DtactionsDirectory',
'InstallVersion',
# 'IncludeUnimacroInPythonPath',
'AhkExeDir', 'AhkUserDir']:
Expand Down Expand Up @@ -803,7 +821,7 @@ def getNatlinkStatusString(self):
self.appendAndRemove(L, D, key)
else:
self.appendAndRemove(L, D, 'unimacroIsEnabled', "---Unimacro is disabled")
for key in ('UnimacroUserDirectory', 'UnimacroDirectory'):
for key in ('UnimacroUserDirectory', 'UnimacroGrammarsDirectory', 'UnimacroDirectory'):
del D[key]
## UserDirectory:
if D['userIsEnabled']:
Expand Down