Reformat and fix circular import

This commit is contained in:
2022-07-21 13:40:03 +01:00
parent 3229d9b806
commit 6c7d0d5c45
11 changed files with 52 additions and 29 deletions

View File

@@ -12,16 +12,16 @@ def loadCommands(allowDup=False):
if filename.endswith(".py") and filename != "__init__.py":
commandName = filename[0:-3]
className = commandName.capitalize() + "Command"
try:
module = __import__("commands.%s" % commandName)
if not commandName in CommandMap:
# try:
module = __import__("commands.%s" % commandName)
if not commandName in CommandMap:
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)
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))
error("Duplicate command: %s" % (commandName))
# except Exception as err:
# error("Exception while loading command %s:\n%s" % (commandName, err))