문제

How can I get cpuinfo in python 2.4. I want to determine number of processors in a machine. (The code should be OS independent). I have written the code for Linux, but don't know how to make it work for windows.

import subprocess, re
cmd = 'cat /proc/cpuinfo |grep processor |wc'
d = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
lines = d.stdout.readlines()
lines = re.split('\s+', lines[0])
number_of_procs = int(lines[1])

Assuming that I don't have cygwin installed on windows machine, I just have python2.4. Please let me know if there's some module which can be called for this purpose, or any help to write the code for this functionality.

Thanks, Sandhya

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top