fix debug

This commit is contained in:
chrys 2018-03-25 01:24:04 +01:00
parent 6634df1999
commit e8a0a63c38
2 changed files with 16 additions and 9 deletions

View File

@ -28,9 +28,11 @@ class debugManager():
directory = os.path.dirname(self._fileName)
if not os.path.exists(directory):
pathlib.Path(directory).mkdir(parents=True, exist_ok=True)
self._file = open(self._fileName,'a')
self._fileOpened = True
try:
self._file = open(self._fileName,'a')
self._fileOpened = True
except Exception as e:
print(e)
def writeDebugOut(self, text, level = debug.debugLevel.DEACTIVE, onAnyLevel=False):
mode = self.env['runtime']['settingsManager'].getSetting('general','debugMode')
@ -57,13 +59,18 @@ class debugManager():
if printMode:
print(msg)
if fileMode:
self._file.write(msg + '\n')
try:
self._file.write(msg + '\n')
except Exception as e:
print(e)
def closeDebugFile(self):
if not self._fileOpened:
return False
if self._file != None:
self._file.close()
try:
self._file.close()
except Exception as e:
print(e)
self._fileOpened = False
return True

View File

@ -286,9 +286,6 @@ class settingsManager():
if not validConfig:
return None
environment['runtime']['debug'] = debugManager.debugManager(self.env['runtime']['settingsManager'].getSetting('general','debugFile'))
environment['runtime']['debug'].initialize(environment)
if cliArgs.options != '':
self.parseSettingArgs(cliArgs.options)
if cliArgs.debug:
@ -298,6 +295,9 @@ class settingsManager():
self.setOptionArgDict('general', 'debugMode', 'PRINT')
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
self.setScriptKeys(self.getSetting('general','scriptKeys'))
environment['runtime']['debug'] = debugManager.debugManager(self.env['runtime']['settingsManager'].getSetting('general','debugFile'))
environment['runtime']['debug'].initialize(environment)
if not os.path.exists(self.getSetting('keyboard','keyboardLayout')):
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')):