def init_subsystems(self): subsystems = list() for subsystem in self.subsystems: dotpath = self.get_dotpath(os.path.join(subsystem.package_dir, subsystem.module_name)) module = __import__(dotpath) for sym in dotpath.split(".")[1:]: module = getattr(module, sym) for sym in dir(module): if type(getattr(module, sym)) == type(object) and Subsystem in getattr(module, sym).__bases__: logger.info("Initialized subsystem `%s`" % subsystem.module_name) subsystem = getattr(module, sym)(subsystem=subsystem) subsystem.setup() subsystems.append(subsystem) self.subsystems = subsystems
def find_subsystems(self): for source in self.config["sources"]: for subsystem in glob.glob(os.path.join(source, "*")): if not os.path.isdir(subsystem): continue for module in glob.glob(os.path.join(subsystem, "*%s*" % os.path.extsep)): if os.path.splitext(os.path.basename(module))[0] == os.path.basename(subsystem): break else: module = None if not module: continue package_dir = subsystem module_name = os.path.splitext(os.path.basename(module))[0] if module_name in self.config["subsystems"] and self.config["subsystems"][module_name]["enabled"]: logger.info("Found subsystem `%s` in '%s'" % (module_name, package_dir)) self.subsystems.append(Subsystem(self, package_dir, module_name)) return self.subsystems