makefile
[arrocco.git] / cpu.py
blobaf7b56c17db6b3160da78acd35af10c240a11245
1 # cpu.py
2 # August 2007
4 """
5 This file is part of Arrocco, which is Copyright 2007 Thomas Plick
6 (tomplick 'at' gmail.com).
8 Arrocco is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 Arrocco is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """
22 import os, subprocess
24 def count_cpus_x():
25 command = ['grep', '-cw', '^processor', '/proc/cpuinfo']
26 proc = subprocess.Popen(command, stdout = subprocess.PIPE)
27 return int(proc.communicate()[0].strip())
29 def count_cpus():
30 try:
31 return count_cpus_x()
32 except:
33 return 1