add some more bits
This commit is contained in:
parent
af8bf385a7
commit
cb7df7862d
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open save' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run replace macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run search macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open save' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run replace macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run search macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open save' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run replace macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run search macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run open save' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run replace macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -16,6 +16,6 @@ class command():
|
|||||||
def getDescription(self):
|
def getDescription(self):
|
||||||
return 'No description found'
|
return 'No description found'
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
self.env['runtime']['outputManager'].presentText('ok i run search macro' , interrupt=True)
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
pass
|
pass
|
||||||
|
@ -31,22 +31,53 @@ class commandManager():
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
for commandFolder in self.env['general']['commandFolderList']:
|
for commandFolder in self.env['general']['commandFolderList']:
|
||||||
self.env['runtime']['commandManager'].shutdownCommands(commandFolder)
|
self.env['runtime']['commandManager'].shutdownCommands(commandFolder)
|
||||||
|
|
||||||
|
def loadFile(self, filepath = ''):
|
||||||
|
if filepath == '':
|
||||||
|
return None
|
||||||
|
if not os.path.exists(filepath):
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not exists:" + filepath ,debug.debugLevel.WARNING)
|
||||||
|
print('1')
|
||||||
|
return None
|
||||||
|
if os.path.isdir(filepath):
|
||||||
|
print('2')
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath is a directory:" + filepath ,debug.debugLevel.ERROR)
|
||||||
|
return None
|
||||||
|
if not os.access(filepath, os.R_OK):
|
||||||
|
print('3')
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not readable:" + filepath ,debug.debugLevel.ERROR)
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
fileName, fileExtension = os.path.splitext(filepath)
|
||||||
|
fileName = fileName.split('/')[-1]
|
||||||
|
if fileName.startswith('__'):
|
||||||
|
return None
|
||||||
|
if fileExtension.lower() == '.py':
|
||||||
|
command_mod = module_utils.importModule(fileName, filepath)
|
||||||
|
command = command_mod.command()
|
||||||
|
command.initialize(self.env)
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("loadFile: Load command:" + filepath ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
|
return command
|
||||||
|
except Exception as e:
|
||||||
|
self.env['runtime']['debug'].writeDebugOut("loadFile: Loading command:" + filepath ,debug.debugLevel.ERROR)
|
||||||
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
|
return None
|
||||||
def loadCommands(self, section='commands',commandPath=''):
|
def loadCommands(self, section='commands',commandPath=''):
|
||||||
if commandPath =='':
|
if commandPath =='':
|
||||||
commandPath = fenrirPath+ "/commands/"
|
commandPath = fenrirPath+ "/commands/"
|
||||||
if not commandPath.endswith('/'):
|
if not commandPath.endswith('/'):
|
||||||
commandPath += '/'
|
commandPath += '/'
|
||||||
commandFolder = commandPath + section +"/"
|
commandFolder = commandPath + section +"/"
|
||||||
if not os.path.exists(commandFolder):
|
if not os.path.exists(commandFolder):
|
||||||
self.env['runtime']['debug'].writeDebugOut("commandFolder not exists:" + commandFolder ,debug.debugLevel.WARNING)
|
self.env['runtime']['debug'].writeDebugOut("loadCommands: commandFolder not exists:" + commandFolder ,debug.debugLevel.WARNING)
|
||||||
return
|
return
|
||||||
if not os.path.isdir(commandFolder):
|
if not os.path.isdir(commandFolder):
|
||||||
self.env['runtime']['debug'].writeDebugOut("commandFolder not a directory:" + commandFolder ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("loadCommands: commandFolder not a directory:" + commandFolder ,debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
if not os.access(commandFolder, os.R_OK):
|
if not os.access(commandFolder, os.R_OK):
|
||||||
self.env['runtime']['debug'].writeDebugOut("commandFolder not readable:" + commandFolder ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("loadCommands: commandFolder not readable:" + commandFolder ,debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
self.env['commands'][section] = {}
|
self.env['commands'][section] = {}
|
||||||
self.env['commandsIgnore'][section] = {}
|
self.env['commandsIgnore'][section] = {}
|
||||||
commandList = glob.glob(commandFolder+'*')
|
commandList = glob.glob(commandFolder+'*')
|
||||||
@ -66,9 +97,9 @@ 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, onAnyLevel=True)
|
self.env['runtime']['debug'].writeDebugOut("loadCommands: Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("loadCommands: Loading command:" + command ,debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -79,7 +79,9 @@ class vmenuManager():
|
|||||||
if self.currIndex == None:
|
if self.currIndex == None:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
pass
|
command = self.getValueByPath(self.menuDict, self.currIndex)
|
||||||
|
if not command == None:
|
||||||
|
command.run()
|
||||||
except:
|
except:
|
||||||
self.incLevel()
|
self.incLevel()
|
||||||
def incLevel(self):
|
def incLevel(self):
|
||||||
@ -87,10 +89,9 @@ class vmenuManager():
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
r = self.getValueByPath(self.menuDict, self.currIndex +[0])
|
r = self.getValueByPath(self.menuDict, self.currIndex +[0])
|
||||||
if not r:
|
print(r)
|
||||||
return
|
#if not r:
|
||||||
if not isinstance(r, dict):
|
# return
|
||||||
return
|
|
||||||
if r == {}:
|
if r == {}:
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
@ -128,15 +129,18 @@ class vmenuManager():
|
|||||||
def fs_tree_to_dict(self, path_):
|
def fs_tree_to_dict(self, path_):
|
||||||
for root, dirs, files in os.walk(path_):
|
for root, dirs, files in os.walk(path_):
|
||||||
tree = {d: self.fs_tree_to_dict(os.path.join(root, d)) for d in dirs}
|
tree = {d: self.fs_tree_to_dict(os.path.join(root, d)) for d in dirs}
|
||||||
tree.update({f: root + '/' + f for f in files})
|
for f in files:
|
||||||
|
try:
|
||||||
|
command = self.env['runtime']['commandManager'].loadFile(root + '/' + f)
|
||||||
|
tree.update({f: command})
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return tree # note we discontinue iteration trough os.walk
|
return tree # note we discontinue iteration trough os.walk
|
||||||
def getNestedByPath(self, complete, path):
|
def getNestedByPath(self, complete, path):
|
||||||
path = path.copy()
|
path = path.copy()
|
||||||
if path != []:
|
if path != []:
|
||||||
index = list(complete.keys())[path[0]]
|
index = list(complete.keys())[path[0]]
|
||||||
print(path)
|
nested = self.getNestedByPath(complete[index], path[1:])
|
||||||
path.remove(0)
|
|
||||||
nested = self.getNestedByPath(complete[index], path)
|
|
||||||
return nested
|
return nested
|
||||||
else:
|
else:
|
||||||
return complete
|
return complete
|
||||||
|
Loading…
Reference in New Issue
Block a user