def test_import_dir(self): """ Test if import_dir imports correct files """ import_dir("sample_plugin_dir", "sample_plugin_dir") self.assertEqual(len(Base.__subclasses__()), 1)
def get_opsys_name(self, cmdline_opsys): """ Get correct opsys name from user passed opsys or raise FafError if not available """ cmdline_opsys = cmdline_opsys.lower() if not cmdline_opsys in systems: raise FafError( "Operating system '{0}' does not exist".format(cmdline_opsys)) return systems[cmdline_opsys].nice_name def get_db_opsys(self, db, cmdline_opsys): """ Get opsys object from database or raise FafError if not available """ opsys_name = self.get_opsys_name(cmdline_opsys) db_opsys = get_opsys_by_name(db, opsys_name) if db_opsys is None: raise FafError( "Operating system '{0}' is not installed".format(opsys_name)) return db_opsys import_dir(__name__, os.path.dirname(__file__)) load_plugins(Action, actions)
.format(self.__class__.__name__)) def compare_many(self, db_reports): """ Some libraries (btparser, satyr) provide a way to compare many reports at the same time returning a report list and distances object. This may be a significant speedup. """ raise NotImplementedError("compare_many is not implemented for {0}" .format(self.__class__.__name__)) def check_btpath_match(self, ureport, parser): """ Check whether a path in stacktrace matches to a knowledgebase rule. """ raise NotImplementedError("check_btpath_match is not implemented for " "{0}".format(self.__class__.__name__)) def find_crash_function(self, db_backtrace): """ Find the crash function of a backtrace. """ raise NotImplementedError("find_crash_function is not implemented for " "{0}".format(self.__class__.__name__)) import_dir(__name__, os.path.dirname(__file__)) load_plugins(ProblemType, problemtypes)
self.sessionmaker = sessionmaker(bind=self.engine, autocommit=autocommit) def get_database(self) -> TemporaryDatabase: return TemporaryDatabase(self.sessionmaker()) class YieldQueryAdaptor: """ This class wraps a Query into an object with interface that can be used at places where we need to iterate over items and want to know count of those items. """ def __init__(self, query, yield_per) -> None: self._query = query self._yield_per = yield_per self._len: Optional[int] = None def __len__(self) -> Optional[int]: if self._len is None: self._len = int(self._query.count()) return self._len def __iter__(self) -> Iterator[int]: return iter(self._query.yield_per(self._yield_per)) # Import all events import_dir(__name__, os.path.dirname(__file__), "events")
self.sessionmaker = sessionmaker(bind=self.engine, autocommit=autocommit) def get_database(self): return TemporaryDatabase(self.sessionmaker()) class YieldQueryAdaptor: """ This class wraps a Query into an object with interface that can be used at places where we need to iterate over items and want to know count of those items. """ def __init__(self, query, yield_per): self._query = query self._yield_per = yield_per self._len = None def __len__(self): if self._len is None: self._len = int(self._query.count()) return self._len def __iter__(self): return iter(self._query.yield_per(self._yield_per)) # Import all events import_dir(__name__, os.path.dirname(__file__), "events")