Skip to content

Commit

Permalink
Merge pull request #44 from Conan-Kudo/osrelease
Browse files Browse the repository at this point in the history
Change distro name retrieval to try to read /etc/os-release first
  • Loading branch information
FrostyX committed Oct 27, 2015
2 parents 9000c82 + 2277d61 commit 2253f83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
import sys
import platform
import unittest
from tracer.resources.system import System

DISTRO = platform.linux_distribution(full_distribution_name=False)[0]
DISTRO = System.distribution()
13 changes: 12 additions & 1 deletion tracer/resources/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ class System(object):

@staticmethod
def distribution():
return platform.linux_distribution(full_distribution_name=False)[0]
# Checks if /etc/os-release exists, and if it does,
# use it to divine the name of the distribution
# Otherwise, revert to using platform.linux_distribution()
if os.path.isfile("/etc/os-release"):
with open("/etc/os-release") as os_release_file:
os_release_data = {}
for line in os_release_file:
os_release_key, os_release_value = line.rstrip().split("=")
os_release_data[os_release_key] = os_release_value.strip('"')
return os_release_data["ID"]
else:
return platform.linux_distribution(full_distribution_name=False)[0]

@staticmethod
def package_manager(**kwargs):
Expand Down

0 comments on commit 2253f83

Please sign in to comment.