Esempio n. 1
0
def package_group_for_my_distro():
    """Factory that returns a class representing the distro currently being used."""
    if sys.platform == "darwin":
        return MacOSBrewPackageGroup
    elif sys.platform in [
            "linux",
            "linux2",
            "linux3",
    ]:
        LINUX_DISTROS = {
            "linuxmint": UbuntuPackageGroup,
            "redhat": RedHatPackageGroup,
            "fedora": FedoraPackageGroup,
            "centos": CentOSPackageGroup,
            "manjarolinux": ArchPackageGroup,
            "arch": ArchPackageGroup,
            "debian-": DebianPackageGroup,
            "debian-squeeze": DebianSqueezePackageGroup,
            "debian-squeeze-lts": DebianSqueezeLTSPackageGroup,
            "debian-wheezy": DebianWheezyPackageGroup,
            "debian-jessie": DebianJessiePackageGroup,
            "debian-stretch": DebianStretchPackageGroup,
            "debian-sid": DebianSidPackageGroup,
            "ubuntu-": UbuntuPackageGroup,
            "ubuntu-precise": UbuntuPrecisePackageGroup,
            "ubuntu-trusty": UbuntuTrustyPackageGroup,
            "ubuntu-vivid": UbuntuVividPackageGroup,
            "ubuntu-wily": UbuntuWilyPackageGroup,
            "ubuntu-xenial": UbuntuXenialPackageGroup,
            "ubuntu-yakkety": UbuntuYakketyPackageGroup,
        }

        this_distro = utils.lsb_release().lower()

        if this_distro in [
                "debian",
                "ubuntu",
        ]:
            distro_and_version = "{0}-{1}".format(
                this_distro,
                utils.lsb_release_codename().lower())
            if distro_and_version not in LINUX_DISTROS.keys():
                raise exceptions.DistroVersionNotFound(distro_and_version)
            return LINUX_DISTROS[distro_and_version]
        else:
            if this_distro in LINUX_DISTROS:
                return LINUX_DISTROS[this_distro]
            else:
                raise exceptions.UnsupportedPlatform(this_distro)
    else:
        raise exceptions.UnsupportedPlatform(sys.platform)
Esempio n. 2
0
def package_group_for_my_distro():
    """Factory that returns a class representing the distro currently being used."""
    if sys.platform == "darwin":
        return MacOSBrewPackageGroup
    elif sys.platform in ["linux", "linux2", "linux3", ]:
        LINUX_DISTROS = {
            "linuxmint": UbuntuPackageGroup,
            "redhat": RedHatPackageGroup,
            "fedora": FedoraPackageGroup,
            "centos": CentOSPackageGroup,
            "manjarolinux": ArchPackageGroup,
            "arch": ArchPackageGroup,
            "debian-": DebianPackageGroup,
            "debian-squeeze": DebianSqueezePackageGroup,
            "debian-squeeze-lts": DebianSqueezeLTSPackageGroup,
            "debian-wheezy": DebianWheezyPackageGroup,
            "debian-jessie": DebianJessiePackageGroup,
            "debian-stretch": DebianStretchPackageGroup,
            "debian-sid": DebianSidPackageGroup,
            "ubuntu-": UbuntuPackageGroup,
            "ubuntu-precise": UbuntuPrecisePackageGroup,
            "ubuntu-trusty": UbuntuTrustyPackageGroup,
            "ubuntu-vivid": UbuntuVividPackageGroup,
            "ubuntu-wily": UbuntuWilyPackageGroup,
            "ubuntu-xenial": UbuntuXenialPackageGroup,
            "ubuntu-yakkety": UbuntuYakketyPackageGroup,
        }

        this_distro = utils.lsb_release().lower()

        if this_distro in ["debian", "ubuntu",]:
            distro_and_version = "{0}-{1}".format(
                this_distro, utils.lsb_release_codename().lower()
            )
            if distro_and_version not in LINUX_DISTROS.keys():
                raise exceptions.DistroVersionNotFound(distro_and_version)
            return LINUX_DISTROS[distro_and_version]
        else:
            if this_distro in LINUX_DISTROS:
                return LINUX_DISTROS[this_distro]
            else:
                raise exceptions.UnsupportedPlatform(this_distro)
    else:
        raise exceptions.UnsupportedPlatform(sys.platform)
def package_group_for_my_distro():
    """Factory that returns a class representing the distro currently being used."""
    if sys.platform == "darwin":
        return MacOSBrewPackageGroup
    elif sys.platform in ["linux", "linux2", "linux3", ]:
        LINUX_DISTROS = {
            "ubuntu": UbuntuPackageGroup,
            "linuxmint": UbuntuPackageGroup,
            "redhat": RedHatPackageGroup,
            "fedora": FedoraPackageGroup,
            "centos": CentOSPackageGroup,
            "manjarolinux": ArchPackageGroup,
            "arch": ArchPackageGroup,
            "debian": DebianPackageGroup,
        }

        this_distro = utils.lsb_release().lower()
        if this_distro in LINUX_DISTROS:
            return LINUX_DISTROS[this_distro]
        else:
            raise exceptions.UnsupportedPlatform(this_distro)
    else:
        raise exceptions.UnsupportedPlatform(sys.platform)