def __init__(self, session): Screen.__init__(self, session) self.mdisks = Disks() self.mountpoints = MountPoints() self.mountpoints.read() self.disks = list() self.mounts = list() for disk in self.mdisks.disks: if disk[2] == True: diskname = disk[3] for partition in disk[5]: mp = "" rmp = "" try: mp = self.mountpoints.get(partition[0][:3], int(partition[0][3:])) rmp = self.mountpoints.getRealMount( partition[0][:3], int(partition[0][3:])) except Exception, e: pass if len(mp) > 0: self.disks.append( MountEntry( disk[3], "P.%s (Fixed: %s)" % (partition[0][3:], mp))) self.mounts.append(mp) elif len(rmp) > 0: self.disks.append( MountEntry( disk[3], "P.%s (Fast: %s)" % (partition[0][3:], rmp))) self.mounts.append(rmp)
def __init__(self, session, args = 0): self.session = session Screen.__init__(self, session) self.disks = list () self.mdisks = Disks() for disk in self.mdisks.disks: print ("disk:", disk) capacity = "%d MB" % (disk[1] / (1024 * 1024)) self.disks.append(DiskEntry(disk[3], capacity, disk[2])) self["menu"] = List(self.disks) self["key_red"] = Button(_("Mounts")) self["key_green"] = Button(_("Info")) #self["key_yellow"] = Button(_("Initialize")) self["key_blue"] = Button(_("Exit")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, #"yellow": self.yellow, "green": self.green, "red": self.red, "cancel": self.quit, }, -2)
def chkfs(self): disks = Disks() ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index+1, self.fstype) if ret == 0: self.session.open(MessageBox, _("Check disk terminated with success"), MessageBox.TYPE_INFO) elif ret == -1: self.session.open(MessageBox, _("Cannot umount current drive.\nA record in progress, timeshit or some external tools (like samba and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) else: self.session.open(MessageBox, _("Error checking disk. The disk may be damaged"), MessageBox.TYPE_ERROR)
def refresh(self): self.disks = list() self.mdisks = Disks() for disk in self.mdisks.disks: capacity = "%d MB" % (disk[1] / (1024 * 1024)) self.disks.append(DiskEntry(disk[3], capacity, disk[2])) self["menu"].setList(self.disks)
def mkfs(self): disks = Disks() if "mmcblk1" in (self.disk[0]): ret = disks.mkfs(self.disk[5][self.index][0][:7], self.index+1, self.fstype) print "ret1", ret else: ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index+1, self.fstype) print "ret2", ret if ret == 0: self.session.open(MessageBox, _("Format terminated with success"), MessageBox.TYPE_INFO) elif ret == -2: self.session.open(MessageBox, _("Cannot format current drive.\nA record in progress, timeshit or some external tools (like samba and nfsd) may cause this problem.\nPlease stop this actions/applications and try again"), MessageBox.TYPE_ERROR) else: self.session.open(MessageBox, _("Error formatting disk. The disk may be damaged"), MessageBox.TYPE_ERROR)
def __init__(self, session): Screen.__init__(self, session) self.mdisks = Disks() self.mountpoints = MountPoints() self.mountpoints.read() self.disks = list() self.mounts = list() for disk in self.mdisks.disks: if disk[2] == True: diskname = disk[3] for partition in disk[5]: mp = "" rmp = "" try: if "mmcblk1" in partition[0][:7]: mp = self.mountpoints.get(partition[0][:7], int(partition[0][8:])) rmp = self.mountpoints.getRealMount( partition[0][:7], int(partition[0][8:])) else: mp = self.mountpoints.get(partition[0][:3], int(partition[0][3:])) rmp = self.mountpoints.getRealMount( partition[0][:3], int(partition[0][3:])) except Exception as e: pass if len(mp) > 0: if "mmcblk1" in partition[0][:7]: self.disks.append( MountEntry( disk[3], "P.%s (Fixed: %s)" % (partition[0][7:], mp))) self.mounts.append(mp) else: self.disks.append( MountEntry( disk[3], "P.%s (Fixed: %s)" % (partition[0][3:], mp))) self.mounts.append(mp) elif len(rmp) > 0: if "mmcblk1" in partition[0][:7]: self.disks.append( MountEntry( disk[3], "P.%s (Fast: %s)" % (partition[0][7:], rmp))) self.mounts.append(rmp) else: self.disks.append( MountEntry( disk[3], "P.%s (Fast: %s)" % (partition[0][3:], rmp))) self.mounts.append(rmp) self["menu"] = List(self.disks) self["key_red"] = Button(_("Umount")) self["key_blue"] = Button(_("Exit")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "blue": self.quit, "red": self.red, "cancel": self.quit, }, -2)