3 from Tools.Directories import *
7 procFile = open(filename)
13 return "/proc/ide/hd" + ("a","b","c","d","e","f","g","h","i")[num] + "/"
16 def __init__(self, index):
20 bus = (self.index & 2)
21 target = (self.index & 1)
23 self.prochdx = num2prochdx(index)
24 self.devidex = "/dev/ide/host%d/bus%d/target%d/lun0/" % (host, bus, target)
33 ret = "External (CF) - "
43 procfile = tryOpen(self.prochdx + "capacity")
48 line = procfile.readline()
56 cap = cap / 1000 * 512 / 1000
58 return "%d.%03d GB" % (cap/1024, cap%1024)
61 procfile = tryOpen(self.prochdx + "model")
66 line = procfile.readline()
72 procfile = tryOpen("/proc/mounts")
79 line = procfile.readline()
82 if line.startswith(self.devidex):
83 parts = line.strip().split(" ")
85 stat = os.statvfs(parts[1])
88 free = stat.f_bfree/1000 * stat.f_bsize/1000
93 def numPartitions(self):
95 idedir = os.listdir(self.devidex)
99 for filename in idedir:
100 if filename.startswith("disc"):
102 if filename.startswith("part"):
107 cmd = "/bin/umount " + self.devidex + "part*"
111 def createPartition(self):
112 cmd = "/sbin/sfdisk -f " + self.devidex + "disc"
113 sfdisk = os.popen(cmd, "w")
114 sfdisk.write("0,\n;\n;\n;\ny\n")
119 cmd = "/sbin/mkfs.ext3 -T largefile -m0 " + self.devidex + "part1"
124 cmd = "/bin/mount -t ext3 " + self.devidex + "part1 /hdd"
128 def createMovieFolder(self):
129 res = os.system("mkdir " + resolveFilename(SCOPE_HDD))
132 errorList = [ _("Everything is fine"), _("Creating partition failed"), _("Mkfs failed"), _("Mount failed"), _("Create movie folder failed"), _("Unmount failed")]
134 def initialize(self):
137 if self.createPartition() != 0:
143 if self.mount() != 0:
146 if self.createMovieFolder() != 0:
152 mediafile = tryOpen(num2prochdx(num) + "media")
157 line = mediafile.readline()
160 if line.startswith("disk"):
165 class HarddiskManager:
170 if existHDD(hddNum) == 1:
171 self.hdd.append(Harddisk(hddNum))
186 hdd = hd.model() + " ("
192 list.append((hdd, hd))
196 harddiskmanager = HarddiskManager()