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:
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
The easiest way to check Python version in Linux is using python -V command. All we need is to open the terminal then type python -V in the prompt.
The distro package ( distro stands for Linux Distribution) provides information about the Linux distribution it runs on, such as a reliable machine-readable distro ID, or version information. It is the recommended replacement for Python's original platform.
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With