5 procFile = open(filename)
11 return "/proc/ide/hd" + ("a","b","c","d","e","f","g","h","i")[num] + "/"
14 def __init__(self, index):
18 bus = (self.index & 2)
19 target = (self.index & 1)
21 self.prochdx = num2prochdx(index)
22 self.devidex = "/dev/ide/host%d/bus%d/target%d/lun0/" % (host, bus, target)
27 procfile = tryOpen(self.prochdx + "capacity")
32 line = procfile.readline()
43 procfile = tryOpen(self.prochdx + "model")
48 line = procfile.readline()
54 procfile = tryOpen("/proc/mounts")
61 line = procfile.readline()
64 if line.startswith(self.devidex):
65 parts = line.strip().split(" ")
67 stat = os.statvfs(parts[1])
70 free = stat.f_bfree/1000 * stat.f_bsize/1000
75 def numPartitions(self):
77 idedir = os.listdir(self.devidex)
81 for filename in idedir:
82 if filename.startswith("disc"):
84 if filename.startswith("part"):
90 mediafile = tryOpen(num2prochdx(num) + "media")
95 line = mediafile.readline()
98 if line.startswith("disk"):
103 class HarddiskManager:
108 if existHDD(hddNum) == 1:
109 self.hdd.append(Harddisk(hddNum))
118 cap = hd.capacity() / 1000 * 512 / 1000
119 hdd = hd.model() + " ("
125 hdd += ", %d,%d GB" % (cap/1024, cap%1024)
128 list.append((hdd, hd))