added warning (if kill own rootfs)
[enigma2.git] / lib / python / Screens / HarddiskSetup.py
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 Screens.MessageBox import MessageBox
7
8 class HarddiskSetup(Screen):
9         def __init__(self, session, hdd):
10                 Screen.__init__(self, session)
11                 self.hdd = hdd
12                 
13                 cap = hdd.capacity() / 1000 * 512 / 1000
14                 capstr = "Capacity: %d.%03d GB" % (cap / 1000, cap % 1000)
15
16                 self["model"] = Label("Model: " + hdd.model())
17                 self["capacity"] = Label(capstr)
18
19                 idx = hdd.getIndex()
20                 
21                 if idx & 1:
22                         busstr = "Slave"
23                 else:   
24                         busstr = "Master"
25                 
26                 self["bus"] = Label("Bus: " + busstr)
27                 self["initialize"] = Label("Initialize")
28
29                 self["actions"] = ActionMap(["OkCancelActions"],
30                 {
31                         "ok": self.close,
32                         "cancel": self.close
33                 })
34                 
35                 self["shortcuts"] = ActionMap(["ShortcutActions"],
36                 {
37                         "red": self.hddInitialize
38                 })
39
40         def hddInitialize(self):
41                 if self.hdd.getIndex() == 2:            #CF
42                         print "not a good idea!"
43                         self.session.open(MessageBox, "not a good idea - this will kill our rootfs!")
44                 else:   
45                         pass
46                         #self.hdd.initialize()
47
48 class HarddiskSelection(Screen):
49         def __init__(self, session):
50                 Screen.__init__(self, session)
51
52                 self["hddlist"] = MenuList(harddiskmanager.HDDList())
53                 
54                 self["actions"] = ActionMap(["OkCancelActions"],
55                 {
56                         "ok": self.okbuttonClick ,
57                         "cancel": self.close
58                 })
59
60         def okbuttonClick(self):
61                 selection = self["hddlist"].getCurrent()
62                 self.session.open(HarddiskSetup, selection[1])
63                 print "ok"
64                 pass