EPGSearch: the last change was not acceptable, we will NOT modify default behaviour...
[enigma2-plugins.git] / eparted / src / eparted.py
1 # -*- coding: utf-8 -*-
2 # code by GeminiTeam
3 from enigma import eTimer
4
5 from Screens.Screen import Screen
6 from Screens.MessageBox import MessageBox
7
8 from Components.Label import Label
9 from Components.Pixmap import MultiPixmap
10 from Components.Sources.StaticText import StaticText
11 from Components.Sources.List import List
12 from Components.ActionMap import ActionMap
13 from Components.MenuList import MenuList
14 from Components.Console import Console
15 from Tools.Directories import pathExists, createDir
16 from Tools.BoundFunction import boundFunction
17 from Tools.LoadPixmap import LoadPixmap
18
19 from Tools.Directories import resolveFilename, SCOPE_SKIN
20 SkinDefaultPath = resolveFilename(SCOPE_SKIN, "skin_default/icons/")
21
22 from Components.ConfigList import ConfigListScreen
23 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigInteger, ConfigYesNo, ConfigText, ConfigSelection, NoSave
24 config.plugins.eparted = ConfigSubsection()
25
26 from os import system as os_system, path as os_path, listdir
27
28 #from Plugins.Bp.geminimain.gTools import cleanexit
29
30 LIST_TYPE_DEV = 0
31 LIST_TYPE_PAR = 1
32 LIST_TYPE = 0
33
34 DEV_PATH = 1
35 DEV_SIZE = 2
36 DEV_TYPE = 3
37 DEV_NAME = 7
38
39 PA_NR = 1
40 PA_START = 2
41 PA_END = 3
42 PA_SIZE = 4
43 PA_FS = 5
44 PA_TYPE = 6
45 PA_NAME = 7
46
47 #-----------------------------------------------------------------------------
48
49 def getInt_epart(val):
50         try:
51                 return int(float(val[0:-2]))#Einheit abschneiden
52         except:
53                 return 0
54
55 def parseCmd(result):
56         devlist = []
57         try:
58                 entry = []
59                 addok = False
60                 for x in result.split('\n'):
61                         #if x=="BYT;":#start
62                         if x.find("BYT;") >= 0:
63                                 addok = True
64                         elif x == "":#end
65                                 if addok and len(entry):
66                                         devlist.append(entry)
67                                 addok = False
68                                 entry = []
69                         else:
70                                 if addok and len(x) > 1 and x[len(x) - 1] == ';':
71                                         l = x.split(':')
72                                         if len(l) == 7:#Part
73                                                 l.insert(0, LIST_TYPE_PAR)
74                                                 l[PA_START] = getInt_epart(l[PA_START])
75                                                 l[PA_END] = getInt_epart(l[PA_END])
76                                                 l[PA_SIZE] = getInt_epart(l[PA_SIZE])
77                                                 l[PA_NAME] = ""
78                                                 if l[PA_FS].find("linux-swap") == 0:
79                                                         l[PA_FS] = "linux-swap"
80                                                 entry.append(l)
81                                         elif len(l) == 8:#Device
82                                                 if l[0].find("/dev/mtd") < 0:
83                                                         l.insert(0, LIST_TYPE_DEV)
84                                                         entry.append(l)
85         except:
86                 print "[eParted] <parse error>"
87                 return []
88         return devlist
89
90 def myExecute(cmd, session, test=False):
91         if test:
92                 from time import sleep
93                 sleep(5)
94                 result = 0
95         else:
96                 res = os_system(cmd)
97                 result = (res >> 8)
98         print "[eParted]", result, cmd
99         if result != 0 and session is not None:
100                 session.open(MessageBox, _("Error command '%s'") % cmd, MessageBox.TYPE_ERROR, timeout=8)
101         return result
102         
103 def getMountP():
104         try:
105                 mounts = open("/proc/mounts")
106         except IOError:
107                 return []
108
109         lines = mounts.readlines()
110         mounts.close()
111         return lines
112
113 def ismounted(dev):
114         for x in getMountP():
115                 parts = x.strip().split(" ")
116                 if len(parts) > 1:
117                         realpath = os_path.realpath(parts[0])
118                         if realpath == dev:
119                                 return parts[1]
120         return None
121
122 rereaddevices = False
123 #-------------------------------------------------------------------------------------
124
125 class Ceparted(Screen):
126         skin = """<screen position="center,center" size="820,320" title="eParted v0.13">
127                         <widget name="list" position="10,10" size="800,300" enableWrapAround="1" scrollbarMode="showOnDemand"/>
128                 </screen>"""
129         def __init__(self, session):
130                 Screen.__init__(self, session)
131
132                 self["actions"] = ActionMap(["OkCancelActions"],
133                 {
134                         "cancel": self.Exit,
135                         "ok": self.Ok
136                 }, -1)
137
138                 self["list"] = MenuList(list=[])
139                 self.Console = Console()
140                 global rereaddevices
141                 rereaddevices = True
142                 self.__readDev()
143
144         def Ok(self):
145                 sel = self["list"].getCurrent()
146                 if sel and sel[1]:
147                         global rereaddevices
148                         rereaddevices = False
149                         self.session.openWithCallback(self.__readDev, Cpart, sel[1])
150         
151         def __readDev(self):
152                 global rereaddevices
153                 if rereaddevices:
154                         self.Console.ePopen("parted -m -l", self.__FinishedConsole)
155                 
156         def Exit(self):
157                 self.Console.killAll()
158                 self.close()
159                 #cleanexit(__name__)
160
161         def __FinishedConsole(self, result, retval, extra_args=None):
162                 if retval == 0 and '\n' in result:
163                         list = []
164                         for x in parseCmd(result):
165                                 if x[0][LIST_TYPE] == LIST_TYPE_DEV:
166                                         name = x[0][DEV_NAME]
167                                         if len(name) == 0:
168                                                 name = x[0][DEV_PATH]
169                                         tstr = name
170                                         tstr += "  (%s - %d %s %s)" % (x[0][DEV_SIZE], len(x) - 1, _("partition(s)"), x[0][DEV_PATH])
171                                         list.append((tstr, (name, x[0][DEV_PATH], x[0][DEV_SIZE])))
172                         self["list"].setList(list)
173
174 #-------------------------------------------------------------------------------------
175
176 class AddPart(Screen, ConfigListScreen):
177         skin = """<screen name="AddPart" position="center,center" size="820,320" title="add Partition" >
178                         <ePixmap pixmap="skin_default/buttons/red.png" position="10,5" size="200,40" alphatest="on" />
179                         <ePixmap pixmap="skin_default/buttons/green.png" position="210,5" size="200,40" alphatest="on" />
180                         <widget render="Label" source="key_red" position="10,5" size="200,40" zPosition="1" valign="center" halign="center" backgroundColor="#9f1313" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
181                         <widget render="Label" source="key_green" position="210,5" size="200,40" zPosition="1" valign="center" halign="center" backgroundColor="#1f771f" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
182                         <eLabel position="10,50" size="800,1" backgroundColor="grey" />
183                         <widget name="config" position="10,60" size="800,240" enableWrapAround="1" scrollbarMode="showOnDemand" />
184                 </screen>"""
185
186         def __init__(self, session, maxsize, unit, countpart):
187                 Screen.__init__(self, session)
188                 self.session = session
189                 self.setup_title = _("add partition")
190
191                 menu = []
192                 default = "ext3"
193                 if pathExists("/sbin/mkfs.ext2"):
194                         menu.append("ext2")
195                 if pathExists("/sbin/mkfs.ext3"):
196                         menu.append("ext3")
197                 if pathExists("/sbin/mkfs.ext4"):
198                         menu.append("ext4")
199                         default = "ext4"
200                 if pathExists("/sbin/mkfs.xfs"):
201                         menu.append("xfs")
202                 if pathExists("/sbin/mkswap"):
203                         menu.append("linux-swap")
204                 if pathExists("/sbin/mkfs.vfat"):
205                         menu.append("fat32")
206                 if pathExists("/usr/sbin/mkfs.msdos"):
207                         menu.append("fat16")
208                 config.plugins.eparted.fs = NoSave(ConfigSelection(default=default, choices=menu))
209                 config.plugins.eparted.size = NoSave(ConfigInteger(default=maxsize, limits=[1, maxsize]))
210
211                 list = []
212                 if countpart < 4:#nur 4 parts möglich bei primary
213                         list.append(getConfigListEntry(_("size in %s (max %d %s):") % (unit, maxsize, unit), config.plugins.eparted.size))
214                 list.append(getConfigListEntry(_("filesystem:"), config.plugins.eparted.fs))
215                 ConfigListScreen.__init__(self, list, session=session)
216                 
217                 self["key_red"] = StaticText(_("cancel"))
218                 self["key_green"] = StaticText(_("ok"))
219                 
220                 self["setupActions"] = ActionMap(["SetupActions", "ColorActions"],
221                 {
222                         "red": self.keyCancel,
223                         "cancel": self.keyCancel,
224                         "green": self.keySave,
225                         "save": self.keySave,
226                         "ok": self.keySave,
227                 }, -2)
228
229         def keyCancel(self):
230                 self.close()
231                 
232         def keySave(self):
233                 if config.plugins.eparted.size.value > 0:
234                         self.close((config.plugins.eparted.size.value, config.plugins.eparted.fs.value))
235
236 #-------------------------------------------------------------------------------------
237
238 class Cpart(Screen):
239         PA_TYPE_USE = 1
240         PA_TYPE_LAST = 2
241         PA_TYPE_FREE = 4
242
243         skin = """<screen position="center,center" size="820,320" title="eParted">
244                         <widget name="PixmapRed" pixmaps="skin_default/buttons/button_off.png,skin_default/buttons/button_red.png" position="10,12" size="25,25" alphatest="on" />
245                         <widget name="PixmapGreen" pixmaps="skin_default/buttons/button_off.png,skin_default/buttons/button_green.png" position="290,12" size="25,25" alphatest="on" />
246                         <widget name="PixmapBlue" pixmaps="skin_default/buttons/button_off.png,skin_default/buttons/button_blue.png" position="570,12" size="25,25" alphatest="on" />
247                         <widget name="LabelRed" position="50,5" size="200,40" valign="center" backgroundColor="background" font="Regular;21" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
248                         <widget name="LabelGreen" position="330,5" size="200,40" valign="center" backgroundColor="background" font="Regular;21" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
249                         <widget name="LabelBlue" position="610,5" size="200,40" valign="center" backgroundColor="background" font="Regular;21" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
250                         <eLabel position="10,50" size="800,1" backgroundColor="grey" />
251                         <widget source="list" render="Listbox" position="10,60" size="800,240" enableWrapAround="1" scrollbarMode="showOnDemand">
252                         <convert type="TemplatedMultiContent">
253                                 {"template": [
254                                 MultiContentEntryText(pos = (10,2), size = (60, 30), font=0, flags = RT_HALIGN_LEFT, text=0),
255                                 MultiContentEntryText(pos = (80,2), size = (170, 30), font=0, flags = RT_HALIGN_LEFT, text=1),
256                                 MultiContentEntryText(pos = (260,2), size = (170, 30), font=0, flags = RT_HALIGN_LEFT, text=2),
257                                 MultiContentEntryText(pos = (440,2), size = (170, 30), font=0, flags = RT_HALIGN_LEFT, text=3),
258                                 MultiContentEntryText(pos = (620,2), size = (180, 30), font=0, flags = RT_HALIGN_LEFT, text=4)
259                                 ],
260                                 "fonts": [gFont("Regular", 21)],
261                                 "itemHeight": 30
262                                 }
263                         </convert>
264                         </widget>
265                 </screen>"""
266
267         def __init__(self, session, entry):
268                 Screen.__init__(self, session)
269
270                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
271                 {
272                         "cancel": self.Exit,
273                         "green": self.KeyGreen,
274                         "blue": self.KeyBlue,
275                         "red": self.KeyRed
276                 }, -1)
277
278                 self["list"] = List(list=[])
279                 self["list"].onSelectionChanged.append(self.__SetLabels)
280                 self["PixmapRed"] = MultiPixmap()
281                 self["PixmapGreen"] = MultiPixmap()
282                 self["PixmapBlue"] = MultiPixmap()
283                 self["LabelRed"] = Label()
284                 self["LabelGreen"] = Label()
285                 self["LabelBlue"] = Label()
286
287                 self.__devpath = entry[DEV_PATH]
288                 self.__fullsize = 0
289                 self.__old_part_list = []
290                 self.__new_part_list = []
291                 self.__comlist = []
292                 self.__unit = entry[2][len(entry[2]) - 2:]
293
294                 self.Console = Console()
295                 self.__getPartInfo()
296                 
297         def Exit(self):
298                 self.Console.killAll()
299                 self.close()
300                 
301         def __getPartInfo(self, val=None):
302                 self.Console.ePopen("parted -m %s unit %s print" % (self.__devpath, self.__unit), self.__FinishedConsole)
303                 
304         def __Filllist(self):
305                 list = []
306                 index = self["list"].getIndex()
307                 for x in self.__new_part_list:
308                         if x[LIST_TYPE] == LIST_TYPE_PAR:
309                                 #print x
310                                 p0 = "%s: %s" % (_("Nr"), x[PA_NR])
311                                 p1 = "%s: %d%s" % (_("Start"), x[PA_START], self.__unit)
312                                 p2 = "%s: %d%s" % (_("End"), x[PA_END], self.__unit)
313                                 p3 = "%s: %d%s" % (_("Size"), x[PA_SIZE], self.__unit)
314                                 p4 = "%s: %s" % (_("Type"), x[PA_FS])
315                                 list.append((p0, p1, p2, p3, p4, x))
316                         self["list"].setList(list)
317                 self["list"].setIndex(index)
318                 self.__createCommandList()
319                 
320         def __SetLabels(self):
321                 sel = self["list"].getCurrent()
322                 self["LabelGreen"].setText("")
323                 self["LabelRed"].setText("")
324                 if sel and sel[5]:
325                         if sel[5][PA_TYPE] & self.PA_TYPE_FREE and len(self.__new_part_list) < 6:
326                                 self["PixmapGreen"].setPixmapNum(1)
327                                 self["LabelGreen"].setText(_("add"))
328                         else:
329                                 self["PixmapGreen"].setPixmapNum(0)
330                         if sel[5][PA_TYPE] & self.PA_TYPE_LAST and bool(sel[5][PA_TYPE] & self.PA_TYPE_FREE) == False:
331                                 self["PixmapRed"].setPixmapNum(1)
332                                 self["LabelRed"].setText(_("delete"))
333                         else:
334                                 self["PixmapRed"].setPixmapNum(0)
335                                 
336         def __addFreePart(self, plist, lastPartEnd):
337                 x = [LIST_TYPE_PAR, str(len(plist)), lastPartEnd, self.__fullsize, 0, _("free"), (self.PA_TYPE_FREE | self.PA_TYPE_LAST), ";"]
338                 plist.append(x)
339                 
340         def __FinishedConsole(self, result, retval, extra_args=None):
341                 if retval == 0 and '\n' in result:
342                         tlist = parseCmd(result)
343                         if len(tlist):
344                                 self.__old_part_list = tlist[0][:]
345                                 self.__new_part_list = tlist[0][:]
346
347                         lastPartEnd = 0
348                         count = 2
349                         for x in self.__old_part_list:
350                                 if x[LIST_TYPE] == LIST_TYPE_DEV:
351                                         self.__fullsize = getInt_epart(x[DEV_SIZE])
352                                         name = x[DEV_NAME]
353                                         if len(name) == 0:
354                                                 name = x[DEV_PATH]
355                                         name += " (%s)" % x[DEV_SIZE]
356                                         self.setTitle(name)
357                                 else:
358                                         lastPartEnd = x[PA_END]
359                                         x[PA_TYPE] = self.PA_TYPE_USE
360                                         if count == len(self.__old_part_list):#is letzte part
361                                                 x[PA_TYPE] |= self.PA_TYPE_LAST
362                                         count += 1
363
364                         if lastPartEnd < self.__fullsize:#Wenn noch Frei, Part erstellen
365                                 self.__addFreePart(self.__old_part_list, lastPartEnd)
366                                 self.__addFreePart(self.__new_part_list, lastPartEnd)
367                         
368                         self.__Filllist()
369
370         def KeyBlue(self):
371                 if len(self.__comlist):
372                         self.session.openWithCallback(self.__getPartInfo, Cpartexe, self.__comlist)
373
374         def KeyRed(self):
375                 sel = self["list"].getCurrent()
376                 if sel and sel[1] and sel[5][PA_TYPE] & self.PA_TYPE_LAST and bool(sel[5][PA_TYPE] & self.PA_TYPE_FREE) == False:
377                         try:
378                                 self.__new_part_list.remove(sel[5])#aktuelle part löschen
379                                 for x in self.__new_part_list:
380                                         if x[LIST_TYPE] == LIST_TYPE_PAR:
381                                                 if x[PA_TYPE] & self.PA_TYPE_FREE:#letzte Freie suchen und auch löschen
382                                                         self.__new_part_list.remove(x)
383                                                         break
384                                                 else:
385                                                         x[PA_TYPE] = self.PA_TYPE_USE
386                                 
387                                 lastPartEnd = 0
388                                 if len(self.__new_part_list) > 1:#von letzter Part, TYp setzen und Ende ermitteln
389                                         self.__new_part_list[len(self.__new_part_list) - 1][PA_TYPE] = self.PA_TYPE_USE | self.PA_TYPE_LAST
390                                         lastPartEnd = self.__new_part_list[len(self.__new_part_list) - 1][PA_END]
391                                 
392                                 if lastPartEnd < self.__fullsize:#Wenn noch Frei, Part erstellen
393                                         self.__addFreePart(self.__new_part_list, lastPartEnd)
394                                 #for x in self.__new_part_list:
395                                 #       if x[LIST_TYPE]==LIST_TYPE_PAR:
396                                 #               print x
397                         except:
398                                 print "[eParted] <remove part>"
399                         self.__Filllist()
400                         
401         def KeyGreen(self):
402                 sel = self["list"].getCurrent()
403                 if sel and sel[5] and sel[5][PA_TYPE] & self.PA_TYPE_FREE and sel[5][PA_START] < sel[5][PA_END] and len(self.__new_part_list) < 6:
404                         self.session.openWithCallback(self.__CallbackAddPart, AddPart, sel[5][PA_END] - sel[5][PA_START], self.__unit, len(self.__new_part_list) - 1)
405                         
406         def __CallbackAddPart(self, val=None):
407                 if val:
408                         for x in self.__new_part_list:
409                                 if x[LIST_TYPE] == LIST_TYPE_PAR:
410                                         if x[PA_TYPE] & self.PA_TYPE_FREE:
411                                                 x[PA_SIZE] = val[0]
412                                                 x[PA_FS] = val[1]
413                                                 x[PA_END] = x[PA_START] + x[PA_SIZE]
414                                                 x[PA_TYPE] = self.PA_TYPE_USE | self.PA_TYPE_LAST
415                                                 if x[PA_END] < self.__fullsize:#Wenn noch Frei, Part erstellen
416                                                         self.__addFreePart(self.__new_part_list, x[PA_END])
417                                                 break
418                                         else:
419                                                 x[PA_TYPE] = self.PA_TYPE_USE
420                         self.__Filllist()
421                         
422         def __addPart2Comlist(self, list, val, mkpart=True):
423                 #print val
424                 partnr = val[PA_NR]
425                 if mkpart:
426                         fs = val[PA_FS]
427                         com = "parted -s -a optimal %s mkpart primary %s %s%s %s%s" % (self.__devpath, fs, val[PA_START], self.__unit, val[PA_END], self.__unit)
428                         list.append((com , _("create partition %s") % partnr, None))
429                 
430                 mountdev = None
431                 if val[PA_FS] == "linux-swap":
432                         mkfs = "/sbin/mkswap"
433                 elif val[PA_FS] == "fat16":
434                         mkfs = "/usr/sbin/mkfs.msdos -F 16"
435                 elif val[PA_FS] == "fat32":
436                         mkfs = "/sbin/mkfs.vfat"
437                 else:
438                         mkfs = "/sbin/mkfs." + val[PA_FS]
439                         mountdev = self.__devpath + partnr
440                         if val[PA_FS] == "xfs":
441                                 mkfs += " -f"
442
443                 com = "%s %s%s" % (mkfs, self.__devpath, partnr)
444                 list.append((com , _("make filesystem '%s' on partition %s (%d %s)") % (val[PA_FS], partnr, val[PA_SIZE], self.__unit), mountdev))
445                 
446         def __delPart2Comlist(self, list, val):
447                 partnr = val[PA_NR]
448                 dev = "%s%s" % (self.__devpath, partnr)
449                 mp = ismounted(dev)
450                 if mp is not None:
451                         if myExecute("umount %s" % mp, self.session):
452                                 return
453                 list.insert(0, ("parted -s -a none %s rm %s" % (self.__devpath, partnr), _("delete partition %s") % partnr, None))
454
455         def __createCommandList(self):
456                 self.__comlist = []
457                 #welche parts sollen gelöscht werden
458                 for x in range(len(self.__old_part_list)):
459                         if self.__old_part_list[x][LIST_TYPE] == LIST_TYPE_PAR:
460                                 if bool(self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False:
461                                         if len(self.__new_part_list) > x:
462                                                 if self.__old_part_list[x][PA_SIZE] != self.__new_part_list[x][PA_SIZE]:
463                                                         #print self.__old_part_list[x], self.__new_part_list[x]
464                                                         self.__delPart2Comlist(self.__comlist, self.__old_part_list[x])
465                                         else:
466                                                 self.__delPart2Comlist(self.__comlist, self.__old_part_list[x])
467
468                 #welche parts sollen erstellt werden
469                 for x in range(len(self.__new_part_list)):
470                         if self.__new_part_list[x][LIST_TYPE] == LIST_TYPE_PAR:
471                                 if bool(self.__new_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False:
472                                         if len(self.__old_part_list) > x and bool(self.__old_part_list[x][PA_TYPE] & self.PA_TYPE_FREE) == False:
473                                                 if self.__new_part_list[x][PA_SIZE] != self.__old_part_list[x][PA_SIZE]:
474                                                         #print self.__new_part_list[x], self.__old_part_list[x]
475                                                         self.__addPart2Comlist(self.__comlist, self.__new_part_list[x])
476                                                 else:
477                                                         if self.__new_part_list[x][PA_FS] != self.__old_part_list[x][PA_FS]:
478                                                                 self.__addPart2Comlist(self.__comlist, self.__new_part_list[x], False)
479                                         else:
480                                                 self.__addPart2Comlist(self.__comlist, self.__new_part_list[x])
481                 
482
483                 #for x in self.__comlist: print "[eParted] com =",x
484                 if len(self.__comlist):
485                         self["PixmapBlue"].setPixmapNum(1)
486                         self["LabelBlue"].setText(_("execute"))
487                 else:
488                         self["PixmapBlue"].setPixmapNum(0)
489                         self["LabelBlue"].setText("")
490
491 class Cpartexe(Screen):
492         skin = """<screen position="center,center" size="820,320" title=" ">
493                         <widget name="PixmapButton" pixmaps="skin_default/buttons/button_green.png,skin_default/buttons/button_off.png" position="10,12" size="25,25" alphatest="on" />
494                         <widget name="LabelButton" position="50,5" size="200,40" valign="center" backgroundColor="background" font="Regular;21" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
495                         <eLabel position="10,50" size="800,1" backgroundColor="grey" />
496                         <widget source="list" render="Listbox" position="10,60" size="800,252" enableWrapAround="1" scrollbarMode="showOnDemand">
497                         <convert type="TemplatedMultiContent">
498                                 {"template": [
499                                 MultiContentEntryText(pos = (40,0), size = (760,36), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=0),
500                                 MultiContentEntryPixmapAlphaTest(pos = (2,2), size = (32,32), png=1),
501                                 ],
502                                 "fonts": [gFont("Regular", 21)],
503                                 "itemHeight": 36
504                                 }
505                         </convert>
506                         </widget>
507                 </screen>"""
508
509         def __init__(self, session, comlist):
510                 Screen.__init__(self, session)
511
512                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
513                 {
514                         "cancel": self.Exit,
515                         "green": self.KeyGreen,
516                         #"red": self.KeyRed
517                 }, -1)
518
519                 self.setTitle(_("execute"))
520                 self["PixmapButton"] = MultiPixmap()
521                 self["LabelButton"] = Label(_("Start") + " ?")
522
523                 self.mountlist = []
524                 list = []
525                 for x in comlist:
526                         print x
527                         list.append((x[1], None, x[0]))
528                         if x[2] is not None:
529                                 self.mountlist.append(x[2])
530                 self["list"] = List(list)
531                 
532                 self.__Stimer = eTimer()
533                 self.__Stimer_conn = self.__Stimer.timeout.connect(self.__exeList)
534                 self.__state = -1
535                 
536         def __getPartitionUUID(self, device):
537                 try:
538                         if os_path.exists("/dev/disk/by-uuid"):
539                                 for uuid in listdir("/dev/disk/by-uuid/"):
540                                         if not os_path.exists("/dev/disk/by-uuid/" + uuid):
541                                                 return None
542                                         if os_path.realpath("/dev/disk/by-uuid/" + uuid) == device:
543                                                 return ("/dev/disk/by-uuid/" + uuid, uuid)
544                         else:
545                                 return (device, device[5:])
546                 except:
547                         print "[eParted] <error get UUID>"
548                 return None
549                 
550         def __mountDevice(self):
551                 for x in self.mountlist:
552                         dev = self.__getPartitionUUID(x)
553                         if dev is not None:
554                                 if os_path.exists("/media/" + dev[1]) == False:
555                                         createDir("/media/" + dev[1], True)
556                                 cmd = "mount %s /media/%s" % (dev[0], dev[1])
557                                 myExecute(cmd, None)
558
559         def Exit(self):
560                 if self.__state < 0:
561                         del self.__Stimer_conn
562                         del self.__Stimer
563                         self.__mountDevice()
564                         self.close()
565                 
566         def __exeList(self):
567                 if len(self["list"].list) > self.__state and self.__state > -1:
568                         res = myExecute(self["list"].list[self.__state][2], self.session)
569                         pic = "redx.png"
570                         if res == 0:
571                                 pic = "selectioncross.png"
572
573                         self["list"].list[self.__state] = (self["list"].list[self.__state][0], LoadPixmap(path=SkinDefaultPath + pic), self["list"].list[self.__state][2], self["list"].list[self.__state][2])
574                         self["list"].updateList(self["list"].list)
575                         self["list"].setIndex(self.__state)
576                         
577                         if res == 0:
578                                 self.__state += 1
579                         else:
580                                 self.__state = len(self["list"].list)#bei fehler ans Ende der liste
581                                 self["PixmapButton"].setPixmapNum(0)
582                                 self["LabelButton"].setText(_("quit"))
583                                 
584                         self.__Stimer.start(500, True)
585                 else:
586                         self.__state = -2
587                         self["PixmapButton"].setPixmapNum(0)
588                         self["LabelButton"].setText(_("quit"))
589                 
590         def KeyGreen(self):
591                 if self.__state == -1:
592                         global rereaddevices
593                         rereaddevices = True
594                         self.__state += 1
595                         self["PixmapButton"].setPixmapNum(1)
596                         self["LabelButton"].setText(_("Please Wait"))
597                         self["list"].setIndex(0)
598                         self.__Stimer.start(500, True)
599                 elif self.__state == -2:
600                         self.Exit()
601         
602         #def KeyRed(self):
603         #       self.Exit()