TypeError: int() argument must be a string or a number, not 'Popen' Python -
i have these lines using popen
numcpu = sub.popen("($(cat /proc/cpuinfo | grep 'physical id' | awk '{print $nf}' | sort | uniq | wc -l))", shell=true, stdout=sub.pipe, stderr=sub.pipe) numcores = sub.popen("($(cat /proc/cpuinfo | grep 'cpu cores' | awk '{print $nf}' | sort | uniq | wc -l))", shell=true, stdout=sub.pipe, stderr=sub.pipe) numsibling = sub.popen("($(cat /proc/cpuinfo | grep 'siblings' | awk '{print $nf}' | sort | uniq | wc -l))", shell=true, stdout=sub.pipe, stderr=sub.pipe)
but run traceback error
traceback (most recent call last): file "./cputool", line 53, in <module> cputool() file "./cputool", line 45, in cputool numthreads = int(numsibling)/int(numcores) typeerror: int() argument must string or number, not 'popen'
on line
numthreads = int(numsibling)/int(numcores)
i'm new scripting there anyway assign these popen values string or int works? don't think doing simple numcpu== 'anything' works wrong? beginner? nothing can find on here (so) similar cases, work case unfortunately. thanks!
you can read stdout proc_name.stdout.readline()
, convert int
.
numthreads = int(numsibling.stdout.readline())/int(numcores.stdout.readline())
Comments
Post a Comment