def __init__(self, manifest=None): mgr_name = 'apt' if disttool.is_debian_based() else 'yum' self.mgr = AptPackageMgr() if disttool.is_debian_based( ) else YumPackageMgr() self.manifest = os.path.abspath(manifest or self.DEFAULT_MANIFEST) self.conf = configparser.ConfigParser() self.conf.read(self.manifest) dist_id, release = disttool.linux_dist()[0:2] if disttool.is_redhat_based() and not disttool.is_fedora(): dist_id = 'el' dist_id = dist_id.lower() major_release = release.split('.')[0] self.sections = [ s % locals() for s in ('%(mgr_name)s', '%(mgr_name)s:%(dist_id)s', '%(mgr_name)s:%(dist_id)s%(major_release)s', '%(mgr_name)s:%(dist_id)s%(release)s') ] self.sections.reverse() LOG.debug( 'Initialized ImpLoader with such settings\n' ' manifest: %s\n' ' sections: %s\n', self.manifest, self.sections)
def __init__(self, manifest=None): mgr_name = "apt" if disttool.is_debian_based() else "yum" self.mgr = AptPackageMgr() if disttool.is_debian_based() else YumPackageMgr() self.manifest = os.path.abspath(manifest or self.DEFAULT_MANIFEST) self.conf = configparser.ConfigParser() self.conf.read(self.manifest) dist_id, release = disttool.linux_dist()[0:2] if disttool.is_redhat_based() and not disttool.is_fedora(): dist_id = "el" dist_id = dist_id.lower() major_release = release.split(".")[0] self.sections = [ s % locals() for s in ( "%(mgr_name)s", "%(mgr_name)s:%(dist_id)s", "%(mgr_name)s:%(dist_id)s%(major_release)s", "%(mgr_name)s:%(dist_id)s%(release)s", ) ] self.sections.reverse() LOG.debug( "Initialized ImpLoader with such settings\n" " manifest: %s\n" " sections: %s\n", self.manifest, self.sections, )
def test_DistTool(self): self.assertTrue(disttool.is_linux()) self.assertTrue(disttool.is_redhat_based()) self.assertTrue(disttool.is_fedora()) self.assertFalse(disttool.is_win()) self.assertFalse(disttool.is_sun()) self.assertFalse(disttool.is_debian_based())