/
Flash_online.py
545 lines (492 loc) · 22.4 KB
/
Flash_online.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
from Components.config import config
from Components.Label import Label
from Components.ActionMap import ActionMap
from Components.ChoiceList import ChoiceList, ChoiceEntryComponent
from Components.Task import Task, Job, job_manager, Condition
from Components.Sources.StaticText import StaticText
from Components.SystemInfo import SystemInfo
from Components.ProgressBar import ProgressBar
from Screens.MessageBox import MessageBox
from Screens.ChoiceBox import ChoiceBox
from Screens.Screen import Screen
from Components.Console import Console
from Tools.BoundFunction import boundFunction
from Tools.Multiboot import GetImagelist, GetCurrentImage, GetCurrentImageMode, GetCurrentKern, GetCurrentRoot, GetBoxName
from enigma import eTimer
import os, urllib2, shutil, math, time, zipfile, shutil
from boxbranding import getImageDistro, getMachineBuild
feedurl = 'http://images.mynonpublic.com/%s' %(getImageDistro())
imagecat = [3.0,4.0,4.1,4.2,5.0,5.1,5.2,5.3,6.0,6.1,6.2,6.3]
def checkimagefiles(files):
return len([x for x in files if 'kernel' in x and '.bin' in x or x in ('zImage', 'uImage', 'root_cfe_auto.bin', 'root_cfe_auto.jffs2', 'oe_kernel.bin', 'oe_rootfs.bin', 'e2jffs2.img', 'rootfs.tar.bz2', 'rootfs.ubi','rootfs.bin')]) == 2
class FlashOnline(Screen):
skin = """
<screen name="SelectImage" position="center,center" size="550,400">
<widget name="list" position="fill" scrollbarMode="showOnDemand"/>
</screen>"""
def __init__(self, session):
Screen.__init__(self, session)
self.session = session
self.selection = 0
self.imagesList = {}
self.setIndex = 0
self.expanded = []
Screen.setTitle(self, _("Flash On the Fly"))
self["key_red"] = StaticText(_("Cancel"))
self["key_green"] = StaticText()
self["key_yellow"] = StaticText()
self["key_blue"] = StaticText()
self["description"] = StaticText()
self["list"] = ChoiceList(list=[ChoiceEntryComponent('',((_("Retrieving image list - Please wait...")), "Waiter"))])
self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "KeyboardInputActions", "MenuActions"],
{
"ok": self.keyOk,
"cancel": boundFunction(self.close, None),
"red": boundFunction(self.close, None),
"green": self.keyOk,
"yellow": self.keyDelete,
"up": self.keyUp,
"down": self.keyDown,
"left": self.keyLeft,
"right": self.keyRight,
"upRepeated": self.keyUp,
"downRepeated": self.keyDown,
"leftRepeated": self.keyLeft,
"rightRepeated": self.keyRight,
"menu": boundFunction(self.close, True),
}, -1)
self.delay = eTimer()
self.delay.callback.append(self.getImagesList)
self.delay.start(0, True)
def getImagesList(self):
def getImages(path, files):
for file in [x for x in files if os.path.splitext(x)[1] == ".zip" and box in x]:
try:
if checkimagefiles([x.split(os.sep)[-1] for x in zipfile.ZipFile(file).namelist()]):
if "Downloaded Images" not in self.imagesList:
self.imagesList["Downloaded Images"] = {}
self.imagesList["Downloaded Images"][file] = {'link': file, 'name': file.split(os.sep)[-1]}
except:
pass
if not self.imagesList:
box = GetBoxName()
for version in reversed(sorted(imagecat)):
newversion = _("Image Version %s") %version
the_page =""
url = '%s/%s/index.php?open=%s' % (feedurl,version,box)
try:
req = urllib2.Request(url)
response = urllib2.urlopen(req)
except urllib2.URLError as e:
print "URL ERROR: %s\n%s" % (e,url)
continue
try:
the_page = response.read()
except urllib2.HTTPError as e:
print "HTTP download ERROR: %s" % e.code
continue
lines = the_page.split('\n')
tt = len(box)
countimage = []
for line in lines:
if line.find("<a href='%s/" % box) > -1:
t = line.find("<a href='%s/" % box)
if line[t+tt+10:t+tt+tt+39].endswith(".zip"):
countimage.append(line[t+tt+10:t+tt+tt+39])
if len(countimage) >= 1:
self.imagesList[newversion] = {}
for image in countimage:
self.imagesList[newversion][image] = {}
self.imagesList[newversion][image]["name"] = image
self.imagesList[newversion][image]["link"] = '%s/%s/%s/%s' % (feedurl,version,box,image)
for media in ['/media/%s' % x for x in os.listdir('/media')] + (['/media/net/%s' % x for x in os.listdir('/media/net')] if os.path.isdir('/media/net') else []):
if not(SystemInfo['HasMMC'] and "/mmc" in media) and os.path.isdir(media):
getImages(media, [os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x])
if "images" in os.listdir(media):
media = os.path.join(media, "images")
if os.path.isdir(media) and not os.path.islink(media) and not os.path.ismount(media):
getImages(media, [os.path.join(media, x) for x in os.listdir(media) if os.path.splitext(x)[1] == ".zip" and box in x])
for dir in [dir for dir in [os.path.join(media, dir) for dir in os.listdir(media)] if os.path.isdir(dir) and os.path.splitext(dir)[1] == ".unzipped"]:
shutil.rmtree(dir)
list = []
for catagorie in reversed(sorted(self.imagesList.keys())):
if catagorie in self.expanded:
list.append(ChoiceEntryComponent('expanded',((str(catagorie)), "Expander")))
for image in reversed(sorted(self.imagesList[catagorie].keys())):
list.append(ChoiceEntryComponent('verticalline',((str(self.imagesList[catagorie][image]['name'])), str(self.imagesList[catagorie][image]['link']))))
else:
for image in self.imagesList[catagorie].keys():
list.append(ChoiceEntryComponent('expandable',((str(catagorie)), "Expander")))
break
if list:
self["list"].setList(list)
if self.setIndex:
self["list"].moveToIndex(self.setIndex if self.setIndex < len(list) else len(list) - 1)
if self["list"].l.getCurrentSelection()[0][1] == "Expander":
self.setIndex -= 1
if self.setIndex:
self["list"].moveToIndex(self.setIndex if self.setIndex < len(list) else len(list) - 1)
self.setIndex = 0
self.selectionChanged()
else:
self.session.openWithCallback(self.close, MessageBox, _("Cannot find images - please try later"), type=MessageBox.TYPE_ERROR, timeout=3)
def keyOk(self):
currentSelected = self["list"].l.getCurrentSelection()
if currentSelected[0][1] == "Expander":
if currentSelected[0][0] in self.expanded:
self.expanded.remove(currentSelected[0][0])
else:
self.expanded.append(currentSelected[0][0])
self.getImagesList()
elif currentSelected[0][1] != "Waiter":
self.session.openWithCallback(self.getImagesList, FlashImage, currentSelected[0][0], currentSelected[0][1])
def keyDelete(self):
currentSelected= self["list"].l.getCurrentSelection()[0][1]
if not("://" in currentSelected or currentSelected in ["Expander", "Waiter"]):
try:
os.remove(currentSelected)
currentSelected = ".".join([currentSelected[:-4], "unzipped"])
if os.path.isdir(currentSelected):
shutil.rmtree(currentSelected)
self.setIndex = self["list"].getSelectedIndex()
self.imagesList = {}
self.getImagesList()
except:
self.session.open(MessageBox, _("Cannot delete downloaded image"), MessageBox.TYPE_ERROR, timeout=3)
def selectionChanged(self):
currentSelected = self["list"].l.getCurrentSelection()
if "://" in currentSelected[0][1] or currentSelected[0][1] in ["Expander", "Waiter"]:
self["key_yellow"].setText("")
else:
self["key_yellow"].setText(_("Delete image"))
if currentSelected[0][1] == "Waiter":
self["key_green"].setText("")
else:
if currentSelected[0][1] == "Expander":
self["key_green"].setText(_("Compress") if currentSelected[0][0] in self.expanded else _("Expand"))
self["description"].setText("")
else:
self["key_green"].setText(_("Flash Image"))
self["description"].setText(currentSelected[0][1])
def keyLeft(self):
self["list"].instance.moveSelection(self["list"].instance.pageUp)
self.selectionChanged()
def keyRight(self):
self["list"].instance.moveSelection(self["list"].instance.pageDown)
self.selectionChanged()
def keyUp(self):
self["list"].instance.moveSelection(self["list"].instance.moveUp)
self.selectionChanged()
def keyDown(self):
self["list"].instance.moveSelection(self["list"].instance.moveDown)
self.selectionChanged()
class FlashImage(Screen):
skin = """<screen position="center,center" size="640,150" flags="wfNoBorder" backgroundColor="#54242424">
<widget name="header" position="5,10" size="e-10,50" font="Regular;40" backgroundColor="#54242424"/>
<widget name="info" position="5,60" size="e-10,130" font="Regular;24" backgroundColor="#54242424"/>
<widget name="progress" position="5,e-39" size="e-10,24" backgroundColor="#54242424"/>
</screen>"""
def __init__(self, session, imagename, source):
Screen.__init__(self, session)
self.containerbackup = None
self.containerofgwrite = None
self.getImageList = None
self.saveImageList = None
self.downloader = None
self.source = source
self.imagename = imagename
self["header"] = Label(_("Backup settings"))
self["info"] = Label(_("Save settings and EPG data"))
self["progress"] = ProgressBar()
self["progress"].setRange((0, 100))
self["progress"].setValue(0)
self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
{
"cancel": self.abort,
"red": self.abort,
"ok": self.ok,
"green": self.ok,
}, -1)
self.delay = eTimer()
self.delay.callback.append(self.confirmation)
self.delay.start(0, True)
self.hide()
def confirmation(self):
self.message = _("Do you want to flash image\n%s") % self.imagename
if SystemInfo["canMultiBoot"]:
self.getImageList = GetImagelist(self.getImagelistCallback)
else:
choices = [(_("Yes, with backup"), "with backup"), (_("Yes, without backup"), "without backup"), (_("No, do not flash image"), False)]
self.session.openWithCallback(self.checkMedia, MessageBox, self.message , list=choices, default=False, simple=True)
def getImagelistCallback(self, imagedict):
self.saveImageList = imagedict
self.getImageList = None
choices = []
currentimageslot = GetCurrentImage()
for x in range(1, SystemInfo["canMultiBoot"][1] + 1):
choices.append(((_("slot%s - %s (current image) with, backup") if x == currentimageslot else _("slot%s - %s, with backup")) % (x, imagedict[x]['imagename']), (x, "with backup")))
for x in range(1, SystemInfo["canMultiBoot"][1] + 1):
choices.append(((_("slot%s - %s (current image), without backup") if x == currentimageslot else _("slot%s - %s, without backup")) % (x, imagedict[x]['imagename']), (x, "without backup")))
choices.append((_("No, do not flash image"), False))
self.session.openWithCallback(self.checkMedia, MessageBox, self.message, list=choices, default=currentimageslot, simple=True)
def checkMedia(self, retval):
if retval:
if SystemInfo["canMultiBoot"]:
self.multibootslot = retval[0]
doBackup = retval[1] == "with backup"
else:
doBackup = retval == "with backup"
def findmedia(path):
def avail(path):
if not '/mmc' in path and os.path.isdir(path) and os.access(path, os.W_OK):
try:
statvfs = os.statvfs(path)
return (statvfs.f_bavail * statvfs.f_frsize) / (1 << 20)
except:
pass
def checkIfDevice(path, diskstats):
st_dev = os.stat(path).st_dev
return (os.major(st_dev), os.minor(st_dev)) in diskstats
diskstats = [(int(x[0]), int(x[1])) for x in [x.split()[0:3] for x in open('/proc/diskstats').readlines()] if x[2].startswith("sd")]
if os.path.isdir(path) and checkIfDevice(path, diskstats) and avail(path) > 500:
return (path, True)
mounts = []
devices = []
for path in ['/media/%s' % x for x in os.listdir('/media')] + (['/media/net/%s' % x for x in os.listdir('/media/net')] if os.path.isdir('/media/net') else []):
if checkIfDevice(path, diskstats):
devices.append((path, avail(path)))
else:
mounts.append((path, avail(path)))
devices.sort(key=lambda x: x[1], reverse=True)
mounts.sort(key=lambda x: x[1], reverse=True)
return ((devices[0][1] > 500 and (devices[0][0], True)) if devices else mounts and mounts[0][1] > 500 and (mounts[0][0], False)) or (None, None)
self.destination, isDevice = findmedia("/media/hdd" or "/media/usb")
if self.destination:
destination = os.path.join(self.destination, 'images')
self.zippedimage = "://" in self.source and os.path.join(destination, self.imagename) or self.source
self.unzippedimage = os.path.join(destination, '%s.unzipped' % self.imagename[:-4])
try:
if os.path.isfile(destination):
os.remove(destination)
if not os.path.isdir(destination):
os.mkdir(destination)
if doBackup:
if isDevice:
self.startBackupsettings(True)
else:
self.session.openWithCallback(self.startBackupsettings, MessageBox, _("Can only find a network drive to store the backup this means after the flash the autorestore will not work. Alternativaly you can mount the network drive after the flash and perform a manufacurer reset to autorestore"), simple=True)
else:
self.startDownload()
except:
self.session.openWithCallback(self.abort, MessageBox, _("Unable to create the required directories on the media (e.g. USB stick or Harddisk) - Please verify media and try again!"), type=MessageBox.TYPE_ERROR, simple=True)
else:
self.session.openWithCallback(self.abort, MessageBox, _("Could not find suitable media - Please remove some downloaded images or insert a media (e.g. USB stick) with sufficiant free space and try again!"), type=MessageBox.TYPE_ERROR, simple=True)
else:
self.abort()
def startBackupsettings(self, retval):
if retval:
from Plugins.SystemPlugins.SoftwareManager.BackupRestore import BackupScreen
self.session.openWithCallback(self.flashPostAction,BackupScreen, runBackup = True)
else:
self.abort()
def flashPostAction(self, retval = True):
if retval:
title =_("Please select what to do after flashing the image:\n(In addition, if it exists, a local script will be executed as well at /media/hdd/images/config/myrestore.sh)")
choices = ((_("Flash and start installation wizard"), "wizard"),
(_("Flash and restore settings and no plugins"), "restoresettingsnoplugin"),
(_("Flash and restore settings and selected plugins (ask user)"), "restoresettings"),
(_("Flash and restore settings and all saved plugins"), "restoresettingsandallplugins"),
(_("Do not flash image"), "abort"))
self.session.openWithCallback(self.postFlashActionCallback, ChoiceBox,title=title,list=choices,selection=self.SelectPrevPostFashAction())
else:
self.abort()
def SelectPrevPostFashAction(self):
index = 0
Settings = False
AllPlugins = False
noPlugins = False
if os.path.exists('/media/hdd/images/config/settings'):
Settings = True
if os.path.exists('/media/hdd/images/config/plugins'):
AllPlugins = True
if os.path.exists('/media/hdd/images/config/noplugins'):
noPlugins = True
if Settings and noPlugins:
index = 1
elif Settings and not AllPlugins and not noPlugins:
index = 2
elif Settings and AllPlugins:
index = 3
return index
def postFlashActionCallback(self, answer):
restoreSettings = False
restoreAllPlugins = False
restoreSettingsnoPlugin = False
if answer is not None:
if answer[1] == "restoresettings":
restoreSettings = True
if answer[1] == "restoresettingsnoplugin":
restoreSettings = True
restoreSettingsnoPlugin = True
if answer[1] == "restoresettingsandallplugins":
restoreSettings = True
restoreAllPlugins = True
if restoreSettings:
self.SaveEPG()
if answer[1] != "abort":
if restoreSettings:
try:
if not os.path.exists('/media/hdd/images/config'):
os.makedirs('/media/hdd/images/config')
open('/media/hdd/images/config/settings','w').close()
except:
print "postFlashActionCallback: failed to create /media/hdd/images/config/settings"
else:
if os.path.exists('/media/hdd/images/config/settings'):
os.unlink('/media/hdd/images/config/settings')
if restoreAllPlugins:
try:
if not os.path.exists('/media/hdd/images/config'):
os.makedirs('/media/hdd/images/config')
open('/media/hdd/images/config/plugins','w').close()
except:
print "postFlashActionCallback: failed to create /media/hdd/images/config/plugins"
else:
if os.path.exists('/media/hdd/images/config/plugins'):
os.unlink('/media/hdd/images/config/plugins')
if restoreSettingsnoPlugin:
try:
if not os.path.exists('/media/hdd/images/config'):
os.makedirs('/media/hdd/images/config')
open('/media/hdd/images/config/noplugins','w').close()
except:
print "postFlashActionCallback: failed to create /media/hdd/images/config/noplugins"
else:
if os.path.exists('/media/hdd/images/config/noplugins'):
os.unlink('/media/hdd/images/config/noplugins')
if restoreSettings or restoreAllPlugins or restoreSettingsnoPlugin:
if config.plugins.softwaremanager.restoremode.value is not None:
try:
if not os.path.exists('/media/hdd/images/config'):
os.makedirs('/media/hdd/images/config')
if config.plugins.softwaremanager.restoremode.value == "slow":
if not os.path.exists('/media/hdd/images/config/slow'):
open('/media/hdd/images/config/slow','w').close()
if os.path.exists('/media/hdd/images/config/fast'):
os.unlink('/media/hdd/images/config/fast')
if os.path.exists('/media/hdd/images/config/turbo'):
os.unlink('/media/hdd/images/config/turbo')
elif config.plugins.softwaremanager.restoremode.value == "fast":
if not os.path.exists('/media/hdd/images/config/fast'):
open('/media/hdd/images/config/fast','w').close()
if os.path.exists('/media/hdd/images/config/slow'):
os.unlink('/media/hdd/images/config/slow')
if os.path.exists('/media/hdd/images/config/turbo'):
os.unlink('/media/hdd/images/config/turbo')
elif config.plugins.softwaremanager.restoremode.value == "turbo":
if not os.path.exists('/media/hdd/images/config/turbo'):
open('/media/hdd/images/config/turbo','w').close()
if os.path.exists('/media/hdd/images/config/slow'):
os.unlink('/media/hdd/images/config/slow')
if os.path.exists('/media/hdd/images/config/fast'):
os.unlink('/media/hdd/images/config/fast')
except:
print "postFlashActionCallback: failed to create restore mode flagfile"
self.startDownload()
else:
self.abort()
else:
self.abort()
def SaveEPG(self):
from enigma import eEPGCache
epgcache = eEPGCache.getInstance()
epgcache.save()
def startDownload(self, reply=True):
self.show()
if reply:
if "://" in self.source:
from Tools.Downloader import downloadWithProgress
self["header"].setText(_("Downloading Image"))
self["info"].setText(self.imagename)
self.downloader = downloadWithProgress(self.source, self.zippedimage)
self.downloader.addProgress(self.downloadProgress)
self.downloader.addEnd(self.downloadEnd)
self.downloader.addError(self.downloadError)
self.downloader.start()
else:
self.unzip()
else:
self.abort()
def downloadProgress(self, current, total):
self["progress"].setValue(int(100 * current / total))
def downloadError(self, reason, status):
self.downloader.stop()
self.session.openWithCallback(self.abort, MessageBox, _("Error during downloading image\n%s\n%s") % (self.imagename, reason), type=MessageBox.TYPE_ERROR, simple=True)
def downloadEnd(self):
self.downloader.stop()
self.unzip()
def unzip(self):
self["header"].setText(_("Unzipping Image"))
self["info"].setText("%s\n%s"% (self.imagename, _("Please wait")))
self["progress"].hide()
self.delay.callback.remove(self.confirmation)
self.delay.callback.append(self.doUnzip)
self.delay.start(0, True)
def doUnzip(self):
try:
zipfile.ZipFile(self.zippedimage, 'r').extractall(self.unzippedimage)
self.flashimage()
except:
self.session.openWithCallback(self.abort, MessageBox, _("Error during unzipping image\n%s") % self.imagename, type=MessageBox.TYPE_ERROR, simple=True)
def flashimage(self):
self["header"].setText(_("Flashing Image"))
def findimagefiles(path):
for path, subdirs, files in os.walk(path):
if not subdirs and files:
return checkimagefiles(files) and path
imagefiles = findimagefiles(self.unzippedimage)
if imagefiles:
self.getImageList = self.saveImageList
self.MTDKERNEL = GetCurrentKern()
self.MTDROOTFS = GetCurrentRoot()
if SystemInfo["canMultiBoot"]:
if "sd" in self.getImageList[self.multibootslot]['part']:
self.MTDKERNEL = "%s%s" %(SystemInfo["canMultiBoot"][2], int(self.getImageList[self.multibootslot]['part'][3])-1)
self.MTDROOTFS = "%s" %(self.getImageList[self.multibootslot]['part'])
if SystemInfo["canMultiBoot"]:
if getMachineBuild() in ("gbmv200","cc1","sf8008","ustym4kpro","beyonwizv2","viper4k"): # issue detect kernel device and rootfs on sda
print "[FlashImage] detect Kernel:",self.MTDKERNEL
print "[FlashImage] detect rootfs:",self.MTDROOTFS
command = "/usr/bin/ofgwrite -r%s -k%s %s" % (self.MTDROOTFS, self.MTDKERNEL, imagefiles)
elif getMachineBuild() in ("hd60","hd61","h9combo","multibox"): # issue with framebuffer force reboot after flashing
command = "/usr/bin/ofgwrite -f -r -k -m%s %s" % (self.multibootslot, imagefiles)
else:
command = "/usr/bin/ofgwrite -r -k -m%s %s" % (self.multibootslot, imagefiles)
elif getMachineBuild() in ("u5pvr","u5","u51","u52","u53","u54","u56"): # issue detect kernel device
print "[FlashImage] detect Kernel:",self.MTDKERNEL
print "[FlashImage] detect rootfs:",self.MTDROOTFS
command = "/usr/bin/ofgwrite -r%s -k%s %s" % (self.MTDROOTFS, self.MTDKERNEL, imagefiles)
else:
command = "/usr/bin/ofgwrite -r -k %s" % imagefiles
self.containerofgwrite = Console()
self.containerofgwrite.ePopen(command, self.FlashimageDone)
else:
self.session.openWithCallback(self.abort, MessageBox, _("Image to install is invalid\n%s") % self.imagename, type=MessageBox.TYPE_ERROR, simple=True)
def FlashimageDone(self, data, retval, extra_args):
self.containerofgwrite = None
if retval == 0:
self["header"].setText(_("Flashing image successful"))
self["info"].setText(_("%s\nPress ok to close") % self.imagename)
else:
self.session.openWithCallback(self.abort, MessageBox, _("Flashing image was not successful\n%s") % self.imagename, type=MessageBox.TYPE_ERROR, simple=True)
def abort(self, reply=None):
if self.getImageList:
return 0
if self.downloader:
self.downloader.stop()
self.close()
def ok(self):
if self["header"].text == _("Flashing image successful"):
self.close()
else:
return 0