Skip to content

Commit

Permalink
[Multiboot] - remove unused mkdir import and align comments with code…
Browse files Browse the repository at this point in the history
… for PEP8
  • Loading branch information
Twol committed Oct 5, 2023
1 parent eab3353 commit 47e9be3
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/python/Tools/Multiboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import glob
import subprocess
import tempfile
from os import mkdir, path, rmdir, rename, remove, sep, stat
from os import path, rmdir, rename, sep, stat

from boxbranding import getMachineMtdRoot
from Components.Console import Console
Expand Down Expand Up @@ -37,7 +37,7 @@ def getMultibootslots():
print("[multiboot*****][getMultibootslots]00 device, bootslots", device, " ", bootslots)
if len(bootslots) != 0:
break
# print("[multiboot*****][getMultibootslots]0 device = ", device)
# print("[multiboot*****][getMultibootslots]0 device = ", device)
if path.exists(device):
print("[multiboot*****][getMultibootslots]path found for device = ", device)
Console(binary=True).ePopen("mount %s %s" % (device, tmpname))
Expand All @@ -63,7 +63,7 @@ def getMultibootslots():
print("[multiboot] [getMultibootslots3] slot = %s file = %s" % (slotnumber, slotname))
if slotnumber.isdigit() and slotnumber not in bootslots:
line = open(file).read().replace("'", "").replace('"', "").replace("\n", " ").replace("ubi.mtd", "mtd").replace("bootargs=", "")
# print("[Multiboot][getMultibootslots]6 readlines = %s " % line)
# print("[Multiboot][getMultibootslots]6 readlines = %s " % line)
slot = dict([(x.split("=", 1)[0].strip(), x.split("=", 1)[1].strip()) for x in line.strip().split(" ") if "=" in x])
if slotnumber == "0":
slot["slotType"] = ""
Expand Down Expand Up @@ -94,7 +94,7 @@ def getMultibootslots():

if "kernel" not in slot.keys():
slot["kernel"] = "%sp%s" % (slot["root"].split("p")[0], int(slot["root"].split("p")[1]) - 1) # oldstyle MB kernel = root-1
# print("[multiboot] [getMultibootslots]7a HasMultibootMTD, kernel, root, SystemInfo['HasRootSubdir'] ", SystemInfo["HasMultibootMTD"], " ", slot["kernel"], " ", slot["root"], " ", SystemInfo["HasRootSubdir"])
# print("[multiboot] [getMultibootslots]7a HasMultibootMTD, kernel, root, SystemInfo['HasRootSubdir'] ", SystemInfo["HasMultibootMTD"], " ", slot["kernel"], " ", slot["root"], " ", SystemInfo["HasRootSubdir"])
else:
continue
bootslots[int(slotnumber)] = slot
Expand All @@ -107,7 +107,7 @@ def getMultibootslots():
if not path.ismount(tmp.dir):
rmdir(tmp.dir)
if bootslots:
# print("[Multiboot] Bootslots found:", bootslots)
# print("[Multiboot] Bootslots found:", bootslots)
bootArgs = open("/sys/firmware/devicetree/base/chosen/bootargs", "r").read()
print("[Multiboot][MultiBootSlot] bootArgs:", bootArgs)
if fileHas("/proc/cmdline", "kexec=1") and SystemInfo["HasRootSubdir"]: # Kexec Vu+ receiver
Expand All @@ -116,7 +116,7 @@ def getMultibootslots():
SystemInfo["MultiBootSlot"] = int(rootsubdir[0].rsplit(char, 1)[1][11:])
SystemInfo["VuUUIDSlot"] = (UUID, UUIDnum) if UUIDnum != 0 else ""
print("[Multiboot][MultiBootSlot]0 current slot used:", SystemInfo["MultiBootSlot"])
# print("[Multiboot][MultiBootSlot]0 UID, UUIDnum:", SystemInfo["VuUUIDSlot"], " ", SystemInfo["VuUUIDSlot"][0], " ", SystemInfo["VuUUIDSlot"][1])
# print("[Multiboot][MultiBootSlot]0 UID, UUIDnum:", SystemInfo["VuUUIDSlot"], " ", SystemInfo["VuUUIDSlot"][0], " ", SystemInfo["VuUUIDSlot"][1])
elif SystemInfo["HasRootSubdir"] and "root=/dev/sda" not in bootArgs: # RootSubdir receiver or sf8008 receiver with root in eMMC slot
slot = [x[-1] for x in bootArgs.split() if x.startswith("rootsubdir")]
SystemInfo["MultiBootSlot"] = int(slot[0])
Expand All @@ -134,12 +134,12 @@ def getMultibootslots():


def getUUIDtoSD(UUID): # returns None on failure
# print("[multiboot][getUUIDtoSD2] UUID = ", UUID)
# print("[multiboot][getUUIDtoSD2] UUID = ", UUID)
check = "/sbin/blkid"
if fileExists(check):
lines = subprocess.check_output([check]).decode(encoding="utf8", errors="ignore").split("\n")
for line in lines:
# print("[Multiboot][getUUIDtoSD2] line", line)
# print("[Multiboot][getUUIDtoSD2] line", line)
if UUID in line.replace('"', ''):
return line.split(":")[0].strip()
else:
Expand Down Expand Up @@ -174,15 +174,15 @@ def GetImagelist(Recovery=None):
else:
Console(binary=True).ePopen("mount %s %s" % (SystemInfo["canMultiBoot"][slot]["root"], tmpname))
imagedir = sep.join([_f for _f in [tmpname, SystemInfo["canMultiBoot"][slot].get("rootsubdir", "")] if _f])
# print("[multiboot] [GetImagelist]0 isfile = %s" % (path.join(imagedir, "usr/bin/enigma2")))
# print("[multiboot] [GetImagelist]0 isfile = %s" % (path.join(imagedir, "usr/bin/enigma2")))
if path.isfile(path.join(imagedir, "usr/bin/enigma2")):
# print("[multiboot] [GetImagelist]1 Slot = %s imagedir = %s" % (slot, imagedir))
# print("[multiboot] [GetImagelist]1 Slot = %s imagedir = %s" % (slot, imagedir))
if path.isfile(path.join(imagedir, "usr/lib/enigma.info")):
print("[multiboot] [BoxInfo] using BoxInfo")
BuildVersion = createInfo(slot, imagedir=imagedir)
# print("[multiboot] [BoxInfo] slot=%s, BuildVersion=%s" % (slot, BuildVersion))
# print("[multiboot] [BoxInfo] slot=%s, BuildVersion=%s" % (slot, BuildVersion))
else:
# print("[multiboot] [BoxInfo] using BoxBranding")
# print("[multiboot] [BoxInfo] using BoxBranding")
print("[multiboot] [GetImagelist] 2 slot = %s imagedir = %s" % (slot, imagedir))
Creator = open("%s/etc/issue" % imagedir).readlines()[-2].capitalize().strip()[:-6]
print("[multiboot] [GetImagelist] Creator = %s imagedir = %s" % (Creator, imagedir))
Expand All @@ -197,12 +197,12 @@ def GetImagelist(Recovery=None):
BuildVersion = "%s %s %s %s (%s)" % (Creator, BuildType[0:3], Build, Dev, date)
elif fileHas("/proc/cmdline", "kexec=1") and path.isfile(path.join(imagedir, "etc/vtiversion.info")):
Vti = open(path.join(imagedir, "etc/vtiversion.info")).read()
# print("[BootInfo]6 vti = ", Vti)
# print("[BootInfo]6 vti = ", Vti)
date = VerDate(imagedir)
Creator = Vti[0:3]
Build = Vti[-8:-1]
BuildVersion = "%s %s (%s) " % (Creator, Build, date)
# print("[BootInfo]8 BuildVersion = ", BuildVersion )
# print("[BootInfo]8 BuildVersion = ", BuildVersion )
else:
date = VerDate(imagedir)
Creator = Creator.replace("-release", " ")
Expand Down Expand Up @@ -360,7 +360,6 @@ def readBrandingFile(self): # Reads boxbranding.so and updates self.output
if output:
for att in list(self.output.keys()):
self.output[att] = output[att]
# print("[readBrandingFile1] self.output = %s" % self.output)

def addBrandingMethods(self): # This creates reader.getBoxType(), reader.getImageDevBuild(), etc
loc = {}
Expand Down

0 comments on commit 47e9be3

Please sign in to comment.