#!/usr/bin/python
+import os
+
import _fireinfo
+PROC_CPUINFO = "/proc/cpuinfo"
+SYS_CLASS_CPUID = "/sys/class/cpuid/cpu%d"
class CPU(object):
__info = _fireinfo.cpuinfo()
def read_cpuinfo(self):
"""
- Read information from /proc/cpuinfo and store
+ Read information from PROC_CPUINFO and store
it into a dictionary self.__cpuinfo.
"""
- f = open("/proc/cpuinfo")
+ f = open(PROC_CPUINFO)
while True:
line = f.readline()
@property
def count(self):
- return int(self.__info["ncpus"])
-
+ """
+ Count number of CPUs (cores).
+ """
+ i = 0
+ while (os.path.exists(SYS_CLASS_CPUID % i)):
+ i += 1
+ return i
if __name__ == "__main__":