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)
25 procfile = tryOpen(self.prochdx + "capacity")
30 line = procfile.readline()
41 procfile = tryOpen(self.prochdx + "model")
46 line = procfile.readline()
52 procfile = tryOpen("/proc/mounts")
59 line = procfile.readline()
62 if line.startswith(self.devidex):
63 parts = line.strip().split(" ")
65 stat = os.statvfs(parts[1])
68 free = stat.f_bfree/1000 * stat.f_bsize/1000
73 def numPartitions(self):
75 idedir = os.listdir(self.devidex)
79 for filename in idedir:
80 if filename.startswith("disc"):
82 if filename.startswith("part"):
87 cmd = "/bin/umount " + self.devidex + "part*"
90 def createPartition(self):
91 cmd = "/sbin/sfdisk -f " + self.devidex + "disc"
92 sfdisk = os.popen(cmd, "w")
93 sfdisk.write("0,\n;\n;\n;\ny\n")
98 cmd = "/sbin/mkfs.ext3 -T largefile -m0 " + self.devidex + "part1"
103 cmd = "/bin/mount -t ext3 " + self.devidex + "part1 /hdd"
107 def createMovieFolder(self):
108 res = os.system("mkdir /hdd/movie")
111 def initialize(self):
114 if self.createPartition() != 0:
120 if self.mount() != 0:
123 if self.createMovieFolder() != 0:
129 mediafile = tryOpen(num2prochdx(num) + "media")
134 line = mediafile.readline()
137 if line.startswith("disk"):
142 class HarddiskManager:
147 if existHDD(hddNum) == 1:
148 self.hdd.append(Harddisk(hddNum))
157 cap = hd.capacity() / 1000 * 512 / 1000
158 hdd = hd.model() + " ("
164 hdd += ", %d,%d GB" % (cap/1024, cap%1024)
170 # if hd.initialize() == 0:
171 # print "hdd status ok"
173 # print "hdd status ok"
175 list.append((hdd, hd))