Prepare command loader for reloading commands

pull/1/head
Mark Veidemanis 4 years ago
parent fe52561b71
commit f54a448d54

@ -6,7 +6,7 @@ import commands
from main import CommandMap
def loadCommands():
def loadCommands(allowDup=False):
for filename in listdir("commands"):
if filename.endswith(".py") and filename != "__init__.py":
commandName = filename[0:-3]
@ -17,6 +17,10 @@ def loadCommands():
CommandMap[commandName] = getattr(getattr(module, commandName), className)
debug("Registered command: %s" % commandName)
else:
if allowDup:
CommandMap[commandName] = getattr(getattr(module, commandName), className)
debug("Registered command: %s" % commandName)
error("Duplicate command: %s" % (commandName))
except Exception as err:
error("Exception while loading command %s:\n%s" % (commandName, err))

Loading…
Cancel
Save