Renovate the module system and implement adding and resuming pool instances using the new relay/alias/network system

This commit is contained in:
2019-01-26 18:58:21 +00:00
parent 4efea3f535
commit 8926cb76ec
37 changed files with 184 additions and 302 deletions

View File

@@ -1,14 +1,21 @@
from os import listdir
from utils.logging.log import *
import commands
def loadCommands(func):
from main import CommandMap
def loadCommands():
for filename in listdir('commands'):
if filename.endswith('.py') and filename != "__init__.py":
commandName = filename[0:-3]
className = commandName.capitalize()
try:
__import__('commands.%s' % commandName)
eval('commands.%s.%s(func)' % (commandName, className))
module = __import__('commands.%s' % commandName)
if not commandName in CommandMap:
CommandMap[commandName] = getattr(getattr(module, commandName), className)
debug("Registered command: %s" % commandName)
else:
error("Duplicate command: %s" % (commandName))
except Exception as err:
error("Exception while loading command %s:\n%s" % (commandName, err))