You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
931 B
Python

from os import listdir
from importlib import reload
import sys
from utils.logging.debug import debug
from utils.logging.log import *
import commands
from main import CommandMap
def loadSingle(commandName):
if commandName+".py" in listdir("commands"):
className = commandName.capitalize()+"Command"
try:
if commandName in CommandMap.keys():
reload(sys.modules["commands."+commandName])
CommandMap[commandName] = getattr(sys.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