From: Michael Tremer Date: Fri, 6 Apr 2012 16:02:42 +0000 (+0200) Subject: Read /etc/os-release to determine the distribution we are running on. X-Git-Tag: 0.9.22~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8af4daa7237a01c7034854cb3ad607d03afe8861;p=pakfire.git Read /etc/os-release to determine the distribution we are running on. --- diff --git a/python/pakfire/distro.py b/python/pakfire/distro.py index 33f084ad9..b6a1c849f 100644 --- a/python/pakfire/distro.py +++ b/python/pakfire/distro.py @@ -35,6 +35,9 @@ class Distribution(object): self._data = {} if data is None: + # Read /etc/os-release if it does exist. + self.read_osrelease() + # Inherit configuration from Pakfire configuration. self.update(self.pakfire.config.get_section("distro")) else: @@ -43,12 +46,12 @@ class Distribution(object): # Dump all data self.dump() - @classmethod - def from_osrelease(cls, pakfire, path="/"): - filename = os.path.join(path, "etc", "os-release") + def read_osrelease(self): + filename = os.path.join(self.pakfire.path, "etc", "os-release") if not os.path.exists(filename): - raise Exception, "Could not find %s." % filename + log.warning(_("Could not read %s.") % filename) + return keymap = { "NAME" : "name", @@ -74,7 +77,7 @@ class Distribution(object): data[k] = v f.close() - return cls(pakfire, data) + self.update(data) @property def config(self): @@ -131,7 +134,11 @@ class Distribution(object): @property def vendor(self): - return self._data.get("vendor", "N/A") + vendor = self._data.get("vendor") + if vendor is None: + vendor = "%s Project" % self.name + + return vendor @property def contact(self):