Advertisement
Guest User

Python detect Linux distribution

a guest
Nov 20th, 2010
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. # İsa Mert GÜRBÜZ <isamertgurbuz@gmail.com>
  2. # isamert.wordpress.com
  3.  
  4. class distribution:
  5.     def getvalue(self, x):
  6.         file = open("/etc/lsb-release", 'r')
  7.         rd = file.read().strip()
  8.         file.close()
  9.         lines = rd.split("\n")
  10.         dd = dict((key, value) for key, value in (line.split('=') for line in lines))
  11.         return dd[x]
  12.     def name(self):
  13.         return self.getvalue("DISTRIB_ID")
  14.     def relase(self):
  15.         return self.getvalue("DISTRIB_RELEASE")
  16.     def codename(self):
  17.         return self.getvalue("DISTRIB_CODENAME")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement