get_cpu_usage workaround for Mac

This commit is contained in:
ha7ilm 2016-03-31 10:08:08 +02:00
parent 09f81ab1e7
commit 30e6dd97fa

View File

@ -617,7 +617,10 @@ last_idletime=0
def get_cpu_usage(): def get_cpu_usage():
global last_worktime, last_idletime global last_worktime, last_idletime
try:
f=open("/proc/stat","r") f=open("/proc/stat","r")
except:
return 0 #Workaround, possibly we're on a Mac
line="" line=""
while not "cpu " in line: line=f.readline() while not "cpu " in line: line=f.readline()
f.close() f.close()