Skip to content

Commit 8db7533

Browse files
authored
Merge pull request #3600 from openatv/Multiboot
[Multiboot]
2 parents 390d0ad + 879f12f commit 8db7533

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

lib/python/Screens/FlashManager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ def findImageFiles(path):
667667
cmdArgs = ["-r%s" % mtdRootFS, "-a"]
668668
elif BoxInfo.getItem("model") in ("dm820", "dm7080"): # Temp solution ofgwrite auto detection not ready.
669669
cmdArgs = ["-rmmcblk0p1"] if rootSubDir is None else ["-r%s" % mtdRootFS, "-c%s" % currentSlot, "-m%s" % self.slotCode]
670-
elif MultiBoot.canMultiBoot() and not (self.slotCode == "R" or self.slotCode == "F"): # Receiver with SD card MultiBoot if (rootSubDir) is None.
670+
elif MultiBoot.canMultiBoot() and self.slotCode not in ("R", "F"): # Receiver with SD card MultiBoot if (rootSubDir) is None.
671671
if BoxInfo.getItem("chkrootmb"):
672672
cmdArgs = ["-r%s" % mtdRootFS, "-c%s" % currentSlot, "-m%s" % self.slotCode]
673673
else:

lib/python/Screens/Information.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -859,20 +859,13 @@ def formatNumber(number):
859859
info.append(formatLine("P1", _("Total flash"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
860860
info.append(formatLine("P1", _("Used flash"), f"{scaleNumber(diskUsed)} ({scaleNumber(diskUsed, 'Iec')})"))
861861
info.append(formatLine("P1", _("Free flash"), f"{scaleNumber(diskFree)} ({scaleNumber(diskFree, 'Iec')})"))
862-
try:
863-
with open("/proc/mtd") as mtd:
864-
for line in mtd:
865-
if '"kernel' in line:
866-
parts = line.split()
867-
name = parts[3].strip('"')
868-
size = int(parts[1], 16)
869-
if name == "kernel":
870-
label = _("Kernel partition")
871-
else:
872-
label = _("Kernel%s partition") % name.replace("kernel", "")
873-
info.append(formatLine("P1", label, "%s (%s)" % (scaleNumber(size), scaleNumber(size, "Iec"))))
874-
except:
875-
pass
862+
for line in fileReadLines("/proc/mtd", [], source=MODULE_NAME)
863+
if "\"kernel" in line:
864+
data = line.split()
865+
name = data[3].strip("\"")
866+
size = int(data[1], 16)
867+
label = _("Kernel partition") if name == "kernel" else _("Kernel%s partition") % name.replace("kernel", "")
868+
info.append(formatLine("P1", label, f"{scaleNumber(size)} ({scaleNumber(size, "Iec")})"))
876869
info.append("")
877870
info.append(formatLine("S", _("RAM (Details)")))
878871
if self.extraSpacing:

lib/python/Screens/MultiBootManager.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,21 +711,18 @@ def __init__(self, session, *args):
711711
self["key_red"] = StaticText()
712712
self["key_green"] = StaticText()
713713
self["description"] = Label()
714-
greenAction = (self.rootInit, _("Start the Chkroot initialization"))
715-
if BoxInfo.getItem("hasUBIMB"):
716-
greenAction = (self.UBIMBInit, _("Start the Chkroot initialization"))
717714
self["actions"] = HelpableActionMap(self, ["OkCancelActions", "ColorActions"], {
718715
"ok": (self.close, _("Close the Chkroot MultiBoot Manager")),
719716
"cancel": (self.close, _("Close the Chkroot MultiBoot Manager")),
720717
"red": (self.disableChkroot, _("Disable the MultiBoot option")),
721-
"green": greenAction
718+
"green": (self.ubimbInit if BoxInfo.getItem("hasUBIMB") else self.rootInit, _("Start the Chkroot initialization"))
722719
}, prio=-1, description=_("Chkroot Manager Actions"))
723720
self["key_red"].setText(_("Disable Chkroot"))
724721
self["key_green"].setText(_("Initialize"))
725722
self.descriptionSuffix = _("The %s %s will reboot within 1 seconds.") % getBoxDisplayName()
726723
self["description"].setText("%s\n\n%s" % (_("Press GREEN to enable MultiBoot!"), self.descriptionSuffix))
727724

728-
def UBIMBInit(self):
725+
def ubimbInit(self):
729726
self.session.open(UBISlotManager)
730727

731728
def rootInit(self):
@@ -917,9 +914,8 @@ def deviceSelectionCallback(self, selection):
917914
def partitionSizeGB(self, dev):
918915
try:
919916
base = dev.replace("/dev/", "")
920-
pathClass = f"/sys/class/block/{base}/size"
921-
pathBlock = f"/sys/block/{base}/size"
922-
path = pathClass if exists(pathClass) else pathBlock
917+
path = f"/sys/class/block/{base}/size"
918+
path = path if exists(path) else f"/sys/block/{base}/size"
923919
with open(path) as fd:
924920
blocks = int(fd.read().strip())
925921
return (blocks * 512) // (1024 * 1024 * 1024)

lib/python/Tools/MultiBoot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def saveKernel(bootSlots, slotCode, kernel):
176176
# print(f"[MultiBoot] loadBootSlots DEBUG: 'UUID=' found for device '{uuidDevice}'.")
177177
if uuidDevice:
178178
device = uuidDevice
179-
if exists(device) or device == "ubi0:ubifs" or device == "ubi0:rootfs":
179+
if exists(device) or device in ("ubi0:ubifs", "ubi0:rootfs"):
180180
if slotCode not in bootSlots:
181181
bootSlots[slotCode] = {}
182182
# print(f"[MultiBoot] Root dictionary entry in slot '{slotCode}' created.")

0 commit comments

Comments
 (0)