Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertEqual(distro.minor_version(best=False),
MODULE_DISTROI.minor_version())
self.assertEqual(distro.minor_version(best=True),
MODULE_DISTROI.minor_version(best=True))
self.assertEqual(distro.build_number(),
MODULE_DISTROI.build_number(best=False))
self.assertEqual(distro.build_number(best=False),
MODULE_DISTROI.build_number())
self.assertEqual(distro.build_number(best=True),
MODULE_DISTROI.build_number(best=True))
self.assertEqual(distro.like(),
MODULE_DISTROI.like())
self.assertEqual(distro.codename(),
MODULE_DISTROI.codename())
self.assertEqual(distro.info(),
MODULE_DISTROI.info(best=False))
self.assertEqual(distro.info(best=False),
MODULE_DISTROI.info())
self.assertEqual(distro.info(best=True),
MODULE_DISTROI.info(best=True))
self.assertEqual(distro.info(),
MODULE_DISTROI.info(pretty=False))
self.assertEqual(distro.info(pretty=False),
MODULE_DISTROI.info())
self.assertEqual(distro.info(pretty=True),
MODULE_DISTROI.info(pretty=True))
self.assertEqual(distro.os_release_info(),
def test_cli(self):
command = [sys.executable, '-m', 'distro']
desired_output = 'Name: ' + distro.name(pretty=True)
distro_version = distro.version(pretty=True)
distro_codename = distro.codename()
desired_output += '\n' + 'Version: ' + distro_version
desired_output += '\n' + 'Codename: ' + distro_codename
desired_output += '\n'
assert self._run(command) == desired_output
def check_distribution():
try:
import distro
except ImportError:
errors = subprocess.run('sudo -EH pip3 install distro', shell=True).stderr
if errors:
sys.exit('Could not determine the system´s Linux distribution')
else:
import distro
codename = distro.codename().lower()
if codename in XENIAL_CODE_NAMES:
logging.debug('Ubuntu 16.04 detected')
return 'xenial'
if codename in BIONIC_CODE_NAMES:
logging.debug('Ubuntu 18.04 detected')
return 'bionic'
else:
sys.exit('Your Distribution ({} {}) is not supported. FACT Installer requires Ubuntu 16.04, Ubuntu 18.04 or compatible!'.format(distro.id(), distro.version()))
def check_distribution():
codename = distro.codename().lower()
if codename in XENIAL_CODE_NAMES:
logging.debug('Ubuntu 16.04 detected')
return 'xenial'
if codename in BIONIC_CODE_NAMES:
logging.debug('Ubuntu 18.04 detected')
return 'bionic'
else:
sys.exit('Your Distribution ({} {}) is not supported. FACT Installer requires Ubuntu 16.04, Ubuntu 18.04 or compatible!'.format(distro.id(), distro.version()))
def get_distribution_version():
"""
Function to acquire current Distribution Version
This function will return the current distribution version
if the user is running on a Linux machine.
"""
return distro.codename()
def detect(cls):
system = platform.system().lower()
if system == 'windows':
dist = 'windows'
version, *_ = platform.win32_ver()
codename = None
elif system == 'darwin':
dist = 'macos'
version, *_ = platform.mac_ver()
codename = None
else:
dist = distro.id()
version = distro.version()
codename = distro.codename()
return cls(
arch=platform.machine(),
system=system,
distro=dist,
version=version,
codename=codename
)
def _get_linux_distro_info(self):
import distro
self.linux_distro = distro.id()
self.os_version = Version(distro.version())
version_name = distro.codename()
self.os_version_name = version_name if version_name != "n/a" else ""
if not self.os_version_name and self.linux_distro == "debian":
self.os_version_name = self.get_debian_version_name(self.os_version)