Implement loading new modules at runtime
This commit is contained in:
17
utils/loaders/single_loader.py
Normal file
17
utils/loaders/single_loader.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from os import listdir
|
||||
from core.main import *
|
||||
from utils.logging.log import *
|
||||
import commands
|
||||
|
||||
def loadSingle(command, func):
|
||||
if command+".py" in listdir("commands"):
|
||||
try:
|
||||
if command in CommandMap.keys():
|
||||
return "Cannot reload modules"
|
||||
else:
|
||||
className = command.capitalize()
|
||||
__import__("commands.%s" % command)
|
||||
eval("commands.%s.%s(func)" % (command, className))
|
||||
return True
|
||||
except Exception as err:
|
||||
return err
|
||||
Reference in New Issue
Block a user