00001 #!/usr/bin/env python 00002 #Little script to get the number of cpus (cores) in the machine one is running on: 00003 #Information is parsed from /proc/cpuinfo file 00004 import os 00005 00006 def get_NumOfCores(): 00007 cores=0 00008 cpuinfo=open("/proc/cpuinfo","r") 00009 if cpuinfo: 00010 for line in cpuinfo.readlines(): 00011 for token in line.split(): 00012 if token == 'processor': 00013 cores=cores+1; 00014 return cores 00015 else: 00016 print "Could not open file /proc/cpuinfo!\n" 00017 return NULL 00018 #Further functions to parse other information will come (RAM, Cache etc)