Skip to content

Commit

Permalink
MultiBootSelector: Stay compatible with OpenPLi startup files
Browse files Browse the repository at this point in the history
  • Loading branch information
betacentauri committed Nov 21, 2020
1 parent 7d7b17f commit 71ee358
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/python/Screens/MultiBootSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def getImagelistCallback(self, imagedict):
for index, x in enumerate(sorted(imagedict.keys())):
if imagedict[x]["imagename"] != _("Empty slot"):
if SystemInfo["canMode12"]:
list.insert(index, ChoiceEntryComponent("", (slotMulti % (x, imagedict[x]["imagename"], 1, current if x == currentimageslot and mode != 12 else ""), x)))
list.append(ChoiceEntryComponent("", (slotMulti % (x, imagedict[x]["imagename"], 12, current if x == currentimageslot and mode == 12 else ""), x + 12)))
list.insert(index, ChoiceEntryComponent("", (slotMulti % (x, imagedict[x]["imagename"], 1, current if x == currentimageslot and mode != 12 else ""), (x, 1))))
list.append(ChoiceEntryComponent("", (slotMulti % (x, imagedict[x]["imagename"], 12, current if x == currentimageslot and mode == 12 else ""), (x, 12))))
indextot = index + 1
else:
list.append(ChoiceEntryComponent("", (slotSingle % (x, imagedict[x]["imagename"], current if x == currentimageslot else ""), x)))
list.append(ChoiceEntryComponent("", (slotSingle % (x, imagedict[x]["imagename"], current if x == currentimageslot else ""), (x, 1))))
if SystemInfo["canMode12"]:
list.insert(indextot, " ")
else:
Expand All @@ -116,20 +116,22 @@ def reboot(self):
self.currentSelected = self["config"].l.getCurrentSelection()
self.slot = self.currentSelected[0][1]
if self.currentSelected[0][1] != "Queued":
print "[MultiBootSelector] reboot2 rebootslot = %s, " % self.slot
slot = self.currentSelected[0][1][0]
boxmode = self.currentSelected[0][1][1]
print "[MultiBootSelector] reboot2 reboot slot = %s, " % slot
print "[MultiBootSelector] reboot2 reboot boxmode = %s, " % boxmode
print "[MultiBootSelector] reboot3 slotinfo = %s" % SystemInfo["canMultiBoot"]
if self.slot < 12:
copyfile(path.join(self.mountDir, SystemInfo["canMultiBoot"][self.slot]["startupfile"]), path.join(self.mountDir, "STARTUP"))
else:
self.slot -= 12
startupfile = path.join(self.mountDir, SystemInfo["canMultiBoot"][self.slot]["startupfile"].replace("BOXMODE_1", "BOXMODE_12"))
print "[MultiBootSelector] reboot5 startupfile = %s" % startupfile
if "BOXMODE" in startupfile:
if SystemInfo["canMode12"]:
if "BOXMODE" in SystemInfo["canMultiBoot"][slot]['startupfile']:
startupfile = path.join(self.mountDir, "%s_%s" % (SystemInfo["canMultiBoot"][slot]['startupfile'].rsplit('_', 1)[0], boxmode))
copyfile(startupfile, path.join(self.mountDir, "STARTUP"))
else:
f = open(startupfile, "r").read().replace("boxmode=1'", "boxmode=12'").replace("%s" % SystemInfo["canMode12"][0], "%s" % SystemInfo["canMode12"][1])
f = open(path.join(self.mountDir, SystemInfo["canMultiBoot"][slot]['startupfile']), "r").read()
if boxmode == 12:
f = f.replace("boxmode=1'", "boxmode=12'").replace("%s" % SystemInfo["canMode12"][0], "%s" % SystemInfo["canMode12"][1])
open(path.join(self.mountDir, "STARTUP"), "w").write(f)
self.session.open(TryQuitMainloop, QUIT_REBOOT)
else:
copyfile(path.join(self.mountDir, SystemInfo["canMultiBoot"][slot]["startupfile"]), path.join(self.mountDir, "STARTUP"))
self.session.open(TryQuitMainloop, QUIT_REBOOT)

def selectionChanged(self):
Expand Down

0 comments on commit 71ee358

Please sign in to comment.