Linux distro name parsing

Posted by Ockonal on Stack Overflow See other posts from Stack Overflow or by Ockonal
Published on 2010-05-03T08:23:49Z Indexed on 2010/05/03 8:28 UTC
Read the original article Hit count: 255

Filed under:
|

Hello, I chose this way to get linux distro name:

ls /etc/*release

And now I have to parse it for name:

/etc/<name>-release

def checkDistro():
    p = Popen('ls /etc/*release' , shell = True, stdout = PIPE)
    distroRelease = p.stdout.read()

    distroName = re.search( ur"\/etc\/(.*)\-release", distroRelease).group()
    print distroName

But this prints the same string that is in distroRelease.

© Stack Overflow or respective owner

Related posts about python

Related posts about regexp