fallback for script folder to config/scripts, remove debug code that runs any script on startup lol

This commit is contained in:
chrys 2016-10-19 20:58:56 +02:00
parent 11c940a114
commit e52f8fe685

View File

@ -54,16 +54,21 @@ class commandManager():
def loadScriptCommands(self, section='commands'): def loadScriptCommands(self, section='commands'):
scriptPath = self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath') scriptPath = self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath')
if not os.path.exists(scriptPath): if not scriptPath.endswith('/'):
self.env['runtime']['debug'].writeDebugOut("scriptpath not exists:" + scriptPath ,debug.debugLevel.ERROR) scriptPath += '/'
return if not os.path.exists(scriptPath) or scriptPath == '/':
if os.path.exists(os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/scripts/'):
scriptPath = os.path.dirname(os.path.realpath(__main__.__file__)) +'/../../config/scripts/'
else:
self.env['runtime']['debug'].writeDebugOut("scriptpath not exists:" + scriptPath ,debug.debugLevel.WARNING)
return
if not os.path.isdir(scriptPath): if not os.path.isdir(scriptPath):
self.env['runtime']['debug'].writeDebugOut("scriptpath not a directory:" + scriptPath ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("scriptpath not a directory:" + scriptPath ,debug.debugLevel.ERROR)
return return
if not os.access(scriptPath, os.R_OK): if not os.access(scriptPath, os.R_OK):
self.env['runtime']['debug'].writeDebugOut("scriptpath not readable:" + scriptPath ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("scriptpath not readable:" + scriptPath ,debug.debugLevel.ERROR)
return return
commandList = glob.glob(self.env['runtime']['settingsManager'].getSetting('general', 'scriptPath')+'/*') commandList = glob.glob(scriptPath+'*')
subCommand = os.path.dirname(os.path.realpath(__main__.__file__)) + '/commands/commands/subprocess.py' subCommand = os.path.dirname(os.path.realpath(__main__.__file__)) + '/commands/commands/subprocess.py'
for command in commandList: for command in commandList:
invalid = False invalid = False
@ -77,7 +82,6 @@ class commandManager():
spec.loader.exec_module(command_mod) spec.loader.exec_module(command_mod)
self.env['commands'][section][fileName.upper()] = command_mod.command() self.env['commands'][section][fileName.upper()] = command_mod.command()
self.env['commands'][section][fileName.upper()].initialize(self.env,command) self.env['commands'][section][fileName.upper()].initialize(self.env,command)
self.env['commands'][section][fileName.upper()].run()
self.env['runtime']['debug'].writeDebugOut("Load script:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True) self.env['runtime']['debug'].writeDebugOut("Load script:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True)
commSettings = fileName.upper().split('__-__') commSettings = fileName.upper().split('__-__')
if len(commSettings) == 1: if len(commSettings) == 1: