improve debug
This commit is contained in:
parent
f785b3e6db
commit
876be9a6d3
@ -34,10 +34,9 @@ class commandManager():
|
|||||||
commandList = glob.glob(commandFolder+'*')
|
commandList = glob.glob(commandFolder+'*')
|
||||||
for command in commandList:
|
for command in commandList:
|
||||||
try:
|
try:
|
||||||
print(command)
|
|
||||||
fileName, fileExtension = os.path.splitext(command)
|
fileName, fileExtension = os.path.splitext(command)
|
||||||
fileName = fileName.split('/')[-1]
|
fileName = fileName.split('/')[-1]
|
||||||
if fileName in ['__init__','__pycache__']:
|
if fileName.startswith('__'):
|
||||||
continue
|
continue
|
||||||
if fileExtension.lower() == '.py':
|
if fileExtension.lower() == '.py':
|
||||||
spec = importlib.util.spec_from_file_location(fileName, command)
|
spec = importlib.util.spec_from_file_location(fileName, command)
|
||||||
@ -46,7 +45,7 @@ class commandManager():
|
|||||||
self.env['commands'][section][fileName.upper()] = command_mod.command()
|
self.env['commands'][section][fileName.upper()] = command_mod.command()
|
||||||
self.env['commandsIgnore'][section][fileName.upper()[fileName.upper().find('-')+1:]+'_IGNORE'] = False
|
self.env['commandsIgnore'][section][fileName.upper()[fileName.upper().find('-')+1:]+'_IGNORE'] = False
|
||||||
self.env['commands'][section][fileName.upper()].initialize(self.env)
|
self.env['commands'][section][fileName.upper()].initialize(self.env)
|
||||||
self.env['runtime']['debug'].writeDebugOut("Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
|
||||||
|
@ -37,16 +37,21 @@ class debug():
|
|||||||
self._file = open(self._fileName,'a')
|
self._file = open(self._fileName,'a')
|
||||||
self._fileOpened = True
|
self._fileOpened = True
|
||||||
|
|
||||||
def writeDebugOut(self, text, level = debugLevel.DEACTIVE):
|
def writeDebugOut(self, text, level = debugLevel.DEACTIVE, onAnyLevel=False):
|
||||||
if self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') < int(level):
|
if (self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') < int(level)) or \
|
||||||
|
not (onAnyLevel and self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') > int(debugLevel.DEACTIVE)) :
|
||||||
if self._fileOpened:
|
if self._fileOpened:
|
||||||
self.closeDebugFile()
|
self.closeDebugFile()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if not self._fileOpened:
|
if not self._fileOpened:
|
||||||
self.openDebugFile()
|
self.openDebugFile()
|
||||||
msg = str(level) +' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')
|
if onAnyLevel:
|
||||||
) + ': ' + text
|
msg = 'INFO ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'))
|
||||||
|
else:
|
||||||
|
msg = str(level) +' ' + str(datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')
|
||||||
|
)
|
||||||
|
msg += ': ' + text
|
||||||
print(msg)
|
print(msg)
|
||||||
self._file.write(msg + '\n')
|
self._file.write(msg + '\n')
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class settingsManager():
|
|||||||
shortcutKeys.append(key.upper())
|
shortcutKeys.append(key.upper())
|
||||||
shortcut.append(shortcutRepeat)
|
shortcut.append(shortcutRepeat)
|
||||||
shortcut.append(sorted(shortcutKeys))
|
shortcut.append(sorted(shortcutKeys))
|
||||||
self.env['runtime']['debug'].writeDebugOut("Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
self.env['bindings'][str(shortcut)] = commandName
|
self.env['bindings'][str(shortcut)] = commandName
|
||||||
kbConfig.close()
|
kbConfig.close()
|
||||||
|
|
||||||
@ -85,6 +85,7 @@ class settingsManager():
|
|||||||
if os.path.exists(soundIconPath + Values[1]):
|
if os.path.exists(soundIconPath + Values[1]):
|
||||||
soundIconFile = soundIconPath + Values[1]
|
soundIconFile = soundIconPath + Values[1]
|
||||||
self.env['soundIcons'][soundIcon] = soundIconFile
|
self.env['soundIcons'][soundIcon] = soundIconFile
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("SoundIcon: " + soundIcon + '.' + soundIconFile, debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
siConfig.close()
|
siConfig.close()
|
||||||
|
|
||||||
def loadDicts(self, dictConfigPath=os.path.dirname(os.path.realpath(__main__.__file__)) + '/../../config/punctuation/default.conf'):
|
def loadDicts(self, dictConfigPath=os.path.dirname(os.path.realpath(__main__.__file__)) + '/../../config/punctuation/default.conf'):
|
||||||
@ -115,7 +116,7 @@ class settingsManager():
|
|||||||
elif len(sepLine) > 2:
|
elif len(sepLine) > 2:
|
||||||
sepLine[1] = ':===:'
|
sepLine[1] = ':===:'
|
||||||
self.env['punctuation'][currDictName][sepLine[0]] = sepLine[1]
|
self.env['punctuation'][currDictName][sepLine[0]] = sepLine[1]
|
||||||
self.env['runtime']['debug'].writeDebugOut("Punctuation: " + currDictName + '.' + str(sepLine[0]) + ' :' + sepLine[1] ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Punctuation: " + currDictName + '.' + str(sepLine[0]) + ' :' + sepLine[1] ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
dictConfig.close()
|
dictConfig.close()
|
||||||
|
|
||||||
def loadSettings(self, settingConfigPath):
|
def loadSettings(self, settingConfigPath):
|
||||||
@ -251,10 +252,10 @@ class settingsManager():
|
|||||||
environment['runtime']['screenManager'] = screenManager.screenManager()
|
environment['runtime']['screenManager'] = screenManager.screenManager()
|
||||||
environment['runtime']['screenManager'].initialize(environment)
|
environment['runtime']['screenManager'].initialize(environment)
|
||||||
|
|
||||||
environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.ERROR)
|
environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
environment['runtime']['debug'].writeDebugOut(str(environment),debug.debugLevel.ERROR)
|
environment['runtime']['debug'].writeDebugOut(str(environment),debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
environment['runtime']['debug'].writeDebugOut('\/-------settings.conf-------\/',debug.debugLevel.ERROR)
|
environment['runtime']['debug'].writeDebugOut('\/-------settings.conf-------\/',debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
environment['runtime']['debug'].writeDebugOut(str(environment['settings']._sections
|
environment['runtime']['debug'].writeDebugOut(str(environment['settings']._sections
|
||||||
),debug.debugLevel.ERROR)
|
),debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
return environment
|
return environment
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user