You are not logged in.
Pages: 1
Any ideas as to why the last line always equals 0 when it shouldn't?
tmp = os.popen('free -m').readlines()
total = int(tmp[1].split()[1])
used = int(tmp[2].split()[2])
free = int(tmp[2].split()[3])
pused = (int(used) / int(free)) * 100
print pused
Offline
That's because you're doing an integer division. Do this instead:
pused = float(used) / free * 100
Offline
Looks like you have more free space than used space, you should be happy
The division of 2 integers is an integer. The division is always less than 1 in your case, and so the integer which represents it is 0.
Some PKGBUILDs: http://members.lycos.co.uk/sweiss3
Offline
Offline
btw. if you want to do an integer division, you don't have to use int on both operands, just use //.
a = 2.031
b = 3.5 * a
b // a
Offline
Pages: 1