diff options
| author | Ronny Strutz <ronny.strutz@multimedia-labs.de> | 2005-08-29 22:58:16 +0000 |
|---|---|---|
| committer | Ronny Strutz <ronny.strutz@multimedia-labs.de> | 2005-08-29 22:58:16 +0000 |
| commit | 567412adf1ace2dac175a2f206eef40191f06761 (patch) | |
| tree | 070e0bca61518e52688beb4b91fc40a0b014ce60 /lib/python | |
| parent | bc5fff23f0b5e52e67fa6df82506320523b6771a (diff) | |
| download | enigma2-567412adf1ace2dac175a2f206eef40191f06761.tar.gz enigma2-567412adf1ace2dac175a2f206eef40191f06761.zip | |
add free
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/Components/Harddisk.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index c5ba1344..708bb62e 100644 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -1,4 +1,4 @@ - +import os def tryOpen(filename): try: @@ -10,9 +10,15 @@ def tryOpen(filename): class Harddisk: def __init__(self, index): self.index = index + + host = self.index / 4 + bus = (self.index & 2) + target = (self.index & 1) + #perhaps this is easier? self.prochdx = "/proc/ide/hd" + ("a","b","c","d","e","f","g","h")[index] + "/" - + self.devidex = "/dev/ide/host" + str(host) + "/bus" + str(bus) + "/target" + str(target) + "/lun0/" + def capacity(self): procfile = tryOpen(self.prochdx + "capacity") @@ -41,6 +47,23 @@ class Harddisk: return line def free(self): - pass + procfile = tryOpen("/proc/mounts") -
\ No newline at end of file + if procfile == "": + return -1 + + free = -1 + while 1: + line = procfile.readline() + if line == "": + break + if line.startswith(self.devidex): + parts = line.strip().split(" ") + try: + stat = os.statvfs(parts[1]) + except OSError: + continue + free = stat.f_bfree/1000 * stat.f_bsize/1000 + break + procfile.close() + return free |
