Avoided setup-dependent error (file structuring). Implemented TNMR application search and re-open if it closes. This will not fix any particularly odd situations, but it will recover the majority of TNMR crashes and user error.

This commit is contained in:
2025-08-15 11:15:10 +02:00
parent bee3f5615a
commit 558bbfded9
4 changed files with 18 additions and 2 deletions

View File

@@ -17,6 +17,8 @@ import win32com.client
import pythoncom
import frappy_psi.tnmr.NTNMR as NTNMR
import winapps
import time
import json
import traceback
@@ -102,8 +104,21 @@ class TNMR:
pythoncom.CoInitialize()
return win32com.client.GetActiveObject("NTNMR.Application")
except pythoncom.com_error:
try:
self.open_TNMR()
time.sleep(10)
# try again
pythoncom.CoInitialize()
return win32com.client.GetActiveObject("NTNMR.Application")
except:
raise TNMRNotRunnningError
raise TNMRNotRunnningError
def open_TNMR(self):
'''Tries to open up TNMR, using its registration in the Windows registry'''
for app in winapps.search_installed('TNMR'):
os.system('start ' + str(app.install_location.absolute()) + '\\bin\\TNMR.exe')
def execute_cmd(self, cmd):
'''Sends an arbitrary command through to TNMR'''
print('W: Executing arbitrary command: ' + f'out = self.get_instance().{cmd}')