コード例 #1
0
class HddSetup(Screen):
    if FULLHD:
        skin = """
		<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">
			<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
			<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
			<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
			<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
			<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
			<widget source="menu" render="Listbox" position="20,45" size="520,380" scrollbarMode="showOnDemand">
				<convert type="TemplatedMultiContent">
					{"template": [
						MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),
						MultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),
						MultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),
						],
						"fonts": [gFont("Regular", 22)],
						"itemHeight": 50
					}
				</convert>
			</widget>
		</screen>"""
    else:
        skin = """
		<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">
			<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
			<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
			<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
			<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
			<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
			<widget source="menu" render="Listbox" position="20,45" size="520,380" scrollbarMode="showOnDemand">
				<convert type="TemplatedMultiContent">
					{"template": [
						MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),
						MultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),
						MultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),
						],
						"fonts": [gFont("Regular", 22)],
						"itemHeight": 50
					}
				</convert>
			</widget>
		</screen>"""

    def __init__(self, session, args=0):
        self.session = session
        Screen.__init__(self, session)
        self.disks = list()
        self.mdisks = Disks()
        self.asHDD = False
        for disk in self.mdisks.disks:
            capacity = "%d MB" % (disk[1] / (1024 * 1024))
            self.disks.append(
                DiskEntry(disk[3], capacity, disk[2], disk[6], disk[7]))
        self["menu"] = List(self.disks)
        self["key_red"] = Button(_("Exit"))
        self["key_green"] = Button(_("Info"))
        if sfdisk:
            self["key_yellow"] = Button(_("Initialize"))
        else:
            self["key_yellow"] = Button("")
        self["key_blue"] = Button(_("Partitions"))
        self["actions"] = ActionMap(
            ["OkCancelActions", "ColorActions"], {
                "blue": self.blue,
                "yellow": self.yellow,
                "green": self.green,
                "red": self.quit,
                "cancel": self.quit,
            }, -2)
        self.onShown.append(self.setWindowTitle)

    def setWindowTitle(self):
        self.setTitle(_("Device Manager"))

    def isExt4Supported(self):
        return "ext4" in open("/proc/filesystems").read()

    def mkfs(self):
        self.formatted += 1
        return self.mdisks.mkfs(self.mdisks.disks[self.sindex][0],
                                self.formatted, self.fsresult)

    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], disk[6], disk[7]))

        self["menu"].setList(self.disks)

    def checkDefault(self):
        mp = MountPoints()
        mp.read()
        if self.asHDD and not mp.exist("/media/hdd"):
            mp.add(self.mdisks.disks[self.sindex][0], 1, "/media/hdd")
            mp.write()
            mp.mount(self.mdisks.disks[self.sindex][0], 1, "/media/hdd")
            os.system("mkdir -p /media/hdd/movie")
            message = _(
                "Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?"
            )
            mbox = self.session.openWithCallback(self.restartBox, MessageBox,
                                                 message,
                                                 MessageBox.TYPE_YESNO)
            mbox.setTitle(_("Restart STB"))

    def restartBox(self, answer):
        if answer is True:
            self.session.open(TryQuitMainloop, 2)

    def format(self, result):
        if result != 0:
            self.session.open(
                MessageBox,
                _("Cannot format partition %d") % (self.formatted),
                MessageBox.TYPE_ERROR)
        if self.result == 0:
            if self.formatted > 0:
                self.checkDefault()
                self.refresh()
                return
        elif self.result > 0 and self.result < 3:
            if self.formatted > 1:
                self.checkDefault()
                self.refresh()
                return
        elif self.result == 3:
            if self.formatted > 2:
                self.checkDefault()
                self.refresh()
                return
        elif self.result == 4:
            if self.formatted > 3:
                self.checkDefault()
                self.refresh()
                return
        self.session.openWithCallback(
            self.format, ExtraActionBox,
            _("Formatting partition %d") % (self.formatted + 1),
            _("Initialize disk"), self.mkfs)

    def fdiskEnded(self, result):
        if result == 0:
            self.format(0)
        elif result == -1:
            self.session.open(
                MessageBox,
                _("Cannot umount current device.\nA record in progress, timeshift 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, _("Partitioning failed!"),
                              MessageBox.TYPE_ERROR)

    def fdisk(self):
        return self.mdisks.fdisk(self.mdisks.disks[self.sindex][0],
                                 self.mdisks.disks[self.sindex][1],
                                 self.result, self.fsresult)

    def initialaze(self, result):
        if not self.isExt4Supported():
            result += 1
        if result != 6:
            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)

    def chooseFSType(self, result):
        if result != 5:
            self.result = result
            if self.isExt4Supported():
                self.session.openWithCallback(
                    self.initialaze, ExtraMessageBox, _("Format as"),
                    _("Partitioner"), [
                        ["Ext4", "partitionmanager.png"],
                        ["Ext3", "partitionmanager.png"],
                        ["Ext2", "partitionmanager.png"],
                        ["NTFS", "partitionmanager.png"],
                        ["exFAT", "partitionmanager.png"],
                        ["Fat32", "partitionmanager.png"],
                        [_("Cancel"), "cancel.png"],
                    ], 1, 6)
            else:
                self.session.openWithCallback(
                    self.initialaze, ExtraMessageBox, _("Format as"),
                    _("Partitioner"), [
                        ["Ext3", "partitionmanager.png"],
                        ["Ext2", "partitionmanager.png"],
                        ["NTFS", "partitionmanager.png"],
                        ["exFAT", "partitionmanager.png"],
                        ["Fat32", "partitionmanager.png"],
                        [_("Cancel"), "cancel.png"],
                    ], 1, 5)

    def yellow(self):
        self.asHDD = False
        if sfdisk and len(self.mdisks.disks) > 0:
            list = [(_("No - simple"), "simple"),
                    (_("Yes - fstab entry as /media/hdd"), "as_hdd")]

            def extraOption(ret):
                if ret:
                    if ret[1] == "as_hdd":
                        self.asHDD = True
                    self.yellowAswer()

            self.session.openWithCallback(extraOption,
                                          ChoiceBox,
                                          title=_("Initialize") +
                                          _(" as HDD ?"),
                                          list=list)

    def yellowAswer(self):
        if sfdisk and len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            self.session.openWithCallback(
                self.chooseFSType, ExtraMessageBox,
                _("Please select your preferred configuration.") + "\n" +
                _("Or use standard 'Harddisk Setup' to initialize your drive in ext4."
                  ), _("Partitioner"),
                [
                    [_("One partition"), "partitionmanager.png"],
                    [_("Two partitions (50% - 50%)"), "partitionmanager.png"],
                    [_("Two partitions (75% - 25%)"), "partitionmanager.png"],
                    [
                        _("Three partitions (33% - 33% - 33%)"),
                        "partitionmanager.png"
                    ],
                    [
                        _("Four partitions (25% - 25% - 25% - 25%)"),
                        "partitionmanager.png"
                    ],
                    [_("Cancel"), "cancel.png"],
                ], 1, 5)

    def green(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            self.session.open(HddInfo, self.mdisks.disks[self.sindex][0],
                              self.mdisks.disks[self.sindex])

    def blue(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            if len(self.mdisks.disks[self.sindex][5]) == 0:
                self.session.open(
                    MessageBox,
                    _("You need to initialize your storage device first"),
                    MessageBox.TYPE_ERROR)
            else:
                self.session.open(HddPartitions,
                                  self.mdisks.disks[self.sindex])

    def quit(self):
        self.close()
コード例 #2
0
class HddSetup(Screen):
	if FULLHD:
		skin = """
		<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">
			<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
			<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
			<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
			<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
			<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
			<widget source="menu" render="Listbox" position="20,45" size="520,380" scrollbarMode="showOnDemand">
				<convert type="TemplatedMultiContent">
					{"template": [
						MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),
						MultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),
						MultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),
						],
						"fonts": [gFont("Regular", 22)],
						"itemHeight": 50
					}
				</convert>
			</widget>
		</screen>"""
	else:
		skin = """
		<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">
			<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
			<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
			<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
			<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
			<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
			<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;18" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
			<widget source="menu" render="Listbox" position="20,45" size="520,380" scrollbarMode="showOnDemand">
				<convert type="TemplatedMultiContent">
					{"template": [
						MultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),
						MultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),
						MultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),
						],
						"fonts": [gFont("Regular", 22)],
						"itemHeight": 50
					}
				</convert>
			</widget>
		</screen>"""

	def __init__(self, session, args=0):
		self.session = session
		Screen.__init__(self, session)
		self.disks = list()
		self.mdisks = Disks()
		self.asHDD = False
		for disk in self.mdisks.disks:
			capacity = "%d MB" % (disk[1] / (1024 * 1024))
			self.disks.append(DiskEntry(disk[3], capacity, disk[2], disk[6], disk[7]))
		self["menu"] = List(self.disks)
		self["key_red"] = Button(_("Exit"))
		self["key_green"] = Button(_("Info"))
		if sfdisk:
			self["key_yellow"] = Button(_("Initialize"))
		else:
			self["key_yellow"] = Button("")
		self["key_blue"] = Button(_("Partitions"))
		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
		{
			"blue": self.blue,
			"yellow": self.yellow,
			"green": self.green,
			"red": self.quit,
			"cancel": self.quit,
		}, -2)
		self.onShown.append(self.setWindowTitle)

	def setWindowTitle(self):
		self.setTitle(_("Device Manager"))

	def isExt4Supported(self):
		return "ext4" in open("/proc/filesystems").read()

	def mkfs(self):
		self.formatted += 1
		return self.mdisks.mkfs(self.mdisks.disks[self.sindex][0], self.formatted, self.fsresult)

	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], disk[6], disk[7]))

		self["menu"].setList(self.disks)

	def checkDefault(self):
		mp = MountPoints()
		mp.read()
		if self.asHDD and not mp.exist("/media/hdd"):
			mp.add(self.mdisks.disks[self.sindex][0], 1, "/media/hdd")
			mp.write()
			mp.mount(self.mdisks.disks[self.sindex][0], 1, "/media/hdd")
			os.system("mkdir -p /media/hdd/movie")
			message = _("Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?")
			mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO)
			mbox.setTitle(_("Restart STB"))

	def restartBox(self, answer):
		if answer is True:
			self.session.open(TryQuitMainloop, 2)

	def format(self, result):
		if result != 0:
			self.session.open(MessageBox, _("Cannot format partition %d") % (self.formatted), MessageBox.TYPE_ERROR)
		if self.result == 0:
			if self.formatted > 0:
				self.checkDefault()
				self.refresh()
				return
		elif self.result > 0 and self.result < 3:
			if self.formatted > 1:
				self.checkDefault()
				self.refresh()
				return
		elif self.result == 3:
			if self.formatted > 2:
				self.checkDefault()
				self.refresh()
				return
		elif self.result == 4:
			if self.formatted > 3:
				self.checkDefault()
				self.refresh()
				return
		self.session.openWithCallback(self.format, ExtraActionBox, _("Formatting partition %d") % (self.formatted + 1), _("Initialize disk"), self.mkfs)

	def fdiskEnded(self, result):
		if result == 0:
			self.format(0)
		elif result == -1:
			self.session.open(MessageBox, _("Cannot umount current device.\nA record in progress, timeshift 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, _("Partitioning failed!"), MessageBox.TYPE_ERROR)

	def fdisk(self):
		return self.mdisks.fdisk(self.mdisks.disks[self.sindex][0], self.mdisks.disks[self.sindex][1], self.result, self.fsresult)

	def initialaze(self, result):
		if not self.isExt4Supported():
			result += 1
		if result != 6:
			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)

	def chooseFSType(self, result):
		if result != 5:
			self.result = result
			if self.isExt4Supported():
				self.session.openWithCallback(self.initialaze, ExtraMessageBox, _("Format as"), _("Partitioner"),
											[ [ "Ext4", "partitionmanager.png" ],
											[ "Ext3", "partitionmanager.png" ],
											[ "Ext2", "partitionmanager.png" ],
											[ "NTFS", "partitionmanager.png" ],
											[ "exFAT", "partitionmanager.png" ],
											[ "Fat32", "partitionmanager.png" ],
											[ _("Cancel"), "cancel.png" ],
											], 1, 6)
			else:
				self.session.openWithCallback(self.initialaze, ExtraMessageBox, _("Format as"), _("Partitioner"),
											[ [ "Ext3", "partitionmanager.png" ],
											[ "Ext2", "partitionmanager.png" ],
											[ "NTFS", "partitionmanager.png" ],
											[ "exFAT", "partitionmanager.png" ],
											[ "Fat32", "partitionmanager.png" ],
											[ _("Cancel"), "cancel.png" ],
											], 1, 5)
	def yellow(self):
		self.asHDD = False
		if sfdisk and len(self.mdisks.disks) > 0:
			list = [(_("No - simple"), "simple"), (_("Yes - fstab entry as /media/hdd"), "as_hdd")]
			def extraOption(ret):
				if ret:
					if ret[1] == "as_hdd":
						self.asHDD = True
					self.yellowAswer()
			self.session.openWithCallback(extraOption, ChoiceBox, title = _("Initialize") + _(" as HDD ?"),list = list)

	def yellowAswer(self):
		if sfdisk and len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getIndex()
			self.session.openWithCallback(self.chooseFSType, ExtraMessageBox, _("Please select your preferred configuration.") + "\n" + _("Or use standard 'Harddisk Setup' to initialize your drive in ext4."), _("Partitioner"),
										[ [ _("One partition"), "partitionmanager.png" ],
										[ _("Two partitions (50% - 50%)"), "partitionmanager.png" ],
										[ _("Two partitions (75% - 25%)"), "partitionmanager.png" ],
										[ _("Three partitions (33% - 33% - 33%)"), "partitionmanager.png" ],
										[ _("Four partitions (25% - 25% - 25% - 25%)"), "partitionmanager.png" ],
										[ _("Cancel"), "cancel.png" ],
										], 1, 5)

	def green(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getIndex()
			self.session.open(HddInfo, self.mdisks.disks[self.sindex][0], self.mdisks.disks[self.sindex])

	def blue(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getIndex()
			if len(self.mdisks.disks[self.sindex][5]) == 0:
				self.session.open(MessageBox, _("You need to initialize your storage device first"), MessageBox.TYPE_ERROR)
			else:
				self.session.open(HddPartitions, self.mdisks.disks[self.sindex])

	def quit(self):
		self.close()
コード例 #3
0
class HddSetup(Screen):
    skin = '\n\t<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />\n\t\t<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t<widget source="menu" render="Listbox" position="20,45" size="520,380" scrollbarMode="showOnDemand">\n\t\t\t<convert type="TemplatedMultiContent">\n\t\t\t\t{"template": [\n\t\t\t\t\tMultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),\n\t\t\t\t\tMultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),\n\t\t\t\t\tMultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),\n\t\t\t\t\t],\n\t\t\t\t\t"fonts": [gFont("Regular", 22)],\n\t\t\t\t\t"itemHeight": 50\n\t\t\t\t}\n\t\t\t</convert>\n\t\t</widget>\n\t</screen>'

    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:
            capacity = '%d MB' % (disk[1] / 1048576)
            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)
        self.onShown.append(self.setWindowTitle)

    def setWindowTitle(self):
        self.setTitle(_('Devicelist'))

    def isExt4Supported(self):
        return 'ext4' in open('/proc/filesystems').read()

    def mkfs(self):
        self.formatted += 1
        return self.mdisks.mkfs(self.mdisks.disks[self.sindex][0], self.formatted, self.fsresult)

    def refresh(self):
        self.disks = list()
        self.mdisks = Disks()
        for disk in self.mdisks.disks:
            capacity = '%d MB' % (disk[1] / 1048576)
            self.disks.append(DiskEntry(disk[3], capacity, disk[2]))

        self['menu'].setList(self.disks)

    def checkDefault(self):
        mp = MountPoints()
        mp.read()
        if not mp.exist('/media/hdd'):
            mp.add(self.mdisks.disks[self.sindex][0], 1, '/media/hdd')
            mp.write()
            mp.mount(self.mdisks.disks[self.sindex][0], 1, '/media/hdd')
            os.system('/bin/mkdir -p /media/hdd/movie')
            message = _('Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?')
            mbox = self.session.openWithCallback(self.restartBox, MessageBox, message, MessageBox.TYPE_YESNO)
            mbox.setTitle(_('Restart STB'))

    def restartBox(self, answer):
        if answer is True:
            self.session.open(TryQuitMainloop, 2)

    def format(self, result):
        if result != 0:
            self.session.open(MessageBox, _('Cannot format partition %d') % self.formatted, MessageBox.TYPE_ERROR)
        if self.result == 0:
            if self.formatted > 0:
                self.checkDefault()
                self.refresh()
                return
        elif self.result > 0 and self.result < 3:
            if self.formatted > 1:
                self.checkDefault()
                self.refresh()
                return
        elif self.result == 3:
            if self.formatted > 2:
                self.checkDefault()
                self.refresh()
                return
        elif self.result == 4:
            if self.formatted > 3:
                self.checkDefault()
                self.refresh()
                return
        self.session.openWithCallback(self.format, ExtraActionBox, _('Formatting partition %d') % (self.formatted + 1), _('Initialize disk'), self.mkfs)

    def fdiskEnded(self, result):
        if result == 0:
            self.format(0)
        elif result == -1:
            self.session.open(MessageBox, _('Cannot umount current device.\nA record in progress, timeshift 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, _('Partitioning failed!'), MessageBox.TYPE_ERROR)

    def fdisk(self):
        return self.mdisks.fdisk(self.mdisks.disks[self.sindex][0], self.mdisks.disks[self.sindex][1], self.result, self.fsresult)

    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)

    def chooseFSType(self, result):
        if result != 5:
            self.result = result
            if self.isExt4Supported():
                self.session.openWithCallback(self.initialaze, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Ext4', 'partitionmanager.png'],
                 ['Ext3', 'partitionmanager.png'],
                 ['NTFS', 'partitionmanager.png'],
                 ['Fat32', 'partitionmanager.png'],
                 [_('Cancel'), 'cancel.png']], 1, 4)
            else:
                self.session.openWithCallback(self.initialaze, ExtraMessageBox, _('Format as'), _('Partitioner'), [['Ext3', 'partitionmanager.png'],
                 ['NTFS', 'partitionmanager.png'],
                 ['Fat32', 'partitionmanager.png'],
                 [_('Cancel'), 'cancel.png']], 1, 3)

    def yellow(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            self.session.openWithCallback(self.chooseFSType, ExtraMessageBox, _('Please select your preferred configuration.'), _('Partitioner'), [[_('One partition'), 'partitionmanager.png'],
             [_('Two partitions (50% - 50%)'), 'partitionmanager.png'],
             [_('Two partitions (75% - 25%)'), 'partitionmanager.png'],
             [_('Three partitions (33% - 33% - 33%)'), 'partitionmanager.png'],
             [_('Four partitions (25% - 25% - 25% - 25%)'), 'partitionmanager.png'],
             [_('Cancel'), 'cancel.png']], 1, 5)

    def green(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            self.session.open(HddInfo, self.mdisks.disks[self.sindex][0])

    def red(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            if len(self.mdisks.disks[self.sindex][5]) == 0:
                self.session.open(MessageBox, _('You need to initialize your storage device first'), MessageBox.TYPE_ERROR)
            else:
                self.session.open(HddPartitions, self.mdisks.disks[self.sindex])

    def quit(self):
        self.close()
コード例 #4
0
ファイル: HddSetup.py プロジェクト: OUARGLA86/enigma2
class HddSetup(Screen):
	skin = """
	<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">
		<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
		<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
		<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
		<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
		<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
		<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
		<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
		<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
		<widget name="menu" position="20,45" size="520,380" scrollbarMode="showOnDemand" itemHeight="50" transparent="1" />
	</screen>"""

	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:
			capacity = '%d MB' % (disk[1] / 1048576)
			self.disks.append(DiskEntry(disk[3], capacity, disk[2]))

		self['menu'] = ExtrasList(self.disks)
		self['key_red'] = Button(_('Exit'))
		self['key_green'] = Button('Info')
		self['key_yellow'] = Button(_('Initialize'))
		self['key_blue'] = Button(_('Partitions'))
		self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'red': self.quit,
			'yellow': self.yellow,
			'green': self.green,
			'blue': self.blue,
			'cancel': self.quit}, -2)
		self.onShown.append(self.setWindowTitle)

	def setWindowTitle(self):
		self.setTitle(_('Device Manager'))

	def mkfs(self):
		self.formatted += 1
		return self.mdisks.mkfs(self.mdisks.disks[self.sindex][0], self.formatted)

	def refresh(self):
		self.disks = list()
		self.mdisks = Disks()
		for disk in self.mdisks.disks:
			capacity = '%d MB' % (disk[1] / 1048576)
			self.disks.append(DiskEntry(disk[3], capacity, disk[2]))

		self['menu'].setList(self.disks)

	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')

	def format(self, result):
		if result != 0:
			self.session.open(MessageBox, _('Cannot format partition %d' % self.formatted), MessageBox.TYPE_ERROR)
		if self.result == 0:
			if self.formatted > 0:
				self.checkDefault()
				self.refresh()
				return
		elif self.result > 0 and self.result < 3:
			if self.formatted > 1:
				self.checkDefault()
				self.refresh()
				return
		elif self.result == 3:
			if self.formatted > 2:
				self.checkDefault()
				self.refresh()
				return
		elif self.result == 4:
			if self.formatted > 3:
				self.checkDefault()
				self.refresh()
				return
		self.session.openWithCallback(self.format, ExtraActionBox, _('Formatting partition %d') % (self.formatted + 1), 'Initialize disk', self.mkfs)

	def fdiskEnded(self, result):
		if result == 0:
			self.format(0)
		elif result == -1:
			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.session.open(MessageBox, _('Partitioning failed!'), MessageBox.TYPE_ERROR)

	def fdisk(self):
		return self.mdisks.fdisk(self.mdisks.disks[self.sindex][0], self.mdisks.disks[self.sindex][1], self.result)

	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 yellow(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getSelectedIndex()
			self.session.openWithCallback(self.initialaze, ExtraMessageBox, _('Please select your preferred configuration.'), _('HDD Partitioner'), [[_('One partition'), 'partitionmanager.png'],
				[_('Two partitions (50% - 50%)'), 'partitionmanager.png'],
				[_('Two partitions (75% - 25%)'), 'partitionmanager.png'],
				[_('Three partitions (33% - 33% - 33%)'), 'partitionmanager.png'],
				[_('Four partitions (25% - 25% - 25% - 25%)'), 'partitionmanager.png'],
				[_('Cancel'), 'cancel.png']], 1, 5)
				
	def green(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getSelectedIndex()
			self.session.open(HddInfo, self.mdisks.disks[self.sindex][0])
			
	def blue(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getSelectedIndex()
			self.session.open(HddPartitions, self.mdisks.disks[self.sindex])
			
	def quit(self):
		self.close()
コード例 #5
0
class HddSetup(Screen):
	skin = """
	<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">
		<ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
		<ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
		<ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
		<ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
		<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
		<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
		<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
		<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
		<widget name="menu" position="20,45" size="520,380" scrollbarMode="showOnDemand" itemHeight="50" transparent="1" />
	</screen>"""

	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:
			capacity = '%d MB' % (disk[1] / 1048576)
			self.disks.append(DiskEntry(disk[3], capacity, disk[2]))

		self['menu'] = ExtrasList(self.disks)
		self['key_red'] = Button(_('Partitions'))
		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)
		self.onShown.append(self.setWindowTitle)

	def setWindowTitle(self):
		self.setTitle(_('Atemio Device Manager'))

	def mkfs(self):
		self.formatted += 1
		return self.mdisks.mkfs(self.mdisks.disks[self.sindex][0], self.formatted)

	def refresh(self):
		self.disks = list()
		self.mdisks = Disks()
		for disk in self.mdisks.disks:
			capacity = '%d MB' % (disk[1] / 1048576)
			self.disks.append(DiskEntry(disk[3], capacity, disk[2]))

		self['menu'].setList(self.disks)

	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')

	def format(self, result):
		if result != 0:
			self.session.open(MessageBox, _('Cannot format partition %d' % self.formatted), MessageBox.TYPE_ERROR)
		if self.result == 0:
			if self.formatted > 0:
				self.checkDefault()
				self.refresh()
				return
		elif self.result > 0 and self.result < 3:
			if self.formatted > 1:
				self.checkDefault()
				self.refresh()
				return
		elif self.result == 3:
			if self.formatted > 2:
				self.checkDefault()
				self.refresh()
				return
		elif self.result == 4:
			if self.formatted > 3:
				self.checkDefault()
				self.refresh()
				return
		self.session.openWithCallback(self.format, ExtraActionBox, _('Formatting partition %d') % (self.formatted + 1), 'Initialize disk', self.mkfs)

	def fdiskEnded(self, result):
		if result == 0:
			self.format(0)
		elif result == -1:
			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.session.open(MessageBox, _('Partitioning failed!'), MessageBox.TYPE_ERROR)

	def fdisk(self):
		return self.mdisks.fdisk(self.mdisks.disks[self.sindex][0], self.mdisks.disks[self.sindex][1], self.result)

	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 yellow(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getSelectedIndex()
			self.session.openWithCallback(self.initialaze, ExtraMessageBox, _('Please select your preferred configuration.'), _('HDD Partitioner'), [[_('One partition'), 'partitionmanager.png'],
				[_('Two partitions (50% - 50%)'), 'partitionmanager.png'],
				[_('Two partitions (75% - 25%)'), 'partitionmanager.png'],
				[_('Three partitions (33% - 33% - 33%)'), 'partitionmanager.png'],
				[_('Four partitions (25% - 25% - 25% - 25%)'), 'partitionmanager.png'],
				[_('Cancel'), 'cancel.png']], 1, 5)
				
	def green(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getSelectedIndex()
			self.session.open(HddInfo, self.mdisks.disks[self.sindex][0])
			
	def red(self):
		if len(self.mdisks.disks) > 0:
			self.sindex = self['menu'].getSelectedIndex()
			self.session.open(HddPartitions, self.mdisks.disks[self.sindex])
			
	def quit(self):
		self.close()
コード例 #6
0
class HddSetup(Screen):
    skin = '\n\t<screen name="HddSetup" position="center,center" size="560,430" title="Hard Drive Setup">\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />\n\t\t<ePixmap pixmap="/usr/share/enigma2/skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />\n\t\t<widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />\n\t\t<widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />\n\t\t<widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />\n\t\t<widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />\n\t\t<widget source="menu" render="Listbox" position="20,45" size="520,380" scrollbarMode="showOnDemand">\n\t\t\t<convert type="TemplatedMultiContent">\n\t\t\t\t{"template": [\n\t\t\t\t\tMultiContentEntryPixmapAlphaTest(pos = (5, 0), size = (48, 48), png = 0),\n\t\t\t\t\tMultiContentEntryText(pos = (65, 10), size = (330, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 1),\n\t\t\t\t\tMultiContentEntryText(pos = (405, 10), size = (125, 38), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_TOP, text = 2),\n\t\t\t\t\t],\n\t\t\t\t\t"fonts": [gFont("Regular", 22)],\n\t\t\t\t\t"itemHeight": 50\n\t\t\t\t}\n\t\t\t</convert>\n\t\t</widget>\n\t</screen>'

    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:
            capacity = '%d MB' % (disk[1] / 1048576)
            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)
        self.onShown.append(self.setWindowTitle)

    def setWindowTitle(self):
        self.setTitle(_('Devicelist'))

    def isExt4Supported(self):
        return 'ext4' in open('/proc/filesystems').read()

    def mkfs(self):
        self.formatted += 1
        return self.mdisks.mkfs(self.mdisks.disks[self.sindex][0],
                                self.formatted, self.fsresult)

    def refresh(self):
        self.disks = list()
        self.mdisks = Disks()
        for disk in self.mdisks.disks:
            capacity = '%d MB' % (disk[1] / 1048576)
            self.disks.append(DiskEntry(disk[3], capacity, disk[2]))

        self['menu'].setList(self.disks)

    def checkDefault(self):
        mp = MountPoints()
        mp.read()
        if not mp.exist('/media/hdd'):
            mp.add(self.mdisks.disks[self.sindex][0], 1, '/media/hdd')
            mp.write()
            mp.mount(self.mdisks.disks[self.sindex][0], 1, '/media/hdd')
            os.system('/bin/mkdir -p /media/hdd/movie')
            message = _(
                'Fixed mounted first initialized Storage Device to /media/hdd. It needs a system restart in order to take effect.\nRestart your STB now?'
            )
            mbox = self.session.openWithCallback(self.restartBox, MessageBox,
                                                 message,
                                                 MessageBox.TYPE_YESNO)
            mbox.setTitle(_('Restart STB'))

    def restartBox(self, answer):
        if answer is True:
            self.session.open(TryQuitMainloop, 2)

    def format(self, result):
        if result != 0:
            self.session.open(MessageBox,
                              _('Cannot format partition %d') % self.formatted,
                              MessageBox.TYPE_ERROR)
        if self.result == 0:
            if self.formatted > 0:
                self.checkDefault()
                self.refresh()
                return
        elif self.result > 0 and self.result < 3:
            if self.formatted > 1:
                self.checkDefault()
                self.refresh()
                return
        elif self.result == 3:
            if self.formatted > 2:
                self.checkDefault()
                self.refresh()
                return
        elif self.result == 4:
            if self.formatted > 3:
                self.checkDefault()
                self.refresh()
                return
        self.session.openWithCallback(
            self.format, ExtraActionBox,
            _('Formatting partition %d') % (self.formatted + 1),
            _('Initialize disk'), self.mkfs)

    def fdiskEnded(self, result):
        if result == 0:
            self.format(0)
        elif result == -1:
            self.session.open(
                MessageBox,
                _('Cannot umount current device.\nA record in progress, timeshift 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, _('Partitioning failed!'),
                              MessageBox.TYPE_ERROR)

    def fdisk(self):
        return self.mdisks.fdisk(self.mdisks.disks[self.sindex][0],
                                 self.mdisks.disks[self.sindex][1],
                                 self.result, self.fsresult)

    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)

    def chooseFSType(self, result):
        if result != 5:
            self.result = result
            if self.isExt4Supported():
                self.session.openWithCallback(
                    self.initialaze, ExtraMessageBox, _('Format as'),
                    _('Partitioner'), [['Ext4', 'partitionmanager.png'],
                                       ['Ext3', 'partitionmanager.png'],
                                       ['NTFS', 'partitionmanager.png'],
                                       ['Fat32', 'partitionmanager.png'],
                                       [_('Cancel'), 'cancel.png']], 1, 4)
            else:
                self.session.openWithCallback(
                    self.initialaze, ExtraMessageBox, _('Format as'),
                    _('Partitioner'), [['Ext3', 'partitionmanager.png'],
                                       ['NTFS', 'partitionmanager.png'],
                                       ['Fat32', 'partitionmanager.png'],
                                       [_('Cancel'), 'cancel.png']], 1, 3)

    def yellow(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            self.session.openWithCallback(
                self.chooseFSType, ExtraMessageBox,
                _('Please select your preferred configuration.'),
                _('Partitioner'),
                [[_('One partition'), 'partitionmanager.png'],
                 [_('Two partitions (50% - 50%)'), 'partitionmanager.png'],
                 [_('Two partitions (75% - 25%)'), 'partitionmanager.png'],
                 [
                     _('Three partitions (33% - 33% - 33%)'),
                     'partitionmanager.png'
                 ],
                 [
                     _('Four partitions (25% - 25% - 25% - 25%)'),
                     'partitionmanager.png'
                 ], [_('Cancel'), 'cancel.png']], 1, 5)

    def green(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            self.session.open(HddInfo, self.mdisks.disks[self.sindex][0])

    def red(self):
        if len(self.mdisks.disks) > 0:
            self.sindex = self['menu'].getIndex()
            if len(self.mdisks.disks[self.sindex][5]) == 0:
                self.session.open(
                    MessageBox,
                    _('You need to initialize your storage device first'),
                    MessageBox.TYPE_ERROR)
            else:
                self.session.open(HddPartitions,
                                  self.mdisks.disks[self.sindex])

    def quit(self):
        self.close()