def reloadConnectors(self, force=False):
if self._loaded and not force: return
configPath = Configure.CurrentPath()
connectorsLocation = os.path.join(configPath, "connectors")
connectorsInitPath = os.path.join(connectorsLocation, "__init__.py")
oldPath = sys.path
if configPath not in sys.path:
sys.path.insert(0, configPath)
if not os.path.exists(connectorsInitPath):
with open(connectorsInitPath, "w+") as f:
f.write("#dummy init for connectors module")
for pathName in os.listdir(connectorsLocation):
pathName = os.path.join(connectorsLocation, pathName)
moduleName = os.path.basename(pathName)
if os.path.exists(os.path.join(pathName, "__init__.py")):
dottedName = "connectors.{}".format(moduleName)
with PacketDefinitionSilo():
if dottedName in sys.modules:
#TODO: Test if this even works.
importlib.reload(sys.module[dottedName])
else:
importlib.import_module(dottedName)
sys.path = oldPath
self._loaded = True
# print("Loading module {}".format(pathName))
# self._loadConnectorModule(os.path.join(connectorLocation, pathName))
评论列表
文章目录