(self)
return None
Loads OS names and versions.
Loads OS names and versions.
Loads OS names and versions .
def os_distribution_info(self):
        """
        Loads OS names and versions. 
        """
        # patches welcome! feel free to update this for your distribution

        if os.path.exists("/etc/lsb-release"):
            # Debian/Ubuntu.
            data = open("/etc/lsb-release").read().splitlines()
            distribution = None
            release = None
            codename = None
            for line in data:
                if line.startswith("DISTRIB_ID"):
                    distribution = line.split("=")[-1].strip()
                elif line.startswith("DISTRIB_RELEASE"):
                    release = line.split("=")[-1].strip()
                elif line.startswith("DISTRIB_CODENAME"):
                    codename = line.split("=")[-1].strip()
            return dict(distribution=distribution, version=release, variant=codename)
        elif os.path.exists("/etc/redhat-release"):
            # RHEL/CentOS/Scientific Linux/Fedora
            data = open("/etc/redhat-release").read()
            tokens = data.split()
            for (i,t) in enumerate(tokens):
               if '.' in t:
                  break
            distribution = " ".join(tokens[0:i-1])
            variant = " ".join(tokens[i:-1])
            return dict(distribution=distribution, version=tokens[i], variant=variant)
        elif os.path.exists("/etc/system-release"):
            # Amazon Linux. Needs testing. May not be optimal for other distros.
            data = open("/etc/system-release").read().splitlines()
            distribution = None
            release = None
            rdate = None
            for line in data:
                if line.startswith("NAME"):
                    distribution = line.split("=")[-1].strip()
                elif line.startswith("VERSION"):
                    tokens = line.split(None, 2)
                    release = tokens[0]
                    rdate = tokens[1].replace("(","").replace(")","").strip()
            return dict(distribution=distribution, version=release, variant=rdate)
        else:
            if self.system() == "Darwin":
                return dict(distribution="Darwin", version=self.release(), variant=None)
        return None
def os_distribution_info ( self ) : # patches welcome! feel free to update this for your distribution if os . path . exists ( "/etc/lsb-release" ) : # Debian/Ubuntu. data = open ( "/etc/lsb-release" ) . read ( ) . splitlines ( ) distribution = None release = None codename = None for line in data : if line . startswith ( "DISTRIB_ID" ) : distribution = line . split ( "=" ) [ - 1 ] . strip ( ) elif line . startswith ( "DISTRIB_RELEASE" ) : release = line . split ( "=" ) [ - 1 ] . strip ( ) elif line . startswith ( "DISTRIB_CODENAME" ) : codename = line . split ( "=" ) [ - 1 ] . strip ( ) return dict ( distribution = distribution , version = release , variant = codename ) elif os . path . exists ( "/etc/redhat-release" ) : # RHEL/CentOS/Scientific Linux/Fedora data = open ( "/etc/redhat-release" ) . read ( ) tokens = data . split ( ) for ( i , t ) in enumerate ( tokens ) : if '.' in t : break distribution = " " . join ( tokens [ 0 : i - 1 ] ) variant = " " . join ( tokens [ i : - 1 ] ) return dict ( distribution = distribution , version = tokens [ i ] , variant = variant ) elif os . path . exists ( "/etc/system-release" ) : # Amazon Linux. Needs testing. May not be optimal for other distros. data = open ( "/etc/system-release" ) . read ( ) . splitlines ( ) distribution = None release = None rdate = None for line in data : if line . startswith ( "NAME" ) : distribution = line . split ( "=" ) [ - 1 ] . strip ( ) elif line . startswith ( "VERSION" ) : tokens = line . split ( None , 2 ) release = tokens [ 0 ] rdate = tokens [ 1 ] . replace ( "(" , "" ) . replace ( ")" , "" ) . strip ( ) return dict ( distribution = distribution , version = release , variant = rdate ) else : if self . system ( ) == "Darwin" : return dict ( distribution = "Darwin" , version = self . release ( ) , variant = None ) return None