Exemple #1
0
 def __init__(self, session, device, partition):
     Screen.__init__(self, session)
     self.device = device
     self.partition = partition
     self.mountpoints = MountPoints()
     self.mountpoints.read()
     self.list = []
     self.list.append('Mount as main hdd')
     self.list.append('Mount as /media/usb')
     self.list.append('Mount as /media/usb1')
     self.list.append('Mount as /media/usb2')
     self.list.append('Mount as /media/usb3')
     self.list.append('Mount as /media/cf')
     self.list.append('Mount as /media/mmc1')
     self.list.append('Mount on custom path')
     self['menu'] = MenuList(self.list)
     self['key_green'] = Button('')
     self['key_red'] = Button(_('Ok'))
     self['key_blue'] = Button(_('Exit'))
     self['key_yellow'] = Button('')
     self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'blue': self.quit,
      'red': self.ok,
      'ok': self.ok,
      'cancel': self.quit}, -2)
     self.onShown.append(self.setWindowTitle)
Exemple #2
0
	def __init__(self, session, device, partition):
		Screen.__init__(self, session)
		
		self.device = device
		self.partition = partition
		self.mountpoints = MountPoints()
		self.mountpoints.read()
		self.fast = False
		
		self.list = []
		self.list.append("Mount as main hdd")
		self.list.append("Mount as /media/usb")
		self.list.append("Mount as /media/usb1")
		self.list.append("Mount as /media/usb2")
		self.list.append("Mount as /media/usb3")
		self.list.append("Mount as /media/cf")
		self.list.append("Mount as /media/mmc1")
		self.list.append("Mount on custom path")
		
		self["menu"] = MenuList(self.list)
		
		self["key_red"] = Button(_("Fixed mount"))
		self["key_green"] = Button("Fast mount")
		self["key_blue"] = Button(_("Exit"))
		self["key_yellow"] = Button("")
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"blue": self.quit,
			"green": self.green,
			"ok": self.ok,
			"red": self.ok,
			"cancel": self.quit,
		}, -2)
    def refreshMP(self, uirefresh=True):
        self.partitions = []
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        count = 1
        for part in self.disk[5]:
            capacity = "%d MB" % (part[1] / (1024 * 1024))
            mp = self.mountpoints.get(self.disk[0], count)
            rmp = self.mountpoints.getRealMount(self.disk[0], count)
            if len(mp) > 0:
                self.partitions.append(
                    PartitionEntry(
                        "P. %d - %s (Fixed: %s)" % (count, part[2], mp),
                        capacity))
            elif len(rmp) > 0:
                self.partitions.append(
                    PartitionEntry(
                        "P. %d - %s (Fast: %s)" % (count, part[2], rmp),
                        capacity))
            else:
                self.partitions.append(
                    PartitionEntry("P. %d - %s" % (count, part[2]), capacity))
            count += 1

        if uirefresh:
            self["menu"].setList(self.partitions)
Exemple #4
0
class HddFastRemove(Screen):
	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)
						
		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)
Exemple #5
0
class HddFastRemove(Screen):
	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)
						
		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)
Exemple #6
0
	def checkDefault(self):
		mp = MountPoints()
		mp.read()
		if not mp.exist("/hdd"):
			mp.add(self.mdisks.disks[self.sindex][0], 1, "/hdd")
			mp.write()
			mp.mount(self.mdisks.disks[self.sindex][0], 1, "/hdd")
			os.system("/bin/mkdir /hdd/movie")
			os.system("/bin/mkdir /hdd/music")
			os.system("/bin/mkdir /hdd/picture")
Exemple #7
0
	def __init__(self, session, device, partition):
		Screen.__init__(self, session)
		
		self.device = device
		self.partition = partition
		self.mountpoints = MountPoints()
		self.mountpoints.read()
		self.fast = False
		
		self.list = []
		self.list.append("Mount as main hdd")
		self.list.append("Mount as /media/usb")
		self.list.append("Mount as /media/usb1")
		self.list.append("Mount as /media/usb2")
		self.list.append("Mount as /media/usb3")
		self.list.append("Mount as /media/cf")
		self.list.append("Mount as /media/mmc1")
		self.list.append("Mount on custom path")
		
		self["menu"] = MenuList(self.list)
		
		self["key_red"] = Button(_("Fixed mount"))
		self["key_green"] = Button("Fast mount")
		self["key_blue"] = Button(_("Exit"))
		self["key_yellow"] = Button("")
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"blue": self.quit,
			"green": self.green,
			"red": self.ok,
			"cancel": self.quit,
		}, -2)
Exemple #8
0
 def initialaze(self, result):
     if result != 5:
         self.result = result
         self.formatted = 0
         mp = MountPoints()
         mp.read()
         mp.deleteDisk(self.mdisks.disks[self.sindex][0])
         mp.write()
         self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, _('Partitioning...'), _('Initialize disk'), self.fdisk)
Exemple #9
0
	def initialaze(self, result):
		if result != 5:
			self.result = result
			self.formatted = 0
			mp = MountPoints()
			mp.read()
			mp.deleteDisk(self.mdisks.disks[self.sindex][0])
			mp.write()
			self.session.openWithCallback(self.fdiskEnded, ExtraActionBox, "Partitioning...", "Initialize disk", self.fdisk)
    def refreshMP(self, uirefresh=True):
        self.partitions = []
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        count = 1
        for part in self.disk[5]:
            capacity = '%d MB' % (part[1] / 1048576)
            mp = self.mountpoints.get(self.disk[0], count)
            if len(mp) > 0:
                self.partitions.append(
                    PartitionEntry(
                        'Partition %d - %s (%s)' % (count, part[2], mp),
                        capacity))
            else:
                self.partitions.append(
                    PartitionEntry('Partition %d - %s' % (count, part[2]),
                                   capacity))
            count += 1

        if uirefresh:
            self['menu'].setList(self.partitions)
Exemple #11
0
    def initialaze(self, result):
        if not self.isExt4Supported():
            result += 1

        if result != 4:
            self.fsresult = result
            self.formatted = 0
            mp = MountPoints()
            mp.read()
            mp.deleteDisk(self.mdisks.disks[self.sindex][0])
            mp.write()
            self.session.openWithCallback(self.fdiskEnded, ExtraActionBox,
                                          "Partitioning...", "Initialize disk",
                                          self.fdisk)
Exemple #12
0
	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)
Exemple #13
0
    def refreshMP(self, uirefresh = True):
        self.partitions = []
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        count = 1
        for part in self.disk[5]:
            capacity = '%d MB' % (part[1] / 1048576)
            mp = self.mountpoints.get(self.disk[0], count)
            if len(mp) > 0:
                self.partitions.append(PartitionEntry('Partition %d - %s (%s)' % (count, part[2], mp), capacity))
            else:
                self.partitions.append(PartitionEntry('Partition %d - %s' % (count, part[2]), capacity))
            count += 1

        if uirefresh:
            self['menu'].setList(self.partitions)
Exemple #14
0
	def refreshMP(self, uirefresh = True):
		self.partitions = []
		self.mountpoints = MountPoints()
		self.mountpoints.read()
		count = 1
		for part in self.disk[5]:
			capacity = "%d MB" % (part[1] / (1024 * 1024))
			mp = self.mountpoints.get(self.disk[0], count)
			rmp = self.mountpoints.getRealMount(self.disk[0], count)
			if len(mp) > 0:
				self.partitions.append(PartitionEntry("P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity))
			elif len(rmp) > 0:
				self.partitions.append(PartitionEntry("P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity))
			else:
				self.partitions.append(PartitionEntry("P. %d - %s" % (count, part[2]), capacity))
			count += 1
		
		if uirefresh:
			self["menu"].setList(self.partitions)
Exemple #15
0
	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)
class HddPartitions(Screen):
    def __init__(self, session, disk):
        self.session = session

        Screen.__init__(self, session)
        self.disk = disk
        self.refreshMP(False)

        self["menu"] = List(self.partitions)
        self["menu"].onSelectionChanged.append(self.selectionChanged)
        self["key_red"] = Button("")
        self["key_green"] = Button("")
        self["key_yellow"] = Button("")
        self["key_blue"] = Button(_("Exit"))
        self["label_disk"] = Label("%s - %s" % (self.disk[0], self.disk[3]))
        self["actions"] = ActionMap(
            ["OkCancelActions", "ColorActions"], {
                "blue": self.quit,
                "yellow": self.yellow,
                "green": self.green,
                "red": self.red,
                "cancel": self.quit,
            }, -2)

        if len(self.disk[5]) > 0:
            if self.disk[5][0][3] == "83" or self.disk[5][0][
                    3] == "7" or self.disk[5][0][3] == "b":
                self["key_green"].setText(_("Check"))
                self["key_yellow"].setText(_("Format"))

                mp = self.mountpoints.get(self.disk[0], 1)
                rmp = self.mountpoints.getRealMount(self.disk[0], 1)
                if len(mp) > 0 or len(rmp) > 0:
                    self.mounted = True
                    self["key_red"].setText(_("Umount"))
                else:
                    self.mounted = False
                    self["key_red"].setText(_("Mount"))

    def selectionChanged(self):
        self["key_green"].setText("")
        self["key_yellow"].setText("")
        self["key_red"].setText("")

        if len(self.disk[5]) > 0:
            index = self["menu"].getIndex()
            if self.disk[5][index][3] == "83" or self.disk[5][index][
                    3] == "7" or self.disk[5][index][3] == "b":
                self["key_green"].setText(_("Check"))
                self["key_yellow"].setText(_("Format"))

                mp = self.mountpoints.get(self.disk[0], index + 1)
                rmp = self.mountpoints.getRealMount(self.disk[0], index + 1)
                if len(mp) > 0 or len(rmp) > 0:
                    self.mounted = True
                    self["key_red"].setText(_("Umount"))
                else:
                    self.mounted = False
                    self["key_red"].setText(_("Mount"))

    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 mkfs(self):
        disks = Disks()
        ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index + 1,
                         self.fstype)
        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 isExt4Supported(self):
        return "ext4" in open("/proc/filesystems").read()

    def domkfs(self, result):
        if self.disk[5][self.index][3] == "83":
            if self.isExt4Supported():
                if result < 2:
                    self.fstype = result
                    self.session.open(
                        ExtraActionBox,
                        "Formatting disk %s" % self.disk[5][self.index][0],
                        "Formatting disk", self.mkfs)
            else:
                if result < 1:
                    self.fstype = 1
                    self.session.open(
                        ExtraActionBox,
                        "Formatting disk %s" % self.disk[5][self.index][0],
                        "Formatting disk", self.mkfs)
        elif self.disk[5][self.index][3] == "7":
            if result < 1:
                self.fstype = 2
                self.session.open(
                    ExtraActionBox,
                    "Formatting disk %s" % self.disk[5][self.index][0],
                    "Formatting disk", self.mkfs)
        elif self.disk[5][self.index][3] == "b":
            if result < 1:
                self.fstype = 3
                self.session.open(
                    ExtraActionBox,
                    "Formatting disk %s" % self.disk[5][self.index][0],
                    "Formatting disk", self.mkfs)

    def green(self):
        if len(self.disk[5]) > 0:
            index = self["menu"].getIndex()
            if self.disk[5][index][3] == "83" or self.disk[5][index][
                    3] == "7" or self.disk[5][index][3] == "b":
                self.index = index
                if self.disk[5][index][3] == "83":
                    self.fstype = 0
                elif self.disk[5][index][3] == "7":
                    self.fstype = 2
                elif self.disk[5][index][3] == "b":
                    self.fstype = 3
                self.session.open(ExtraActionBox,
                                  "Checking disk %s" % self.disk[5][index][0],
                                  "Checking disk", self.chkfs)

    def yellow(self):
        if len(self.disk[5]) > 0:
            self.index = self["menu"].getIndex()
            if self.disk[5][self.index][3] == "83":
                if self.isExt4Supported():
                    self.session.openWithCallback(
                        self.domkfs, ExtraMessageBox, "Format as",
                        "HDD Partitioner", [
                            ["Ext4", "partitionmanager.png"],
                            ["Ext3", "partitionmanager.png"],
                            ["Cancel", "cancel.png"],
                        ], 1, 2)
                else:
                    self.session.openWithCallback(
                        self.domkfs, ExtraMessageBox, "Format as",
                        "HDD Partitioner", [
                            ["Ext3", "partitionmanager.png"],
                            ["Cancel", "cancel.png"],
                        ], 1, 1)
            elif self.disk[5][self.index][3] == "7":
                self.session.openWithCallback(
                    self.domkfs, ExtraMessageBox, "Format as",
                    "HDD Partitioner", [
                        ["NTFS", "partitionmanager.png"],
                        ["Cancel", "cancel.png"],
                    ], 1, 1)
            elif self.disk[5][self.index][3] == "b":
                self.session.openWithCallback(
                    self.domkfs, ExtraMessageBox, "Format as",
                    "HDD Partitioner", [
                        ["Fat32", "partitionmanager.png"],
                        ["Cancel", "cancel.png"],
                    ], 1, 1)

    def refreshMP(self, uirefresh=True):
        self.partitions = []
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        count = 1
        for part in self.disk[5]:
            capacity = "%d MB" % (part[1] / (1024 * 1024))
            mp = self.mountpoints.get(self.disk[0], count)
            rmp = self.mountpoints.getRealMount(self.disk[0], count)
            if len(mp) > 0:
                self.partitions.append(
                    PartitionEntry(
                        "P. %d - %s (Fixed: %s)" % (count, part[2], mp),
                        capacity))
            elif len(rmp) > 0:
                self.partitions.append(
                    PartitionEntry(
                        "P. %d - %s (Fast: %s)" % (count, part[2], rmp),
                        capacity))
            else:
                self.partitions.append(
                    PartitionEntry("P. %d - %s" % (count, part[2]), capacity))
            count += 1

        if uirefresh:
            self["menu"].setList(self.partitions)

    def red(self):
        if len(self.disk[5]) > 0:
            index = self["menu"].getIndex()
            if self.disk[5][index][3] != "83" and self.disk[5][index][
                    3] != "7" and self.disk[5][index][3] != "b":
                return

        if len(self.partitions) > 0:
            self.sindex = self['menu'].getIndex()
            if self.mounted:
                mp = self.mountpoints.get(self.disk[0], self.sindex + 1)
                rmp = self.mountpoints.getRealMount(self.disk[0],
                                                    self.sindex + 1)
                if len(mp) > 0:
                    if self.mountpoints.isMounted(mp):
                        if self.mountpoints.umount(mp):
                            self.mountpoints.delete(mp)
                            self.mountpoints.write()
                        else:
                            self.session.open(
                                MessageBox,
                                _("Cannot umount device.\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.mountpoints.delete(mp)
                        self.mountpoints.write()
                elif len(rmp) > 0:
                    self.mountpoints.umount(rmp)
                self.refreshMP()
            else:
                self.session.openWithCallback(self.refreshMP, HddMount,
                                              self.disk[0], self.sindex + 1)

    def quit(self):
        self.close()
Exemple #17
0
class HddPartitions(Screen):
	def __init__(self, session, disk):
		self.session = session
		
		Screen.__init__(self, session)
		self.disk = disk
		self.refreshMP(False)
		
		self["menu"] = List(self.partitions)
		self["menu"].onSelectionChanged.append(self.selectionChanged)
		self["key_red"] = Button("")
		self["key_green"] = Button("")
		self["key_yellow"] = Button("")
		self["key_blue"] = Button(_("Exit"))
		self["label_disk"] = Label("%s - %s" % (self.disk[0], self.disk[3]))
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"blue": self.quit,
			"yellow": self.yellow,
			"green": self.green,
			"red": self.red,
			"cancel": self.quit,
		}, -2)
		
		if len(self.disk[5]) > 0:
			if self.disk[5][0][2] == "Linux":
				self["key_green"].setText(_("Check"))
				self["key_yellow"].setText(_("Format"))
				
		if self.disk[5][0][2] == "Linux swap":
			self["key_red"].setText("")
		else:
			mp = self.mountpoints.get(self.disk[0], 1)
			rmp = self.mountpoints.getRealMount(self.disk[0], 1)
			if len(mp) > 0 or len(rmp) > 0:
				self.mounted = True
				self["key_red"].setText(_("Umount"))
			else:
				self.mounted = False
				self["key_red"].setText(_("Mount"))
		
	def selectionChanged(self):
		self["key_green"].setText("")
		self["key_yellow"].setText("")
		if len(self.disk[5]) > 0:
			index = self["menu"].getIndex()
			if self.disk[5][index][2] == "Linux":
				self["key_green"].setText(_("Check"))
				self["key_yellow"].setText(_("Format"))
				
			if self.disk[5][index][2] == "Linux swap":
				self["key_red"].setText("")
			else:
				mp = self.mountpoints.get(self.disk[0], index+1)
				rmp = self.mountpoints.getRealMount(self.disk[0], index+1)
				if len(mp) > 0 or len(rmp) > 0:
					self.mounted = True
					self["key_red"].setText(_("Umount"))
				else:
					self.mounted = False
					self["key_red"].setText(_("Mount"))
				
	def chkfs(self):
		disks = Disks()
		ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index+1)
		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 mkfs(self):
		disks = Disks()
		ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index+1)
		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 green(self):
		if len(self.disk[5]) > 0:
			index = self["menu"].getIndex()
			if self.disk[5][index][2] == "Linux":
				self.index = index
				self.session.open(ExtraActionBox, "Checking disk %s" % self.disk[5][index][0], "Checking disk", self.chkfs)
				
	def yellow(self):
		if len(self.disk[5]) > 0:
			index = self["menu"].getIndex()
			if self.disk[5][index][2] == "Linux":
				self.index = index
				self.session.open(ExtraActionBox, "Formatting disk %s" % self.disk[5][index][0], "Formatting disk", self.mkfs)
				
	def refreshMP(self, uirefresh = True):
		self.partitions = []
		self.mountpoints = MountPoints()
		self.mountpoints.read()
		count = 1
		for part in self.disk[5]:
			capacity = "%d MB" % (part[1] / (1024 * 1024))
			mp = self.mountpoints.get(self.disk[0], count)
			rmp = self.mountpoints.getRealMount(self.disk[0], count)
			if len(mp) > 0:
				self.partitions.append(PartitionEntry("P. %d - %s (Fixed: %s)" % (count, part[2], mp), capacity))
			elif len(rmp) > 0:
				self.partitions.append(PartitionEntry("P. %d - %s (Fast: %s)" % (count, part[2], rmp), capacity))
			else:
				self.partitions.append(PartitionEntry("P. %d - %s" % (count, part[2]), capacity))
			count += 1
		
		if uirefresh:
			self["menu"].setList(self.partitions)
		
	def red(self):
		if len(self.disk[5]) > 0:
			index = self["menu"].getIndex()
			if self.disk[5][index][2] == "Linux swap":
				return
				
		if len(self.partitions) > 0:
			self.sindex = self['menu'].getIndex()
			if self.mounted:
				mp = self.mountpoints.get(self.disk[0], self.sindex+1)
				rmp = self.mountpoints.getRealMount(self.disk[0], self.sindex+1)
				if len(mp) > 0:
					if self.mountpoints.isMounted(mp):
						if self.mountpoints.umount(mp):
							self.mountpoints.delete(mp)
							self.mountpoints.write()
						else:
							self.session.open(MessageBox, _("Cannot umount device.\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.mountpoints.delete(mp)
						self.mountpoints.write()
				elif len(rmp) > 0:
					self.mountpoints.umount(rmp)
				self.refreshMP()
			else:
				self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex+1)
		
	def quit(self):
		self.close()
Exemple #18
0
class HddMount(Screen):
	def __init__(self, session, device, partition):
		Screen.__init__(self, session)
		
		self.device = device
		self.partition = partition
		self.mountpoints = MountPoints()
		self.mountpoints.read()
		self.fast = False
		
		self.list = []
		self.list.append("Mount as main hdd")
		self.list.append("Mount as /media/usb")
		self.list.append("Mount as /media/usb1")
		self.list.append("Mount as /media/usb2")
		self.list.append("Mount as /media/usb3")
		self.list.append("Mount as /media/cf")
		self.list.append("Mount as /media/mmc1")
		self.list.append("Mount on custom path")
		
		self["menu"] = MenuList(self.list)
		
		self["key_red"] = Button(_("Fixed mount"))
		self["key_green"] = Button("Fast mount")
		self["key_blue"] = Button(_("Exit"))
		self["key_yellow"] = Button("")
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"blue": self.quit,
			"green": self.green,
			"red": self.ok,
			"cancel": self.quit,
		}, -2)
		
	def ok(self):
		self.fast = False
		selected = self["menu"].getSelectedIndex()
		if selected == 0:
			self.setMountPoint("/media/hdd")
		elif selected == 1:
			self.setMountPoint("/media/usb")
		elif selected == 2:
			self.setMountPoint("/media/usb1")
		elif selected == 3:
			self.setMountPoint("/media/usb2")
		elif selected == 4:
			self.setMountPoint("/media/usb3")
		elif selected == 5:
			self.setMountPoint("/media/cf")
		elif selected == 6:
			self.setMountPoint("/media/mmc1")
		elif selected == 7:
			self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = "/media/custom")
			
	def green(self):
		self.fast = True
		selected = self["menu"].getSelectedIndex()
		if selected == 0:
			self.setMountPoint("/media/hdd")
		elif selected == 1:
			self.setMountPoint("/media/usb")
		elif selected == 2:
			self.setMountPoint("/media/usb1")
		elif selected == 3:
			self.setMountPoint("/media/usb2")
		elif selected == 4:
			self.setMountPoint("/media/usb3")
		elif selected == 5:
			self.setMountPoint("/media/cf")
		elif selected == 6:
			self.setMountPoint("/media/mmc1")
		elif selected == 7:
			self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = "/media/custom")
		
	def customPath(self, result):
		if result and len(result) > 0:
			result = result.rstrip("/")
			os.system("mkdir -p %s" % result)
			self.setMountPoint(result)
		
	def setMountPoint(self, path):
		self.cpath = path
		if self.mountpoints.exist(path):
			self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, "Selected mount point is already used by another drive.", "Mount point exist!",
																[ [ "Change old drive with this new drive", "ok.png" ],
																[ "Mantain old drive", "cancel.png" ],
																])
		else:
			self.setMountPointCb(0)
			
	def setMountPointCb(self, result):
		if result == 0:
			if self.mountpoints.isMounted(self.cpath):
				if not self.mountpoints.umount(self.cpath):
					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)
					self.close()
					return
			self.mountpoints.delete(self.cpath)
			if not self.fast:
				self.mountpoints.add(self.device, self.partition, self.cpath)
			self.mountpoints.write()
			if not self.mountpoints.mount(self.device, self.partition, self.cpath):
				self.session.open(MessageBox, _("Cannot mount new drive.\nPlease check filesystem or format it and try again"), MessageBox.TYPE_ERROR)
			elif self.cpath == "/media/hdd":
				os.system("/bin/mkdir /hdd/movie")
				os.system("/bin/mkdir /hdd/music")
				os.system("/bin/mkdir /hdd/picture")

			self.close()
	
	def quit(self):
		self.close()
Exemple #19
0
class HddMount(Screen):
	def __init__(self, session, device, partition):
		Screen.__init__(self, session)
		
		self.device = device
		self.partition = partition
		self.mountpoints = MountPoints()
		self.mountpoints.read()
		self.fast = False
		
		self.list = []
		self.list.append("Mount as main hdd")
		self.list.append("Mount as /media/usb")
		self.list.append("Mount as /media/usb1")
		self.list.append("Mount as /media/usb2")
		self.list.append("Mount as /media/usb3")
		self.list.append("Mount as /media/cf")
		self.list.append("Mount as /media/mmc1")
		self.list.append("Mount on custom path")
		
		self["menu"] = MenuList(self.list)
		
		self["key_red"] = Button(_("Fixed mount"))
		self["key_green"] = Button("Fast mount")
		self["key_blue"] = Button(_("Exit"))
		self["key_yellow"] = Button("")
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"blue": self.quit,
			"green": self.green,
			"ok": self.ok,
			"red": self.ok,
			"cancel": self.quit,
		}, -2)
		
	def ok(self):
		self.fast = False
		selected = self["menu"].getSelectedIndex()
		if selected == 0:
			self.setMountPoint("/media/hdd")
		elif selected == 1:
			self.setMountPoint("/media/usb")
		elif selected == 2:
			self.setMountPoint("/media/usb1")
		elif selected == 3:
			self.setMountPoint("/media/usb2")
		elif selected == 4:
			self.setMountPoint("/media/usb3")
		elif selected == 5:
			self.setMountPoint("/media/cf")
		elif selected == 6:
			self.setMountPoint("/media/mmc1")
		elif selected == 7:
			self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = "/media/custom")
			
	def green(self):
		self.fast = True
		selected = self["menu"].getSelectedIndex()
		if selected == 0:
			self.setMountPoint("/media/hdd")
		elif selected == 1:
			self.setMountPoint("/media/usb")
		elif selected == 2:
			self.setMountPoint("/media/usb1")
		elif selected == 3:
			self.setMountPoint("/media/usb2")
		elif selected == 4:
			self.setMountPoint("/media/usb3")
		elif selected == 5:
			self.setMountPoint("/media/cf")
		elif selected == 6:
			self.setMountPoint("/media/mmc1")
		elif selected == 7:
			self.session.openWithCallback(self.customPath, VirtualKeyBoard, title = (_("Insert mount point:")), text = "/media/custom")
		
	def customPath(self, result):
		if result and len(result) > 0:
			result = result.rstrip("/")
			os.system("mkdir -p %s" % result)
			self.setMountPoint(result)
		
	def setMountPoint(self, path):
		self.cpath = path
		if self.mountpoints.exist(path):
			self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, "Selected mount point is already used by another drive.", "Mount point exist!",
																[ [ "Change old drive with this new drive", "ok.png" ],
																[ "Mantain old drive", "cancel.png" ],
																])
		else:
			self.setMountPointCb(0)
			
	def setMountPointCb(self, result):
		if result == 0:
			if self.mountpoints.isMounted(self.cpath):
				if not self.mountpoints.umount(self.cpath):
					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)
					self.close()
					return
			self.mountpoints.delete(self.cpath)
			if not self.fast:
				self.mountpoints.add(self.device, self.partition, self.cpath)
			self.mountpoints.write()
			if not self.mountpoints.mount(self.device, self.partition, self.cpath):
				self.session.open(MessageBox, _("Cannot mount new drive.\nPlease check filesystem or format it and try again"), MessageBox.TYPE_ERROR)
			elif self.cpath == "/media/hdd":
				os.system("/bin/mkdir /hdd/movie")
				os.system("/bin/mkdir /hdd/music")
				os.system("/bin/mkdir /hdd/picture")

			self.close()
	
	def quit(self):
		self.close()
 def checkDefault(self):
     mp = MountPoints()
     mp.read()
     if not mp.exist('/hdd'):
         mp.add(self.mdisks.disks[self.sindex][0], 1, '/hdd')
         mp.write()
         mp.mount(self.mdisks.disks[self.sindex][0], 1, '/hdd')
         Console().ePopen('mkdir /hdd/movie')
         Console().ePopen('mkdir /hdd/music')
         Console().ePopen('mkdir /hdd/picture')
Exemple #21
0
class HddMount(Screen):

    def __init__(self, session, device, partition):
        Screen.__init__(self, session)
        self.device = device
        self.partition = partition
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        self.list = []
        self.list.append('Mount as main hdd')
        self.list.append('Mount as /media/usb')
        self.list.append('Mount as /media/usb1')
        self.list.append('Mount as /media/usb2')
        self.list.append('Mount as /media/usb3')
        self.list.append('Mount as /media/cf')
        self.list.append('Mount as /media/mmc1')
        self.list.append('Mount on custom path')
        self['menu'] = MenuList(self.list)
        self['key_green'] = Button('')
        self['key_red'] = Button(_('Ok'))
        self['key_blue'] = Button(_('Exit'))
        self['key_yellow'] = Button('')
        self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'blue': self.quit,
         'red': self.ok,
         'ok': self.ok,
         'cancel': self.quit}, -2)
        self.onShown.append(self.setWindowTitle)

    def setWindowTitle(self):
        self.setTitle(_('Devicemanager Mountpoints'))

    def ok(self):
        try:
            os.chmod('/usr/bin/mountct', 493)
            os.chmod('/etc/init.d/mountctall', 493)
            os.symlink('/etc/init.d/mountctall', '/etc/rcS.d/S49mountctall')
        except OSError:
            print '[CTPanel] symlink already exists. do nothing.'

        selected = self['menu'].getSelectedIndex()
        if selected == 0:
            self.setMountPoint('/media/hdd')
        elif selected == 1:
            self.setMountPoint('/media/usb')
        elif selected == 2:
            self.setMountPoint('/media/usb1')
        elif selected == 3:
            self.setMountPoint('/media/usb2')
        elif selected == 4:
            self.setMountPoint('/media/usb3')
        elif selected == 5:
            self.setMountPoint('/media/cf')
        elif selected == 6:
            self.setMountPoint('/media/mmc1')
        elif selected == 7:
            self.session.openWithCallback(self.customPath, VirtualKeyBoard, title=_('Insert mount point:'), text='/media/custom')

    def customPath(self, result):
        if result and len(result) > 0:
            result = result.rstrip('/')
            os.system('mkdir -p %s' % result)
            self.setMountPoint(result)

    def setMountPoint(self, path):
        self.cpath = path
        if self.mountpoints.exist(path):
            self.session.openWithCallback(self.setMountPointCb, ExtraMessageBox, 'Selected mount point is already used by another drive.', 'Mount point exist!', [['Change old drive with this new drive', 'ok.png'], ['Mantain old drive', 'cancel.png']])
        else:
            self.setMountPointCb(0)

    def setMountPointCb(self, result):
        if result == 0:
            if self.mountpoints.isMounted(self.cpath):
                if not self.mountpoints.umount(self.cpath):
                    self.session.open(MessageBox, _('Cannot umount current drive.\nA record in progress, timeshit or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR)
                    self.close()
                    return
            self.mountpoints.delete(self.cpath)
            self.mountpoints.add(self.device, self.partition, self.cpath)
            self.mountpoints.write()
            if not self.mountpoints.mount(self.device, self.partition, self.cpath):
                self.session.open(MessageBox, _('Cannot mount new drive.\nPlease check filesystem or format it and try again'), MessageBox.TYPE_ERROR)
            elif self.cpath == '/media/hdd':
                os.system('/bin/mkdir /hdd/movie')
                os.system('/bin/mkdir /hdd/music')
                os.system('/bin/mkdir /hdd/picture')
            self.close()

    def quit(self):
        self.close()
Exemple #22
0
class HddPartitions(Screen):

    def __init__(self, session, disk):
        self.session = session
        Screen.__init__(self, session)
        self.disk = disk
        self.refreshMP(False)
        self['menu'] = ExtrasList(self.partitions)
        self['menu'].onSelectionChanged.append(self.selectionChanged)
        self['key_red'] = Button('')
        self['key_green'] = Button('')
        self['key_yellow'] = Button('')
        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)
        self.onShown.append(self.setWindowTitle)
        if len(self.disk[5]) > 0:
            if self.disk[5][0][2] == 'Linux':
                self['key_green'].setText(_('Check'))
                self['key_yellow'].setText(_('Format'))
        if self.disk[5][0][2] == 'Linux swap':
            self['key_red'].setText('')
        else:
            mp = self.mountpoints.get(self.disk[0], 1)
            if len(mp) > 0:
                self.mounted = True
                self['key_red'].setText(_('Umount'))
            else:
                self.mounted = False
                self['key_red'].setText(_('Mount'))

    def setWindowTitle(self):
        self.setTitle(_('Devicemanager Partitions'))

    def selectionChanged(self):
        self['key_green'].setText('')
        self['key_yellow'].setText('')
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux':
                self['key_green'].setText(_('Check'))
                self['key_yellow'].setText(_('Format'))
            if self.disk[5][index][2] == 'Linux swap':
                self['key_red'].setText('')
            else:
                mp = self.mountpoints.get(self.disk[0], index + 1)
                if len(mp) > 0:
                    self.mounted = True
                    self['key_red'].setText(_('Umount'))
                else:
                    self.mounted = False
                    self['key_red'].setText(_('Mount'))

    def chkfs(self):
        disks = Disks()
        ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index + 1)
        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, swapfile 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 mkfs(self):
        disks = Disks()
        ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index + 1)
        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, swapfile 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 green(self):
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux':
                self.index = index
                self.session.open(ExtraActionBox, 'Checking disk %s' % self.disk[5][index][0], 'Checking disk', self.chkfs)

    def yellow(self):
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux':
                self.index = index
                self.session.open(ExtraActionBox, 'Formatting disk %s' % self.disk[5][index][0], 'Formatting disk', self.mkfs)

    def refreshMP(self, uirefresh = True):
        self.partitions = []
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        count = 1
        for part in self.disk[5]:
            capacity = '%d MB' % (part[1] / 1048576)
            mp = self.mountpoints.get(self.disk[0], count)
            if len(mp) > 0:
                self.partitions.append(PartitionEntry('Partition %d - %s (%s)' % (count, part[2], mp), capacity))
            else:
                self.partitions.append(PartitionEntry('Partition %d - %s' % (count, part[2]), capacity))
            count += 1

        if uirefresh:
            self['menu'].setList(self.partitions)

    def red(self):
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux swap':
                return
        if len(self.partitions) > 0:
            self.sindex = self['menu'].getSelectedIndex()
            if self.mounted:
                mp = self.mountpoints.get(self.disk[0], self.sindex + 1)
                if len(mp) > 0:
                    if self.mountpoints.isMounted(mp):
                        if self.mountpoints.umount(mp):
                            self.mountpoints.delete(mp)
                            self.mountpoints.write()
                        else:
                            self.session.open(MessageBox, _('Cannot umount device.\nA record in progress, timeshit or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'), MessageBox.TYPE_ERROR)
                    else:
                        self.mountpoints.delete(mp)
                        self.mountpoints.write()
                self.refreshMP()
            else:
                self.session.openWithCallback(self.refreshMP, HddMount, self.disk[0], self.sindex + 1)

    def quit(self):
        self.close()
Exemple #23
0
 def checkDefault(self):
     mp = MountPoints()
     mp.read()
     if not mp.exist('/hdd'):
         mp.add(self.mdisks.disks[self.sindex][0], 1, '/hdd')
         mp.write()
         mp.mount(self.mdisks.disks[self.sindex][0], 1, '/hdd')
         os.system('/bin/mkdir /hdd/movie')
         os.system('/bin/mkdir /hdd/music')
         os.system('/bin/mkdir /hdd/picture')
class HddPartitions(Screen):
    def __init__(self, session, disk):
        self.session = session
        Screen.__init__(self, session)
        self.disk = disk
        self.refreshMP(False)
        self['menu'] = ExtrasList(self.partitions)
        self['menu'].onSelectionChanged.append(self.selectionChanged)
        self['key_red'] = Button('')
        self['key_green'] = Button('')
        self['key_yellow'] = Button('')
        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)
        self.onShown.append(self.setWindowTitle)
        if len(self.disk[5]) > 0:
            if self.disk[5][0][2] == 'Linux':
                self['key_green'].setText(_('Check'))
                self['key_yellow'].setText(_('Format'))
        if self.disk[5][0][2] == 'Linux swap':
            self['key_red'].setText('')
        else:
            mp = self.mountpoints.get(self.disk[0], 1)
            if len(mp) > 0:
                self.mounted = True
                self['key_red'].setText(_('Umount'))
            else:
                self.mounted = False
                self['key_red'].setText(_('Mount'))

    def setWindowTitle(self):
        self.setTitle(_('Devicemanager Partitions'))

    def selectionChanged(self):
        self['key_green'].setText('')
        self['key_yellow'].setText('')
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux':
                self['key_green'].setText(_('Check'))
                self['key_yellow'].setText(_('Format'))
            if self.disk[5][index][2] == 'Linux swap':
                self['key_red'].setText('')
            else:
                mp = self.mountpoints.get(self.disk[0], index + 1)
                if len(mp) > 0:
                    self.mounted = True
                    self['key_red'].setText(_('Umount'))
                else:
                    self.mounted = False
                    self['key_red'].setText(_('Mount'))

    def chkfs(self):
        disks = Disks()
        ret = disks.chkfs(self.disk[5][self.index][0][:3], self.index + 1)
        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, swapfile 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 mkfs(self):
        disks = Disks()
        ret = disks.mkfs(self.disk[5][self.index][0][:3], self.index + 1)
        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, swapfile 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 green(self):
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux':
                self.index = index
                self.session.open(ExtraActionBox,
                                  'Checking disk %s' % self.disk[5][index][0],
                                  'Checking disk', self.chkfs)

    def yellow(self):
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux':
                self.index = index
                self.session.open(
                    ExtraActionBox,
                    'Formatting disk %s' % self.disk[5][index][0],
                    'Formatting disk', self.mkfs)

    def refreshMP(self, uirefresh=True):
        self.partitions = []
        self.mountpoints = MountPoints()
        self.mountpoints.read()
        count = 1
        for part in self.disk[5]:
            capacity = '%d MB' % (part[1] / 1048576)
            mp = self.mountpoints.get(self.disk[0], count)
            if len(mp) > 0:
                self.partitions.append(
                    PartitionEntry(
                        'Partition %d - %s (%s)' % (count, part[2], mp),
                        capacity))
            else:
                self.partitions.append(
                    PartitionEntry('Partition %d - %s' % (count, part[2]),
                                   capacity))
            count += 1

        if uirefresh:
            self['menu'].setList(self.partitions)

    def red(self):
        if len(self.disk[5]) > 0:
            index = self['menu'].getSelectionIndex()
            if self.disk[5][index][2] == 'Linux swap':
                return
        if len(self.partitions) > 0:
            self.sindex = self['menu'].getSelectedIndex()
            if self.mounted:
                mp = self.mountpoints.get(self.disk[0], self.sindex + 1)
                if len(mp) > 0:
                    if self.mountpoints.isMounted(mp):
                        if self.mountpoints.umount(mp):
                            self.mountpoints.delete(mp)
                            self.mountpoints.write()
                        else:
                            self.session.open(
                                MessageBox,
                                _('Cannot umount device.\nA record in progress, timeshit or some external tools (like samba, swapfile and nfsd) may cause this problem.\nPlease stop this actions/applications and try again'
                                  ), MessageBox.TYPE_ERROR)
                    else:
                        self.mountpoints.delete(mp)
                        self.mountpoints.write()
                self.refreshMP()
            else:
                self.session.openWithCallback(self.refreshMP, HddMount,
                                              self.disk[0], self.sindex + 1)

    def quit(self):
        self.close()