Renovate the module system and implement adding and resuming pool instances using the new relay/alias/network system
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
from os import listdir
|
||||
import main
|
||||
from importlib import reload
|
||||
from sys import modules
|
||||
|
||||
from utils.logging.log import *
|
||||
import commands
|
||||
|
||||
def loadSingle(command, func):
|
||||
if command+".py" in listdir("commands"):
|
||||
from main import CommandMap
|
||||
|
||||
def loadSingle(commandName):
|
||||
if commandName+".py" in listdir("commands"):
|
||||
className = commandName.capitalize()
|
||||
try:
|
||||
if command in main.CommandMap.keys():
|
||||
return "Cannot reload modules"
|
||||
else:
|
||||
className = command.capitalize()
|
||||
__import__("commands.%s" % command)
|
||||
eval("commands.%s.%s(func)" % (command, className))
|
||||
return True
|
||||
if commandName in CommandMap.keys():
|
||||
reload(modules["commands."+commandName])
|
||||
CommandMap[commandName] = getattr(modules["commands."+commandName], className)
|
||||
debug("Reloaded command: %s" % commandName)
|
||||
return "RELOAD"
|
||||
module = __import__('commands.%s' % commandName)
|
||||
CommandMap[commandName] = getattr(getattr(module, commandName), className)
|
||||
debug("Registered command: %s" % commandName)
|
||||
return True
|
||||
|
||||
except Exception as err:
|
||||
return err
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user