>>Single Point of Failure >>

§ Home § CV § Blog Photography Divagações §

Calendar

March 2011
M T W T F S S
« Feb   Apr »
 123456
78910111213
14151617181920
21222324252627
28293031  


Popular Tags


Recent Entries



Categories


Archives

Collecting Linux Distribution

Ξ March 20th, 2011 | → 0 Comments |
Tools |, , |

For me, a really useful tool… I keep it in my dropbox toolbox, always available at ~/bin

#! /usr/bin/env python
#  *************************************************************************
#   Collect the “Release” information for the Linux Distribution
#  *************************************************************************
 
import os
 
issue_redhat = “/etc/redhat-release”
issue_ubuntu = “/etc/issue.net”
issue_debian = “/etc/debian_version”
 
def get_content(file):
    return open(file, “rb”).read()
 
def get_release():
    print ”      System: ” + os.uname()[0]
    print ”     Release: ” + os.uname()[2]
    print “Architecture: ” + os.uname()[4]
    if( os.path.exists(issue_redhat) ):
        distribution = get_content(issue_redhat)
    elif( os.path.exists(issue_ubuntu) ):
        distribution = get_content(issue_ubuntu)
    elif( os.path.exists(issue_debian) ):
        distribution = get_content(issue_debian)
    else:
        distribution = “Unable to find distribution.”
    print “Distribution: ” + distribution
 
if __name__ == “__main__”:
    get_release()

 

No Title

Ξ March 8th, 2011 | → 1 Comments |
Photo |, , |

 


On the nightstand...



Entries | Comments