Skip to content
Snippets Groups Projects
os.py 714 B
Newer Older
#!/usr/bin/env python3

"""System utils."""

from configparser import ConfigParser

SUPPORTED_PLATFORMS = (("debian", "10"), ("ubuntu", "18.04"))


def dist() -> tuple:
    """Return distribution name and version).

    :return: Distribution name and version
    :rtype: tuple
    """

    parser = ConfigParser()
    with open("/etc/os-release") as os_release:
        parser.read_string("[os]\n{}".format(os_release.read()))

    return (parser["os"]["ID"], parser["os"]["VERSION_ID"].strip('"'))


def supported_platform() -> bool:
    """Let you know if the current platform is supported.

    :return: Wether the platform is supported or not
    :rtype: bool
    """

    return dist() in SUPPORTED_PLATFORMS