Here is a more concise version of @AndrewWalker's suggestion. It also ensures the presence of "=>" before splitting and removing the final \ n:
import subprocess
p = subprocess.Popen( ['facter'], stdout=subprocess.PIPE )
p.wait()
facts = p.stdout.readlines()
facts = dict(k.split(' => ') for k in [s.strip() for s in facts if ' => ' in s])
print facts["architecture"]
I think I'm going to facterpy . pip install facterpy
then:
import facter
facts = facter.Facter()
print facts["architecture"]
source
share