def getBootOptions(self, value=None):
     self.container = Console()
     if path.isdir(self.mountDir) and path.ismount(self.mountDir):
         self.getImagesList()
     else:
         if not path.isdir(self.mountDir):
             mkdir(self.mountDir)
         self.container.ePopen(
             "mount %s %s" % (SystemInfo["MBbootdevice"], self.mountDir),
             self.getImagesList)
Beispiel #2
0
def getMBbootdevice():
	if not path.isdir(Imagemount):
		mkdir(Imagemount)
	for device in ('/dev/block/by-name/bootoptions', '/dev/mmcblk0p1', '/dev/mmcblk1p1', '/dev/mmcblk0p3', '/dev/mmcblk0p4'):
		if path.exists(device):
			Console().ePopen("mount %s %s" % (device, Imagemount))
			if path.isfile(path.join(Imagemount, "STARTUP")):
				print('[Multiboot] Startupdevice found:', device)
				return device
			Console().ePopen("umount %s" % Imagemount)
	if not path.ismount(Imagemount):
		rmdir(Imagemount)
Beispiel #3
0
	def __init__(self, callback):
		if SystemInfo["canMultiBoot"]:
			self.slots = sorted(list(SystemInfo["canMultiBoot"].keys()))
			self.callback = callback
			self.imagelist = {}
			if not path.isdir(Imagemount):
				mkdir(Imagemount)
			self.container = Console()
			self.phase = self.MOUNT
			self.run()
		else:
			callback({})
Beispiel #4
0
def getMultibootslots():
    bootslots = {}
    if SystemInfo["MBbootdevice"]:
        if not path.isdir(Imagemount):
            mkdir(Imagemount)
        Console().ePopen("/bin/mount %s %s" %
                         (SystemInfo["MBbootdevice"], Imagemount))
        for file in glob.glob(path.join(Imagemount, "STARTUP_*")):
            if "STARTUP_RECOVERY" in file:
                SystemInfo["RecoveryMode"] = True
                print "[multiboot] [getMultibootslots] RecoveryMode is set to:%s" % SystemInfo[
                    "RecoveryMode"]
            slotnumber = file.rsplit("_", 3 if "BOXMODE" in file else 1)[1]
            if slotnumber.isdigit() and slotnumber not in bootslots:
                slot = {}
                for line in open(file).readlines():
                    # print "Multiboot getMultibootslots readlines = %s " %line
                    if "root=" in line:
                        line = line.rstrip("\n")
                        device = getparam(line, "root")
                        if path.exists(device):
                            slot["device"] = device
                            slot["startupfile"] = path.basename(file)
                            if "sda" in line:
                                slot["kernel"] = "/dev/sda%s" % line.split(
                                    "sda", 1)[1].split(" ", 1)[0]
                                slot["rootsubdir"] = None
                            else:
                                slot["kernel"] = "%sp%s" % (device.split(
                                    "p")[0], int(device.split("p")[1]) - 1)
                            if "rootsubdir" in line:
                                SystemInfo["HasRootSubdir"] = True
                                print "[multiboot] [getMultibootslots] HasRootSubdir is set to:%s" % SystemInfo[
                                    "HasRootSubdir"]
                                slot["rootsubdir"] = getparam(
                                    line, "rootsubdir")
                                slot["kernel"] = getparam(line, "kernel")

                        break
                if slot:
                    bootslots[int(slotnumber)] = slot
        print "[multiboot1] getMultibootslots bootslots = %s" % bootslots
        Console().ePopen("umount %s" % Imagemount)
        if not path.ismount(Imagemount):
            rmdir(Imagemount)
    return bootslots
Beispiel #5
0
class EmptySlot():
    MOUNT = 0
    UNMOUNT = 1

    def __init__(self, Contents, callback):
        if SystemInfo["canMultiBoot"]:
            self.slots = sorted(SystemInfo["canMultiBoot"].keys())
            self.callback = callback
            self.imagelist = {}
            self.slot = Contents
            if not path.isdir(Imagemount):
                mkdir(Imagemount)
            self.container = Console()
            self.phase = self.MOUNT
            self.run()
        else:
            callback({})

    def run(self):
        if self.phase == self.UNMOUNT:
            self.container.ePopen("umount %s" % Imagemount, self.appClosed)
        else:
            self.container.ePopen(
                "mount %s %s" %
                (SystemInfo["canMultiBoot"][self.slot]["device"], Imagemount),
                self.appClosed)

    def appClosed(self, data="", retval=0, extra_args=None):
        if retval == 0 and self.phase == self.MOUNT:
            if SystemInfo["HasRootSubdir"] and SystemInfo["canMultiBoot"][
                    self.slot]["rootsubdir"] != None:
                imagedir = (
                    '%s/%s' %
                    (Imagemount,
                     SystemInfo["canMultiBoot"][self.slot]["rootsubdir"]))
            else:
                imagedir = Imagemount
            if path.isfile("%s/usr/bin/enigma2" % imagedir):
                rename("%s/usr/bin/enigma2" % imagedir,
                       "%s/usr/bin/enigmax.bin" % imagedir)
                rename("%s/etc" % imagedir, "%s/etcx" % imagedir)
            self.phase = self.UNMOUNT
            self.run()
        else:
            self.container.killAll()
            if not path.ismount(Imagemount):
                rmdir(Imagemount)
            self.callback()
Beispiel #6
0
    def __init__(self, session):
        Screen.__init__(self, session)
        self.skinName = "Standby"
        self.avswitch = AVSwitch()
        self.oldService = self.session.nav.getCurrentlyPlayingServiceOrGroup()
        print "[Standby] enter standby"
        SystemInfo["StandbyState"] = True

        if os.path.exists("/usr/script/StandbyEnter.sh"):
            Console().ePopen("/usr/script/StandbyEnter.sh &")

        self["actions"] = ActionMap(
            ["StandbyActions"], {
                "power": self.Power,
                "power_make": self.Power_make,
                "power_break": self.Power_break,
                "power_long": self.Power_long,
                "power_repeat": self.Power_repeat,
                "discrete_on": self.Power
            }, -1)

        globalActionMap.setEnabled(False)

        self.ignoreKeyBreakTimer = eTimer()
        self.standbyStopServiceTimer = eTimer()
        self.standbyStopServiceTimer.callback.append(self.stopService)
        self.timeHandler = None

        #mute adc
        self.setMute()
        self.stopService()
        if SystemInfo["Display"] and SystemInfo["LCDMiniTV"]:
            # set LCDminiTV off
            setLCDModeMinitTV("0")
        elif SystemInfo["Display"] and SystemInfo["LCDMiniTV4k"]:
            # set LCDminiTV off
            setLCDModeMinitTV4k("disable")

        self.paused_service = None
        self.prev_running_service = None
        if self.session.current_dialog:
            if self.session.current_dialog.ALLOW_SUSPEND == Screen.SUSPEND_STOPS:
                #get currently playing service reference
                self.prev_running_service = self.session.nav.getCurrentlyPlayingServiceOrGroup(
                )
                #stop actual played dvb-service
                self.session.nav.stopService()
            elif self.session.current_dialog.ALLOW_SUSPEND == Screen.SUSPEND_PAUSES:
                self.paused_service = self.session.current_dialog
                self.paused_service.pauseService()
        if not self.paused_service:
            self.timeHandler = eDVBLocalTimeHandler.getInstance()
            if self.timeHandler.ready():
                if self.session.nav.getCurrentlyPlayingServiceOrGroup():
                    self.stopService()
                else:
                    self.standbyStopServiceTimer.startLongTimer(5)
                self.timeHandler = None
            else:
                self.timeHandler.m_timeUpdated.get().append(self.stopService)

        if self.session.pipshown:
            from Screens.InfoBar import InfoBar
            InfoBar.instance and hasattr(
                InfoBar.instance, "showPiP") and InfoBar.instance.showPiP()

        #set input to vcr scart
        if SystemInfo["ScartSwitch"]:
            self.avswitch.setInput("SCART")
        else:
            self.avswitch.setInput("AUX")

        gotoShutdownTime = int(config.usage.standby_to_shutdown_timer.value)
        print "goto deep2"
        if gotoShutdownTime:
            print "goto deep3"
            self.standbyTimeoutTimer = eTimer()
            self.standbyTimeoutTimer.callback.append(self.standbyTimeout)
            self.standbyTimeoutTimer.startLongTimer(gotoShutdownTime)

        if (getBrandOEM() in ('fulan', 'clap', 'dinobot') or getMachineBuild()
                in ('gbmv200', 'sf8008', 'sf8008m', 'ustym4kpro')):
            try:
                open("/proc/stb/hdmi/output", "w").write("off")
            except:
                pass
        self.onFirstExecBegin.append(self.__onFirstExecBegin)
        self.onClose.append(self.__onClose)
 def cancel(self, value=None):
     self.container = Console()
     self.container.ePopen("umount %s" % self.mountDir,
                           boundFunction(self.unmountCallback, value))
class MultiBootSelector(Screen, HelpableScreen):
    skinTemplate = """
	<screen title="MultiBoot Image Selector" position="center,center" size="%d,%d">
		<widget name="config" position="%d,%d" size="%d,%d" font="Regular;%d" itemHeight="%d" scrollbarMode="showOnDemand" />
		<widget source="options" render="Label" position="%d,e-160" size="%d,%d" font="Regular;%d" halign="center" valign="center" />
		<widget source="description" render="Label" position="%d,e-90" size="%d,%d" font="Regular;%d" />
		<widget source="key_red" render="Label" position="%d,e-50" size="%d,%d" backgroundColor="key_red" font="Regular;%d" foregroundColor="key_text" halign="center" noWrap="1" valign="center" />
		<widget source="key_green" render="Label" position="%d,e-50" size="%d,%d" backgroundColor="key_green" font="Regular;%d" foregroundColor="key_text" halign="center" noWrap="1" valign="center" />
	</screen>"""
    scaleData = [
        800, 485, 10, 10, 780, 306, 24, 34, 10, 780, 60, 20, 10, 780, 30, 22,
        10, 140, 40, 20, 160, 140, 40, 20
    ]
    skin = None

    def __init__(self, session, *args):
        Screen.__init__(self, session)
        HelpableScreen.__init__(self)
        if MultiBootSelector.skin is None:
            # The skin template is designed for a HD screen so the scaling factor is 720.
            MultiBootSelector.skin = MultiBootSelector.skinTemplate % tuple([
                x * getDesktop(0).size().height() / 720
                for x in MultiBootSelector.scaleData
            ])
        Screen.setTitle(self, _("MultiBoot Image Selector"))
        self["config"] = ChoiceList(list=[
            ChoiceEntryComponent("", (
                (_("Retrieving image slots - Please wait...")), "Queued"))
        ])
        self["options"] = StaticText(
            _("Mode 1 suppports Kodi, PiP may not work.\nMode 12 supports PiP, Kodi may not work."
              ) if SystemInfo["canMode12"] else "")
        self["description"] = StaticText(
            _("Use the cursor keys to select an installed image and then Reboot button."
              ))
        self["key_red"] = StaticText(_("Cancel"))
        self["key_green"] = StaticText(_("Reboot"))
        self["actions"] = HelpableActionMap(
            self, [
                "OkCancelActions", "ColorActions", "DirectionActions",
                "KeyboardInputActions", "MenuActions"
            ], {
                "red": (boundFunction(self.close, None),
                        _("Cancel the image selection and exit")),
                "green":
                (self.reboot, _("Select the highlighted image and reboot")),
                "ok":
                (self.reboot, _("Select the highlighted image and reboot")),
                "cancel": (boundFunction(self.close, None),
                           _("Cancel the image selection and exit")),
                "up": (self.keyUp, _("Move up a line")),
                "down": (self.keyDown, _("Move down a line")),
                "left": (self.keyLeft, _("Move up a line")),
                "right": (self.keyRight, _("Move down a line")),
                "upRepeated": (self.keyUp, _("Move up a line")),
                "downRepeated": (self.keyDown, _("Move down a line")),
                "leftRepeated": (self.keyLeft, _("Move up a line")),
                "rightRepeated": (self.keyRight, _("Move down a line")),
                "menu": (boundFunction(self.close, True),
                         _("Cancel the image selection and exit all menus"))
            },
            -1,
            description=_("MultiBootSelector Actions"))
        imagedict = []
        self.getImageList = None
        self.mountDir = "/tmp/startupmount"
        self.callLater(self.getBootOptions)

    def cancel(self, value=None):
        self.container = Console()
        self.container.ePopen("umount %s" % self.mountDir,
                              boundFunction(self.unmountCallback, value))

    def unmountCallback(self, value, data=None, retval=None, extra_args=None):
        self.container.killAll()
        if not path.ismount(self.mountDir):
            rmdir(self.mountDir)
        self.close(value)

    def getBootOptions(self, value=None):
        self.container = Console()
        if path.isdir(self.mountDir) and path.ismount(self.mountDir):
            self.getImagesList()
        else:
            if not path.isdir(self.mountDir):
                mkdir(self.mountDir)
            self.container.ePopen(
                "mount %s %s" % (SystemInfo["MBbootdevice"], self.mountDir),
                self.getImagesList)

    def getImagesList(self, data=None, retval=None, extra_args=None):
        self.container.killAll()
        self.getImageList = GetImagelist(self.getImagelistCallback)

    def getImagelistCallback(self, imagedict):
        list = []
        mode = GetCurrentImageMode() or 0
        currentimageslot = GetCurrentImage()
        print "[MultiBootSelector] reboot1 slot:", currentimageslot
        current = "  %s" % _("(current image)")
        slotSingle = _("Slot %s: %s%s")
        slotMulti = _("Slot %s: %s - Mode %d%s")
        if imagedict:
            indextot = 0
            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)))
                        indextot = index + 1
                    else:
                        list.append(
                            ChoiceEntryComponent(
                                "",
                                (slotSingle %
                                 (x, imagedict[x]["imagename"],
                                  current if x == currentimageslot else ""),
                                 x)))
            if SystemInfo["canMode12"]:
                list.insert(indextot, " ")
        else:
            list.append(
                ChoiceEntryComponent("", ((_("No images found")), "Waiter")))
        self["config"].setList(list)

    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
            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:
                    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])
                    open(path.join(self.mountDir, "STARTUP"), "w").write(f)
                    self.session.open(TryQuitMainloop, QUIT_REBOOT)
            self.session.open(TryQuitMainloop, QUIT_REBOOT)

    def selectionChanged(self):
        currentSelected = self["config"].l.getCurrentSelection()

    def keyLeft(self):
        self["config"].instance.moveSelection(self["config"].instance.moveUp)
        self.selectionChanged()

    def keyRight(self):
        self["config"].instance.moveSelection(self["config"].instance.moveDown)
        self.selectionChanged()

    def keyUp(self):
        self["config"].instance.moveSelection(self["config"].instance.moveUp)
        self.selectionChanged()

    def keyDown(self):
        self["config"].instance.moveSelection(self["config"].instance.moveDown)
        self.selectionChanged()
Beispiel #9
0
class GetImagelist():
	MOUNT = 0
	UNMOUNT = 1

	def __init__(self, callback):
		if SystemInfo["canMultiBoot"]:
			self.slots = sorted(list(SystemInfo["canMultiBoot"].keys()))
			self.callback = callback
			self.imagelist = {}
			if not path.isdir(Imagemount):
				mkdir(Imagemount)
			self.container = Console()
			self.phase = self.MOUNT
			self.run()
		else:
			callback({})

	def run(self):
		if self.phase == self.UNMOUNT:
			self.container.ePopen("umount %s" % Imagemount, self.appClosed)
		else:
			self.slot = self.slots.pop(0)
			self.container.ePopen("mount %s %s" % (SystemInfo["canMultiBoot"][self.slot]["device"], Imagemount), self.appClosed)

	def appClosed(self, data="", retval=0, extra_args=None):
		BuildVersion = "  "
		Build = " "  # ViX Build No.
		Dev = " "  # ViX Dev No.
		Creator = " "  # Openpli Openvix Openatv etc
		Date = " "
		BuildType = " "  # release etc
		if retval:
			self.imagelist[self.slot] = {"imagename": _("Empty slot")}
		if retval == 0 and self.phase == self.MOUNT:
			if SystemInfo["HasRootSubdir"] and SystemInfo["canMultiBoot"][self.slot]["rootsubdir"] != None:
				imagedir = ('%s/%s' %(Imagemount, SystemInfo["canMultiBoot"][self.slot]["rootsubdir"]))
			else:
				imagedir = Imagemount
			if path.isfile("%s/usr/bin/enigma2" % imagedir):
				Creator = open("%s/etc/issue" % imagedir).readlines()[-2].capitalize().strip()[:-6].replace("-release", " rel")
				if Creator.startswith("Openvix"):
					reader = boxbranding_reader(imagedir)
					BuildType = reader.getImageType()
					Build = reader.getImageBuild()
					Dev = BuildType != "release" and " %s" % reader.getImageDevBuild() or ""
					BuildVersion = "%s %s %s %s" % (Creator, BuildType[0:3], Build, Dev)
				else:
					try:
						from datetime import datetime
						date = datetime.fromtimestamp(stat(path.join(imagedir, "var/lib/opkg/status")).st_mtime).strftime("%Y-%m-%d")
						if date.startswith("1970"):
							date = datetime.fromtimestamp(stat(path.join(imagedir, "usr/share/bootlogo.mvi")).st_mtime).strftime("%Y-%m-%d")
						date = max(date, datetime.fromtimestamp(stat(path.join(imagedir, "usr/bin/enigma2")).st_mtime).strftime("%Y-%m-%d"))
					except Exception:
						date = _("Unknown")
					BuildVersion = "%s (%s)" % (open(path.join(imagedir, "etc/issue")).readlines()[-2].capitalize().strip()[:-6], date)
				self.imagelist[self.slot] = {"imagename": "%s" % BuildVersion}
			else:
				self.imagelist[self.slot] = {"imagename": _("Empty slot")}
			if self.slots and SystemInfo["canMultiBoot"][self.slot]["device"] == SystemInfo["canMultiBoot"][self.slots[0]]["device"]:
				self.slot = self.slots.pop(0)
				self.appClosed()
			else:
				self.phase = self.UNMOUNT
				self.run()
		elif self.slots:
			self.phase = self.MOUNT
			self.run()
		else:
			self.container.killAll()
			if not path.ismount(Imagemount):
				rmdir(Imagemount)
			self.callback(self.imagelist)