1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Harddisk import harddiskmanager #global harddiskmanager
4 from Components.MenuList import MenuList
5 from Components.Label import Label
6 from Components.Pixmap import Pixmap
7 from Screens.MessageBox import MessageBox
8 from enigma import eTimer
10 class HarddiskWait(Screen):
13 result = self.hdd.initialize()
18 result = self.hdd.check()
21 def __init__(self, session, hdd, type):
22 Screen.__init__(self, session)
25 if type == HarddiskSetup.HARDDISK_INITIALIZE:
26 text = _("Initializing Harddisk...")
27 self.timer.callback.append(self.doInit)
29 text = _("Checking Filesystem...")
30 self.timer.callback.append(self.doCheck)
31 self["wait"] = Label(text)
34 class HarddiskSetup(Screen):
35 HARDDISK_INITIALIZE = 1
38 def __init__(self, session, hdd, type = None):
39 Screen.__init__(self, session)
42 if type not in [self.HARDDISK_INITIALIZE, self.HARDDISK_CHECK]:
43 self.type = self.HARDDISK_INITIALIZE
47 self["model"] = Label(_("Model: ") + hdd.model())
48 self["capacity"] = Label(_("Capacity: ") + hdd.capacity())
49 self["bus"] = Label(_("Bus: ") + hdd.bus())
50 self["initialize"] = Pixmap()
52 if self.type == self.HARDDISK_INITIALIZE:
53 text = _("Initialize")
56 self["initializetext"] = Label(text)
58 self["actions"] = ActionMap(["OkCancelActions"],
64 self["shortcuts"] = ActionMap(["ShortcutActions"],
66 "red": self.hddQuestion
69 def hddReady(self, result):
70 print "Result: " + str(result)
72 if self.type == self.HARDDISK_INITIALIZE:
73 message = _("Unable to initialize harddisk.\nError: ")
75 message = _("Unable to complete filesystem check.\nError: ")
76 self.session.open(MessageBox, message + str(self.hdd.errorList[0 - result]), MessageBox.TYPE_ERROR)
80 def hddQuestion(self):
81 if self.type == self.HARDDISK_INITIALIZE:
82 message = _("Do you really want to initialize the harddisk?\nAll data on the disk will be lost!")
84 message = _("Do you really want to check the filesystem?\nThis could take lots of time!")
85 self.session.openWithCallback(self.hddConfirmed, MessageBox, message)
87 def hddConfirmed(self, confirmed):
91 print "this will start either the initialize or the fsck now!"
92 self.session.openWithCallback(self.hddReady, HarddiskWait, self.hdd, self.type)
94 class HarddiskSelection(Screen):
95 def __init__(self, session):
96 Screen.__init__(self, session)
98 if harddiskmanager.HDDCount() == 0:
100 tlist.append((_("no HDD found"), 0))
101 self["hddlist"] = MenuList(tlist)
103 self["hddlist"] = MenuList(harddiskmanager.HDDList())
105 self["actions"] = ActionMap(["OkCancelActions"],
107 "ok": self.okbuttonClick ,
111 def okbuttonClick(self):
112 selection = self["hddlist"].getCurrent()
113 if selection[1] != 0:
114 self.session.open(HarddiskSetup, selection[1], HarddiskSetup.HARDDISK_INITIALIZE)
116 # This is actually just HarddiskSelection but with correct type
117 class HarddiskFsckSelection(HarddiskSelection):
118 def __init__(self, session):
119 HarddiskSelection.__init__(self, session)
120 self.skinName = "HarddiskSelection"
122 def okbuttonClick(self):
123 selection = self["hddlist"].getCurrent()
124 if selection[1] != 0:
125 self.session.open(HarddiskSetup, selection[1], HarddiskSetup.HARDDISK_CHECK)