コード例 #1
0
    def __init__(self, session, StandbyCounterIncrease=True):
        self.skinName = "Standby"
        Screen.__init__(self, session)
        self.avswitch = AVSwitch()

        print("[Standby] enter standby")
        BoxInfo.setItem("StandbyState", True)

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

        self["actions"] = ActionMap(["StandbyActions"], {
            "power": self.Power,
            "discrete_on": self.Power
        }, -1)

        globalActionMap.setEnabled(False)

        self.infoBarInstance = isInfoBarInstance()
        from Screens.SleepTimerEdit import isNextWakeupTime
        self.StandbyCounterIncrease = StandbyCounterIncrease
        self.standbyTimeoutTimer = eTimer()
        self.standbyTimeoutTimer.callback.append(self.standbyTimeout)
        self.standbyStopServiceTimer = eTimer()
        self.standbyStopServiceTimer.callback.append(self.stopService)
        self.standbyWakeupTimer = eTimer()
        self.standbyWakeupTimer.callback.append(self.standbyWakeup)
        self.timeHandler = None

        self.setMute()

        self.paused_service = self.paused_action = False

        self.prev_running_service = self.session.nav.getCurrentlyPlayingServiceOrGroup(
        )
        if Components.ParentalControl.parentalControl.isProtected(
                self.prev_running_service):
            self.prev_running_service = eServiceReference(
                config.tv.lastservice.value)
        service = self.prev_running_service and self.prev_running_service.toString(
        )
        if service:
            if service.rsplit(":", 1)[1].startswith("/"):
                self.paused_service = hasattr(
                    self.session.current_dialog, "pauseService") and hasattr(
                        self.session.current_dialog, "unPauseService"
                    ) and self.session.current_dialog or self.infoBarInstance
                self.paused_action = hasattr(
                    self.paused_service, "seekstate"
                ) and hasattr(
                    self.paused_service, "SEEK_STATE_PLAY"
                ) and self.paused_service.seekstate == self.paused_service.SEEK_STATE_PLAY
                self.paused_action and 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:
            self.infoBarInstance and hasattr(
                self.infoBarInstance,
                "showPiP") and self.infoBarInstance.showPiP()

        if BoxInfo.getItem("ScartSwitch"):
            self.avswitch.setInput("SCART")
        else:
            self.avswitch.setInput("AUX")

        try:
            print("[Standby] Write to /proc/stb/hdmi/output")
            open("/proc/stb/hdmi/output", "w").write("off")
        except:
            print("[Standby] Write to /proc/stb/hdmi/output failed.")

        if BoxInfo.getItem("AmlogicFamily"):
            try:
                print("[Standby] Write to /sys/class/leds/led-sys/brightness")
                open("/sys/class/leds/led-sys/brightness", "w").write("0")
            except:
                print(
                    "[Standby] Write to /sys/class/leds/led-sys/brightness failed."
                )
            try:
                print("[Standby] Write to /sys/class/cec/cmd")
                open("/sys/class/cec/cmd", "w").write("0f 36")
            except:
                print("[Standby] Write to /sys/class/cec/cmd failed.")

        gotoShutdownTime = int(config.usage.standby_to_shutdown_timer.value)
        if gotoShutdownTime:
            self.standbyTimeoutTimer.startLongTimer(gotoShutdownTime)

        if self.StandbyCounterIncrease is not 1:
            gotoWakeupTime = isNextWakeupTime(True)
            if gotoWakeupTime != -1:
                curtime = localtime(time())
                if curtime.tm_year > 1970:
                    wakeup_time = int(gotoWakeupTime - time())
                    if wakeup_time > 0:
                        self.standbyWakeupTimer.startLongTimer(wakeup_time)

        self.onFirstExecBegin.append(self.__onFirstExecBegin)
        self.onClose.append(self.__onClose)
コード例 #2
0
def getMultiBootSlots():
    global bootSlots, startupDevice
    bootSlots = {}
    mode12Found = False
    if startupDevice is None:
        startupDevice = getMultiBootStartupDevice()
    if startupDevice:
        tempDir = mkdtemp(prefix=PREFIX)
        Console().ePopen((MOUNT, MOUNT, startupDevice, tempDir))
        for file in glob(pathjoin(tempDir, "STARTUP_*")):
            if "STARTUP_RECOVERY" in file:
                BoxInfo.setItem("RecoveryMode", True)
                print("[MultiBoot] Recovery mode is set to True.")
            if "MODE_" in file:
                mode12Found = True
                slotNumber = file.rsplit("_", 3)[1]
            else:
                slotNumber = file.rsplit("_", 1)[1]
            if slotNumber.isdigit() and slotNumber not in bootSlots:
                lines = fileReadLines(file, source=MODULE_NAME)
                if lines:
                    slot = {}
                    for line in lines:
                        if "root=" in line:
                            device = getArgValue(line, "root")
                            if exists(device):
                                slot["device"] = device
                                slot["startupfile"] = basename(file)
                                if "rootsubdir" in line:
                                    BoxInfo.setItem("HasRootSubdir", True)
                                    slot["kernel"] = getArgValue(
                                        line, "kernel")
                                    slot["rootsubdir"] = getArgValue(
                                        line, "rootsubdir")
                                elif "sda" in line:
                                    slot["kernel"] = getArgValue(
                                        line, "kernel")
                                    slot["rootsubdir"] = None
                                else:
                                    slot["kernel"] = "%sp%s" % (device.split(
                                        "p")[0], int(device.split("p")[1]) - 1)
                                bootSlots[int(slotNumber)] = slot
                            break
                else:
                    print(
                        "[MultiBoot] Warning: No content in file '%s' for slot number '%s'!"
                        % (file, slotNumber))
            else:
                print(
                    "[MultiBoot] Warning: Unexpected slot number '%s' in file '%s'!"
                    % (slotNumber, file))
        Console().ePopen((UMOUNT, UMOUNT, tempDir))
        if not ismount(tempDir):
            rmdir(tempDir)
        if not mode12Found and BoxInfo.getItem("canMode12"):
            # The boot device has ancient content and does not contain the correct STARTUP files!
            for slot in range(1, 5):
                bootSlots[slot] = {
                    "device": "/dev/mmcblk0p%s" % (slot * 2 + 1),
                    "startupfile": None
                }
    if bootSlots:
        for slot in sorted(list(bootSlots.keys())):
            print("[MultiBoot] Boot slot %d: %s" %
                  (slot, str(bootSlots[slot])))
    else:
        print("[MultiBoot] No boot slots found.")
    return bootSlots
コード例 #3
0
ファイル: plugin.py プロジェクト: technic/enigma2-atv
if isPluginInstalled("MultiQuickButton"):
    try:
        from Plugins.Extensions.MultiQuickButton.plugin import *
    except:
        pass

from Screens.CronTimer import *
from Plugins.Extensions.Infopanel.ScriptRunner import *
from Plugins.Extensions.Infopanel.MountManager import *
from Plugins.Extensions.Infopanel.SoftcamPanel import *
from Plugins.Extensions.Infopanel.SwapManager import Swap, SwapAutostart
from Plugins.Extensions.Infopanel.SoftwarePanel import SoftwarePanel
from Plugins.SystemPlugins.SoftwareManager.BackupRestore import BackupScreen, RestoreScreen, BackupSelection, getBackupPath, getBackupFilename
from Plugins.SystemPlugins.SoftwareManager.BackupRestore import InitConfig as BackupRestore_InitConfig

BoxInfo.setItem("SoftCam", Check_Softcam())

# Hide Softcam-Panel Setup when no softcams installed
if not Check_Softcam() and config.plugins.showinfopanelextensions.value:
    config.plugins.showinfopanelextensions.value = False
    config.plugins.showinfopanelextensions.save()
    config.plugins.infopanel_redpanel.save()

# Hide Keymap selection when no other keymaps installed.
if config.usage.keymap.value != eEnv.resolve("${datadir}/enigma2/keymap.xml"):
    if not os.path.isfile(eEnv.resolve("${datadir}/enigma2/keymap.usr")
                          ) and config.usage.keymap.value == eEnv.resolve(
                              "${datadir}/enigma2/keymap.usr"):
        setDefaultKeymap()
    if not os.path.isfile(eEnv.resolve("${datadir}/enigma2/keymap.ntr")
                          ) and config.usage.keymap.value == eEnv.resolve(