Prepare command loader for reloading commands
This commit is contained in:
parent
f7e1f2d221
commit
abdfc48b95
|
@ -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…
Reference in New Issue