views:

138

answers:

1

Is there an existing python module that can be used to detect which distro of Linux and which version of the distro is currently installed.

For example:

  • RedHat Enterprise 5
  • Fedora 11
  • Suse Enterprise 11
  • etc....

I can make my own module by parsing various files like /etc/redhat-release but I was wondering if a module already exists?

Cheers, Ivan

+8  A: 

Look up the docs for the platform module: http://docs.python.org/library/platform.html

Example:

>>> platform.uname()
('Linux', 'localhost', '2.6.31.5-desktop-1mnb', '#1 SMP Fri Oct 23 00:05:22 EDT 2009', 'x86_64', 'AMD Athlon(tm) 64 X2 Dual Core Processor 3600+')
>>> platform.linux_distribution()
('Mandriva Linux', '2010.0', 'Official')
Antoine P.