Beispiel #1
0
 def jobTask(self):
     linkState = 0
     if exists("/sys/class/net/wlan0/operstate"):
         linkState = fileReadLine("/sys/class/net/wlan0/operstate")
         if linkState != "down":
             linkState = fileReadLine("/sys/class/net/wlan0/carrier")
     elif exists("/sys/class/net/eth0/operstate"):
         linkState = fileReadLine("/sys/class/net/eth0/operstate")
         if linkState != "down":
             linkState = fileReadLine("/sys/class/net/eth0/carrier")
     linkState = linkState[:1]
     if exists("/proc/stb/lcd/symbol_network"
               ) and config.lcd.mode.value == "1":
         fileWriteLine("/proc/stb/lcd/symbol_network", linkState)
     elif exists("/proc/stb/lcd/symbol_network"
                 ) and config.lcd.mode.value == "0":
         fileWriteLine("/proc/stb/lcd/symbol_network", "0")
     USBState = 0
     for bus in busses():
         devices = bus.devices
         for dev in devices:
             if dev.deviceClass != 9 and dev.deviceClass != 2 and dev.idVendor != 3034 and dev.idVendor > 0:
                 USBState = 1
     if exists("/proc/stb/lcd/symbol_usb"):
         fileWriteLine("/proc/stb/lcd/symbol_usb", USBState)
     self.timer.startLongTimer(30)
def getHWSerial():
	if isfile("/proc/stb/info/sn"):
		hwserial = fileReadLine("/proc/stb/info/sn", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/info/serial"):
		hwserial = fileReadLine("/proc/stb/info/serial", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/info/serial_number"):
		hwserial = fileReadLine("/proc/stb/info/serial_number", "unknown", source=MODULE_NAME)
	else:
		hwserial = fileReadLine("/sys/class/dmi/id/product_serial", "unknown", source=MODULE_NAME)
	return hwserial.strip()
 def model(self):
     if self.device[:2] == "hd":
         return fileReadLine(pathjoin("/proc/ide", self.device, "model"),
                             _("Unknown"))
     elif self.device[:2] == "sd":
         vendor = fileReadLine(self.sysfsPath("device/vendor"),
                               _("Unknown"))
         model = fileReadLine(self.sysfsPath("device/model"), _("Unknown"))
         return "%s (%s)" % (vendor, model)
     elif self.device.startswith("mmcblk"):
         return fileReadLine(self.sysfsPath("device/name"), _("Unknown"))
     print("[Harddisk] Error: Failed to get model: No hdX or sdX or mmcX!")
     return "-?-"
Beispiel #4
0
def getSystemTemperature():
    temperature = ""
    if isfile("/proc/stb/sensors/temp0/value"):
        temperature = fileReadLine("/proc/stb/sensors/temp0/value",
                                   source=MODULE_NAME)
    elif isfile("/proc/stb/sensors/temp/value"):
        temperature = fileReadLine("/proc/stb/sensors/temp/value",
                                   source=MODULE_NAME)
    elif isfile("/proc/stb/fp/temp_sensor"):
        temperature = fileReadLine("/proc/stb/fp/temp_sensor",
                                   source=MODULE_NAME)
    if temperature:
        return "%s%s C" % (temperature, u"\u00B0")
    return temperature
 def getUserfriendlyDeviceName(self, dev, phys):
     dev, part = self.splitDeviceName(dev)
     description = _("External Storage %s") % dev
     if exists(pathjoin("/sys", phys, "model")):
         description = fileReadLine(pathjoin("/sys", phys, "model"),
                                    _("Unknown"))
     elif exists(pathjoin("/sys", phys, "name")):
         description = fileReadLine(pathjoin("/sys", phys, "name"),
                                    _("Unknown"))
     else:
         print("[Harddisk] Error: Couldn't read model!")
     # not wholedisk and not partition 1
     if part and part != 1:
         description += _(" (Partition %d)") % part
     return description
Beispiel #6
0
def getFPWasTimerWakeup(check=False):
    global wasTimerWakeup
    isError = False
    if wasTimerWakeup is not None:
        if check:
            return wasTimerWakeup, isError
        return wasTimerWakeup
    wasTimerWakeup = fileReadLine("/proc/stb/fp/was_timer_wakeup",
                                  source=MODULE_NAME)
    if wasTimerWakeup is not None:
        wasTimerWakeup = int(wasTimerWakeup) and True or False
        if not fileWriteLine("/tmp/was_timer_wakeup.txt",
                             str(wasTimerWakeup),
                             source=MODULE_NAME):
            try:
                with open("/dev/dbox/fp0") as fd:
                    wasTimerWakeup = unpack('B', ioctl(
                        fd.fileno(), 9, ' '))[0] and True or False
            except (IOError, OSError) as err:
                isError = True
                print(
                    "[StbHardware] Error %d: Unable to read '/dev/dbox/fp0', getFPWasTimerWakeup failed!  (%s)"
                    % (err.errno, err.strerror))
    else:
        wasTimerWakeup = False
    if wasTimerWakeup:
        clearFPWasTimerWakeup()  # Clear hardware status.
    if check:
        return wasTimerWakeup, isError
    return wasTimerWakeup
Beispiel #7
0
 def __init__(self):
     print("[MultiBoot] MultiBoot is initializing.")
     self.bootArgs = fileReadLine(
         "/sys/firmware/devicetree/base/chosen/bootargs",
         default="",
         source=MODULE_NAME)
     self.loadMultiBoot()
def getFPVersion():
	if isfile("/proc/stb/info/micomver"):
		version = fileReadLine("/proc/stb/info/micomver", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/fp/version"):
		if BoxInfo.getItem("platform") == "dm4kgen" or BoxInfo.getItem("model") in ("dm520", "dm7080", "dm820"):
			version = fileReadLine("/proc/stb/fp/version", "unknown", source=MODULE_NAME)
		else:
			version = int(fileReadLine("/proc/stb/fp/version", "0", source=MODULE_NAME))
	elif isfile("/sys/firmware/devicetree/base/bolt/tag"):
		version = fileReadLine("/sys/firmware/devicetree/base/bolt/tag", "unknown", source=MODULE_NAME).rstrip("\0")
	else:
		try:
			with open("/dev/dbox/fp0") as fd:
				version = ioctl(fd.fileno(), 0)
		except (IOError, OSError) as err:
			version = "unknown"
			print("[StbHardware] Error %d: Unable to access '/dev/dbox/fp0', getFPVersion failed!  (%s)" % (err.errno, err.strerror))
	return version
 def __init__(self, device, removable=False):
     self.device = device
     self.card = False
     self.max_idle_time = 0
     self.idle_running = False
     self.last_access = time()
     self.last_stat = 0
     self.timer = None
     self.is_sleeping = False
     self.dev_path = ""
     self.disk_path = ""
     self.mount_path = None
     self.mount_device = None
     self.phys_path = realpath(self.sysfsPath("device"))
     self.removable = removable
     self.internal = "ide" in self.phys_path or "pci" in self.phys_path or "ahci" in self.phys_path or "sata" in self.phys_path
     data = fileReadLine(pathjoin("/sys/block", device, "queue/rotational"),
                         "1")
     self.rotational = int(data)
     if BoxInfo.getItem("Udev"):
         self.dev_path = "/dev/" + self.device
         self.disk_path = self.dev_path
         self.card = "sdhci" in self.phys_path or "mmc" in self.device
     else:
         tmp = fileReadLine(self.sysfsPath("dev")).split(":")
         s_major = int(tmp[0])
         s_minor = int(tmp[1])
         for disc in listdir("/dev/discs"):
             dev_path = realpath("/dev/discs/" + disc)
             disk_path = dev_path + "/disc"
             try:
                 rdev = stat(disk_path).st_rdev
             except (IOError, OSError):
                 continue
             if s_major == major(rdev) and s_minor == minor(rdev):
                 self.dev_path = dev_path
                 self.disk_path = disk_path
                 break
         self.card = self.device[:2] == "hd" and "host0" not in self.dev_path
     print("[Harddisk] New device '%s' -> '%s' -> '%s'." %
           (self.device, self.dev_path, self.disk_path))
     if (self.internal or not removable) and not self.card:
         self.startIdle()
def getFPWakeuptime():
	wakeup = fileReadLine("/proc/stb/fp/wakeup_time", source=MODULE_NAME)
	if wakeup is None:
		try:
			with open("/dev/dbox/fp0") as fd:
				wakeup = unpack('L', ioctl(fd.fileno(), 5, '    '))[0]  # Get wakeup time.
		except (IOError, OSError) as err:
			wakeup = 0
			print("[StbHardware] Error %d: Unable to read '/dev/dbox/fp0', getFPWakeuptime failed!  (%s)" % (err.errno, err.strerror))
	return wakeup
	def __init__(self):
		global hw_info
		if hw_info:
			return
		hw_info = self
		self.device_version = fileReadLine("/proc/stb/info/version", "", source=MODULE_NAME).strip()
		self.device_revision = fileReadLine("/proc/stb/info/board_revision", "", source=MODULE_NAME).strip()
		self.device_name = BoxInfo.getItem("model")
		self.device_brandname = BoxInfo.getItem("brand")
		self.device_model = BoxInfo.getItem("model")
		self.device_model = self.device_model or self.device_name
		self.device_hw = self.device_model
		self.machine_name = self.device_model
		if self.device_revision:
			self.device_string = "%s (%s-%s)" % (self.device_hw, self.device_revision, self.device_version)
		elif self.device_version:
			self.device_string = "%s (%s)" % (self.device_hw, self.device_version)
		else:
			self.device_string = self.device_hw
		self.device_hdmi = BoxInfo.getItem("hdmi")  # Only some early DMM boxes do not have HDMI hardware.
		print("[HardwareInfo] Detected: '%s'." % self.get_device_string())
 def diskSize(self):
     line = fileReadLine(self.sysfsPath("size"))
     if line is None:
         dev = self.findMount()
         if dev:
             try:
                 stat = statvfs(dev)
                 cap = int(stat.f_blocks * stat.f_bsize)
                 return cap / 1000 / 1000
             except (IOError, OSError):
                 return 0
     cap = int(line)
     return cap / 1000 * 512 / 1000
def getBoxProc():
	if isfile("/proc/stb/info/hwmodel"):
		procmodel = fileReadLine("/proc/stb/info/hwmodel", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/info/azmodel"):
		procmodel = fileReadLine("/proc/stb/info/model", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/info/gbmodel"):
		procmodel = fileReadLine("/proc/stb/info/gbmodel", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/info/vumodel") and not isfile("/proc/stb/info/boxtype"):
		procmodel = fileReadLine("/proc/stb/info/vumodel", "unknown", source=MODULE_NAME)
	elif isfile("/proc/stb/info/boxtype") and not isfile("/proc/stb/info/vumodel"):
		procmodel = fileReadLine("/proc/stb/info/boxtype", "unknown", source=MODULE_NAME)
	elif isfile("/proc/boxtype"):
		procmodel = fileReadLine("/proc/boxtype", "unknown", source=MODULE_NAME)
	elif isfile("/proc/device-tree/model"):
		procmodel = fileReadLine("/proc/device-tree/model", "unknown", source=MODULE_NAME).strip()[0:12]
	elif isfile("/sys/firmware/devicetree/base/model"):
		procmodel = fileReadLine("/sys/firmware/devicetree/base/model", "unknown", source=MODULE_NAME)
	else:
		procmodel = fileReadLine("/proc/stb/info/model", "unknown", source=MODULE_NAME)
	return procmodel.strip().lower()
Beispiel #14
0
def getBoxUptime():
	upTime = fileReadLine("/proc/uptime", source=MODULE_NAME)
	if upTime is None:
		return "-"
	secs = int(upTime.split(".")[0])
	times = []
	if secs > 86400:
		days = secs // 86400
		secs = secs % 86400
		times.append(ngettext("%d day", "%d days", days) % days)
	h = secs // 3600
	m = (secs % 3600) // 60
	times.append(ngettext("%d hour", "%d hours", h) % h)
	times.append(ngettext("%d minute", "%d minutes", m) % m)
	return " ".join(times)
Beispiel #15
0
def getFPVersion():
	version = None
	try:
		if getBrandOEM() == "blackbox" and isfile("/proc/stb/info/micomver"):
			version = fileReadLine("/proc/stb/info/micomver", source=MODULE_NAME)
		elif getBoxType() in ('dm7080', 'dm820', 'dm520', 'dm525', 'dm900', 'dm920'):
			version = open("/proc/stb/fp/version", "r").read()
		else:
			version = int(open("/proc/stb/fp/version", "r").read())
	except IOError:
		try:
			with open("/dev/dbox/fp0") as fd:
				version = ioctl(fd.fileno(), 0)
		except (IOError, OSError) as err:
			print("[StbHardware] Error %d: Unable to access '/dev/dbox/fp0', getFPVersion failed!  (%s)" % (err.errno, err.strerror))
	return version
Beispiel #16
0
def getChipSetString():
    if getMachineBuild() in ('dm7080', 'dm820'):
        return "7435"
    elif getMachineBuild() in ('dm520', 'dm525'):
        return "73625"
    elif getMachineBuild() in ('dm900', 'dm920', 'et13000', 'sf5008'):
        return "7252S"
    elif getMachineBuild() in ('hd51', 'vs1500', 'h7'):
        return "7251S"
    elif getMachineBuild() in ('alien5', ):
        return "S905D"
    else:
        chipset = fileReadLine("/proc/stb/info/chipset", source=MODULE_NAME)
        if chipset is None:
            return _("Undefined")
        return str(chipset.lower().replace('\n',
                                           '').replace('bcm', '').replace(
                                               'brcm', '').replace('sti', ''))
Beispiel #17
0
def InitLcd():
    if not BoxInfo.getItem("dboxlcd"):
        detected = False
    else:
        detected = eDBoxLCD.getInstance().detected()
    BoxInfo.setItem("Display", detected)
    config.lcd = ConfigSubsection()
    if exists("/proc/stb/lcd/mode"):
        can_lcdmodechecking = fileReadLine("/proc/stb/lcd/mode")
    else:
        can_lcdmodechecking = False
    BoxInfo.setItem("LCDMiniTV", can_lcdmodechecking)
    if detected:
        ilcd = LCD()
        if can_lcdmodechecking:

            def setLCDModeMinitTV(configElement):
                print("[Lcd] setLCDModeMinitTV='%s'." % configElement.value)
                fileWriteLine("/proc/stb/lcd/mode", configElement.value)

            def setMiniTVFPS(configElement):
                print("[Lcd] setMiniTVFPS='%s'." % configElement.value)
                fileWriteLine("/proc/stb/lcd/fps", configElement.value)

            def setLCDModePiP(configElement):
                pass  # DEBUG: Should this be doing something?

            def setLCDScreenshot(configElement):
                ilcd.setScreenShot(configElement.value)

            config.lcd.modepip = ConfigSelection(choices={
                "0": _("Off"),
                "5": _("PIP"),
                "7": _("PIP with OSD")
            },
                                                 default="0")
            config.lcd.modepip.addNotifier(setLCDModePiP)
            config.lcd.screenshot = ConfigYesNo(default=False)
            config.lcd.screenshot.addNotifier(setLCDScreenshot)
            config.lcd.modeminitv = ConfigSelection(choices={
                "0": _("Normal"),
                "1": _("MiniTV"),
                "2": _("OSD"),
                "3": _("MiniTV with OSD")
            },
                                                    default="0")
            config.lcd.fpsminitv = ConfigSlider(default=30, limits=(0, 30))
            config.lcd.modeminitv.addNotifier(setLCDModeMinitTV)
            config.lcd.fpsminitv.addNotifier(setMiniTVFPS)
        else:
            config.lcd.modeminitv = ConfigNothing()
            config.lcd.screenshot = ConfigNothing()
            config.lcd.fpsminitv = ConfigNothing()
        config.lcd.scroll_speed = ConfigSelection(choices=[("500", _("Slow")),
                                                           ("300",
                                                            _("Normal")),
                                                           ("100", _("Fast"))],
                                                  default="300")
        config.lcd.scroll_delay = ConfigSelection(choices=[
            ("10000", "10 %s" % _("seconds")), ("20000",
                                                "20 %s" % _("seconds")),
            ("30000", "30 %s" % _("seconds")), ("60000", "1 %s" % _("minute")),
            ("300000", "5 %s" % _("minutes")), ("noscrolling", _("Off"))
        ],
                                                  default="10000")

        def setLCDbright(configElement):
            ilcd.setBright(configElement.value)

        def setLCDstandbybright(configElement):
            ilcd.setStandbyBright(configElement.value)

        def setLCDdimbright(configElement):
            ilcd.setDimBright(configElement.value)

        def setLCDdimdelay(configElement):
            ilcd.setDimDelay(configElement.value)

        def setLCDcontrast(configElement):
            ilcd.setContrast(configElement.value)

        def setLCDinverted(configElement):
            ilcd.setInverted(configElement.value)

        def setLCDflipped(configElement):
            ilcd.setFlipped(configElement.value)

        def setLCDmode(configElement):
            ilcd.setMode(configElement.value)

        def setLCDpower(configElement):
            ilcd.setPower(configElement.value)

        def setfblcddisplay(configElement):
            ilcd.setfblcddisplay(configElement.value)

        def setLCDshowoutputresolution(configElement):
            ilcd.setShowoutputresolution(configElement.value)

        def setLCDminitvmode(configElement):
            ilcd.setLCDMiniTVMode(configElement.value)

        def setLCDminitvpipmode(configElement):
            ilcd.setLCDMiniTVPIPMode(configElement.value)

        def setLCDminitvfps(configElement):
            ilcd.setLCDMiniTVFPS(configElement.value)

        def setLEDnormalstate(configElement):
            ilcd.setLEDNormalState(configElement.value)

        def setLEDdeepstandby(configElement):
            ilcd.setLEDDeepStandbyState(configElement.value)

        def setLEDblinkingtime(configElement):
            ilcd.setLEDBlinkingTime(configElement.value)

        def setPowerLEDstate(configElement):
            if exists("/proc/stb/power/powerled"):
                fileWriteLine("/proc/stb/power/powerled", configElement.value)

        def setPowerLEDstate2(configElement):
            if exists("/proc/stb/power/powerled2"):
                fileWriteLine("/proc/stb/power/powerled2", configElement.value)

        def setPowerLEDstanbystate(configElement):
            if exists("/proc/stb/power/standbyled"):
                fileWriteLine("/proc/stb/power/standbyled",
                              configElement.value)

        def setPowerLEDdeepstanbystate(configElement):
            if exists("/proc/stb/power/suspendled"):
                fileWriteLine("/proc/stb/power/suspendled",
                              configElement.value)

        def setLedPowerColor(configElement):
            if exists("/proc/stb/fp/ledpowercolor"):
                fileWriteLine("/proc/stb/fp/ledpowercolor",
                              configElement.value)

        def setLedStandbyColor(configElement):
            if exists("/proc/stb/fp/ledstandbycolor"):
                fileWriteLine("/proc/stb/fp/ledstandbycolor",
                              configElement.value)

        def setLedSuspendColor(configElement):
            if exists("/proc/stb/fp/ledsuspendledcolor"):
                fileWriteLine("/proc/stb/fp/ledsuspendledcolor",
                              configElement.value)

        def setLedBlinkControlColor(configElement):
            if exists("/proc/stb/fp/led_blink"):
                fileWriteLine("/proc/stb/fp/led_blink", configElement.value)

        def setLedBrightnessControl(configElement):
            if exists("/proc/stb/fp/led_brightness"):
                fileWriteLine("/proc/stb/fp/led_brightness",
                              configElement.value)

        def setLedColorControlColor(configElement):
            if exists("/proc/stb/fp/led_color"):
                fileWriteLine("/proc/stb/fp/led_color", configElement.value)

        def setLedFadeControlColor(configElement):
            if exists("/proc/stb/fp/led_fade"):
                fileWriteLine("/proc/stb/fp/led_fade", configElement.value)

        def setPower4x7On(configElement):
            if exists("/proc/stb/fp/power4x7on"):
                fileWriteLine("/proc/stb/fp/power4x7on", configElement.value)

        def setPower4x7Standby(configElement):
            if exists("/proc/stb/fp/power4x7standby"):
                fileWriteLine("/proc/stb/fp/power4x7standby",
                              configElement.value)

        def setPower4x7Suspend(configElement):
            if exists("/proc/stb/fp/power4x7suspend"):
                fileWriteLine("/proc/stb/fp/power4x7suspend",
                              configElement.value)

        def setXcoreVFD(configElement):
            if exists("/sys/module/brcmstb_osmega/parameters/pt6302_cgram"):
                fileWriteLine(
                    "/sys/module/brcmstb_osmega/parameters/pt6302_cgram",
                    configElement.value)

        config.usage.vfd_xcorevfd = ConfigSelection(choices=[
            ("0", _("12 character")), ("1", _("8 character"))
        ],
                                                    default="0")
        config.usage.vfd_xcorevfd.addNotifier(setXcoreVFD)
        config.usage.lcd_powerled = ConfigSelection(choices=[("off", _("Off")),
                                                             ("on", _("On"))],
                                                    default="on")
        config.usage.lcd_powerled.addNotifier(setPowerLEDstate)
        config.usage.lcd_powerled2 = ConfigSelection(choices=[("off",
                                                               _("Off")),
                                                              ("on", _("On"))],
                                                     default="on")
        config.usage.lcd_powerled2.addNotifier(setPowerLEDstate2)
        config.usage.lcd_standbypowerled = ConfigSelection(choices=[
            ("off", _("Off")), ("on", _("On"))
        ],
                                                           default="on")
        config.usage.lcd_standbypowerled.addNotifier(setPowerLEDstanbystate)
        config.usage.lcd_deepstandbypowerled = ConfigSelection(choices=[
            ("off", _("Off")), ("on", _("On"))
        ],
                                                               default="on")
        config.usage.lcd_deepstandbypowerled.addNotifier(
            setPowerLEDdeepstanbystate)
        config.lcd.ledpowercolor = ConfigSelection(choices=[("0", _("Off")),
                                                            ("1", _("Blue")),
                                                            ("2", _("Red")),
                                                            ("3", _("Violet"))
                                                            ],
                                                   default="1")
        config.lcd.ledpowercolor.addNotifier(setLedPowerColor)
        config.lcd.ledstandbycolor = ConfigSelection(choices=[("0", _("Off")),
                                                              ("1", _("Blue")),
                                                              ("2", _("Red")),
                                                              ("3",
                                                               _("Violet"))],
                                                     default="3")
        config.lcd.ledstandbycolor.addNotifier(setLedStandbyColor)
        config.lcd.ledsuspendcolor = ConfigSelection(choices=[("0", _("Off")),
                                                              ("1", _("Blue")),
                                                              ("2", _("Red")),
                                                              ("3",
                                                               _("Violet"))],
                                                     default="2")
        config.lcd.ledsuspendcolor.addNotifier(setLedSuspendColor)
        colorsList = [
            ("0xff0000", _("Red")),
            ("0xff3333", _("Rose")),
            ("0xff5500", _("Orange")),
            ("0xdd9900", _("Yellow")),
            ("0x99dd00", _("Lime")),
            ("0x00ff00", _("Green")),
            ("0x00ff99", _("Aqua")),
            ("0x00bbff", _("Olympic blue")),
            ("0x0000ff", _("Blue")),
            ("0x6666ff", _("Azure")),
            ("0x9900ff", _("Purple")),
            ("0xff0066", _("Pink")),
            ("0xffffff", _("White")),
        ]
        config.lcd.ledblinkcontrolcolor = ConfigSelection(choices=colorsList,
                                                          default="0xffffff")
        config.lcd.ledblinkcontrolcolor.addNotifier(setLedBlinkControlColor)
        config.lcd.ledbrightnesscontrol = ConfigSlider(default=0xff,
                                                       increment=25,
                                                       limits=(0, 0xff))
        config.lcd.ledbrightnesscontrol.addNotifier(setLedBrightnessControl)
        config.lcd.ledcolorcontrolcolor = ConfigSelection(choices=colorsList,
                                                          default="0xffffff")
        config.lcd.ledcolorcontrolcolor.addNotifier(setLedColorControlColor)
        config.lcd.ledfadecontrolcolor = ConfigSelection(choices=colorsList,
                                                         default="0xffffff")
        config.lcd.ledfadecontrolcolor.addNotifier(setLedFadeControlColor)
        config.lcd.power4x7on = ConfigSelection(choices=[("off", _("Off")),
                                                         ("on", _("On"))],
                                                default="on")
        config.lcd.power4x7on.addNotifier(setPower4x7On)
        config.lcd.power4x7standby = ConfigSelection(choices=[("off",
                                                               _("Off")),
                                                              ("on", _("On"))],
                                                     default="on")
        config.lcd.power4x7standby.addNotifier(setPower4x7Standby)
        config.lcd.power4x7suspend = ConfigSelection(choices=[("off",
                                                               _("Off")),
                                                              ("on", _("On"))],
                                                     default="on")
        config.lcd.power4x7suspend.addNotifier(setPower4x7Suspend)
        if platform in ("dm4kgen", "8100s"):
            standby_default = 4
        elif model == "osmega":
            standby_default = 10
        else:
            standby_default = 1
        if not ilcd.isOled():
            config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
            config.lcd.contrast.addNotifier(setLCDcontrast)
        else:
            config.lcd.contrast = ConfigNothing()
        if model in ("h3", "ebox5000", "ebox5100", "sh1", "spycat",
                     "novacombo", "novatwin"):
            config.lcd.standby = ConfigSlider(default=standby_default,
                                              limits=(0, 4))
            config.lcd.dimbright = ConfigSlider(default=standby_default,
                                                limits=(0, 4))
            config.lcd.bright = ConfigSlider(default=4, limits=(0, 4))
        elif model == "osmega":
            config.lcd.standby = ConfigSlider(default=standby_default,
                                              limits=(0, 10))
            config.lcd.dimbright = ConfigSlider(default=standby_default,
                                                limits=(0, 10))
            config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
        else:
            config.lcd.standby = ConfigSlider(default=standby_default,
                                              limits=(0, 10))
            config.lcd.dimbright = ConfigSlider(default=standby_default,
                                                limits=(0, 10))
            config.lcd.bright = ConfigSlider(
                default=BoxInfo.getItem("DefaultDisplayBrightness"),
                limits=(0, 10))
        config.lcd.dimbright.addNotifier(setLCDdimbright)
        config.lcd.dimbright.apply = lambda: setLCDdimbright(config.lcd.
                                                             dimbright)
        config.lcd.dimdelay = ConfigSelection(choices=[
            ("5", "5 %s" % _("seconds")), ("10", "10 %s" % _("seconds")),
            ("15", "15 %s" % _("seconds")), ("20", "20 %s" % _("seconds")),
            ("30", "30 %s" % _("seconds")), ("60", "1 %s" % _("minute")),
            ("120", "2 %s" % _("minutes")), ("300", "5 %s" % _("minutes")),
            ("0", _("Off"))
        ],
                                              default="0")
        config.lcd.dimdelay.addNotifier(setLCDdimdelay)
        config.lcd.standby.addNotifier(setLCDstandbybright)
        config.lcd.standby.apply = lambda: setLCDstandbybright(config.lcd.
                                                               standby)
        config.lcd.bright.addNotifier(setLCDbright)
        config.lcd.bright.apply = lambda: setLCDbright(config.lcd.bright)
        config.lcd.bright.callNotifiersOnSaveAndCancel = True
        config.lcd.invert = ConfigYesNo(default=False)
        config.lcd.invert.addNotifier(setLCDinverted)

        def PiconPackChanged(configElement):
            configElement.save()

        config.lcd.picon_pack = ConfigYesNo(default=False)
        config.lcd.picon_pack.addNotifier(PiconPackChanged)
        config.lcd.flip = ConfigYesNo(default=False)
        config.lcd.flip.addNotifier(setLCDflipped)
        if BoxInfo.getItem("LcdLiveTV"):

            def lcdLiveTvChanged(configElement):
                if "live_enable" in BoxInfo.getItem("LcdLiveTV"):
                    fileWriteLine(
                        BoxInfo.getItem("LcdLiveTV"),
                        configElement.value and "enable" or "disable")
                else:
                    fileWriteLine(BoxInfo.getItem("LcdLiveTV"),
                                  configElement.value and "0" or "1")
                try:
                    InfoBarInstance = InfoBar.instance
                    InfoBarInstance and InfoBarInstance.session.open(
                        dummyScreen)
                except:
                    pass

            config.lcd.showTv = ConfigYesNo(default=False)
            config.lcd.showTv.addNotifier(lcdLiveTvChanged)

        if BoxInfo.getItem("LCDMiniTV") and platform not in ("gb7356",
                                                             "gb7252",
                                                             "gb72604"):
            config.lcd.minitvmode = ConfigSelection(choices=[
                ("0", _("Normal")), ("1", _("MiniTV")), ("2", _("OSD")),
                ("3", _("MiniTV with OSD"))
            ],
                                                    default="0")
            config.lcd.minitvmode.addNotifier(setLCDminitvmode)
            config.lcd.minitvpipmode = ConfigSelection(choices=[
                ("0", _("Off")), ("5", _("PIP")), ("7", _("PIP with OSD"))
            ],
                                                       default="0")
            config.lcd.minitvpipmode.addNotifier(setLCDminitvpipmode)
            config.lcd.minitvfps = ConfigSlider(default=30, limits=(0, 30))
            config.lcd.minitvfps.addNotifier(setLCDminitvfps)

        if BoxInfo.getItem("VFD_scroll_repeats") and BoxInfo.getItem(
                "VFDRepeats"):

            def scroll_repeats(configElement):
                fileWriteLine(BoxInfo.getItem("VFD_scroll_repeats"),
                              configElement.value)

            config.usage.vfd_scroll_repeats = ConfigSelection(choices=[
                ("0", _("None")), ("1", _("1X")), ("2", _("2X")),
                ("3", _("3X")), ("4", _("4X")), ("500", _("Continuous"))
            ],
                                                              default="3")
            config.usage.vfd_scroll_repeats.addNotifier(
                scroll_repeats, immediate_feedback=False)
        else:
            config.usage.vfd_scroll_repeats = ConfigNothing()
        if BoxInfo.getItem("VFD_scroll_delay") and BoxInfo.getItem(
                "VFDRepeats"):

            def scroll_delay(configElement):
                if BoxInfo.getItem("VFDDelay"):
                    fileWriteLine(BoxInfo.getItem("VFD_scroll_delay"),
                                  hex(int(configElement.value)))
                else:
                    fileWriteLine(BoxInfo.getItem("VFD_scroll_delay"),
                                  configElement.value)

            config.usage.vfd_scroll_delay = ConfigSlider(default=150,
                                                         increment=10,
                                                         limits=(0, 500))
            config.usage.vfd_scroll_delay.addNotifier(scroll_delay,
                                                      immediate_feedback=False)
            config.lcd.hdd = ConfigYesNo(default=True)
        else:
            config.lcd.hdd = ConfigNothing()
            config.usage.vfd_scroll_delay = ConfigNothing()
        if BoxInfo.getItem("VFD_initial_scroll_delay") and BoxInfo.getItem(
                "VFDRepeats"):

            def initial_scroll_delay(configElement):
                if BoxInfo.getItem("VFDDelay"):
                    fileWriteLine(BoxInfo.getItem("VFD_initial_scroll_delay"),
                                  hex(int(configElement.value)))
                else:
                    fileWriteLine(BoxInfo.getItem("VFD_initial_scroll_delay"),
                                  configElement.value)

            config.usage.vfd_initial_scroll_delay = ConfigSelection(
                choices=[("3000", "3 %s" % _("seconds")),
                         ("5000", "5 %s" % _("seconds")),
                         ("10000", "10 %s" % _("seconds")),
                         ("20000", "20 %s" % _("seconds")),
                         ("30000", "30 %s" % _("seconds")),
                         ("0", _("No delay"))],
                default="10000")
            config.usage.vfd_initial_scroll_delay.addNotifier(
                initial_scroll_delay, immediate_feedback=False)
        else:
            config.usage.vfd_initial_scroll_delay = ConfigNothing()
        if BoxInfo.getItem("VFD_final_scroll_delay") and BoxInfo.getItem(
                "VFDRepeats"):

            def final_scroll_delay(configElement):
                if BoxInfo.getItem("VFDDelay"):
                    fileWriteLine(BoxInfo.getItem("VFD_final_scroll_delay"),
                                  hex(int(configElement.value)))
                else:
                    fileWriteLine(BoxInfo.getItem("VFD_final_scroll_delay"),
                                  configElement.value)

            config.usage.vfd_final_scroll_delay = ConfigSelection(
                choices=[("3000", "3 %s" % _("seconds")),
                         ("5000", "5 %s" % _("seconds")),
                         ("10000", "10 %s" % _("seconds")),
                         ("20000", "20 %s" % _("seconds")),
                         ("30000", "30 %s" % _("seconds")),
                         ("0", _("No delay"))],
                default="10000")
            config.usage.vfd_final_scroll_delay.addNotifier(
                final_scroll_delay, immediate_feedback=False)
        else:
            config.usage.vfd_final_scroll_delay = ConfigNothing()
        if exists("/proc/stb/lcd/show_symbols"):
            config.lcd.mode = ConfigSelection(choices=[("0", _("No")),
                                                       ("1", _("Yes"))],
                                              default="1")
            config.lcd.mode.addNotifier(setLCDmode)
        else:
            config.lcd.mode = ConfigNothing()
        if exists("/proc/stb/power/vfd") or exists("/proc/stb/lcd/vfd"):
            config.lcd.power = ConfigSelection(choices=[("0", _("No")),
                                                        ("1", _("Yes"))],
                                               default="1")
            config.lcd.power.addNotifier(setLCDpower)
        else:
            config.lcd.power = ConfigNothing()
        if exists("/proc/stb/fb/sd_detach"):
            config.lcd.fblcddisplay = ConfigSelection(choices=[("1", _("No")),
                                                               ("0", _("Yes"))
                                                               ],
                                                      default="1")
            config.lcd.fblcddisplay.addNotifier(setfblcddisplay)
        else:
            config.lcd.fblcddisplay = ConfigNothing()
        if exists("/proc/stb/lcd/show_outputresolution"):
            config.lcd.showoutputresolution = ConfigSelection(choices=[
                ("0", _("No")), ("1", _("Yes"))
            ],
                                                              default="1")
            config.lcd.showoutputresolution.addNotifier(
                setLCDshowoutputresolution)
        else:
            config.lcd.showoutputresolution = ConfigNothing()
        if model == "vuultimo":
            config.lcd.ledblinkingtime = ConfigSlider(default=5,
                                                      increment=1,
                                                      limits=(0, 15))
            config.lcd.ledblinkingtime.addNotifier(setLEDblinkingtime)
            config.lcd.ledbrightnessdeepstandby = ConfigSlider(default=1,
                                                               increment=1,
                                                               limits=(0, 15))
            config.lcd.ledbrightnessdeepstandby.addNotifier(setLEDnormalstate)
            config.lcd.ledbrightnessdeepstandby.addNotifier(setLEDdeepstandby)
            config.lcd.ledbrightnessdeepstandby.apply = lambda: setLEDdeepstandby(
                config.lcd.ledbrightnessdeepstandby)
            config.lcd.ledbrightnessstandby = ConfigSlider(default=1,
                                                           increment=1,
                                                           limits=(0, 15))
            config.lcd.ledbrightnessstandby.addNotifier(setLEDnormalstate)
            config.lcd.ledbrightnessstandby.apply = lambda: setLEDnormalstate(
                config.lcd.ledbrightnessstandby)
            config.lcd.ledbrightness = ConfigSlider(default=3,
                                                    increment=1,
                                                    limits=(0, 15))
            config.lcd.ledbrightness.addNotifier(setLEDnormalstate)
            config.lcd.ledbrightness.apply = lambda: setLEDnormalstate(
                config.lcd.ledbrightness)
            config.lcd.ledbrightness.callNotifiersOnSaveAndCancel = True
        else:

            def doNothing():
                pass

            config.lcd.ledbrightness = ConfigNothing()
            config.lcd.ledbrightness.apply = lambda: doNothing()
            config.lcd.ledbrightnessstandby = ConfigNothing()
            config.lcd.ledbrightnessstandby.apply = lambda: doNothing()
            config.lcd.ledbrightnessdeepstandby = ConfigNothing()
            config.lcd.ledbrightnessdeepstandby.apply = lambda: doNothing()
            config.lcd.ledblinkingtime = ConfigNothing()
    else:

        def doNothing():
            pass

        config.lcd.contrast = ConfigNothing()
        config.lcd.bright = ConfigNothing()
        config.lcd.standby = ConfigNothing()
        config.lcd.bright.apply = lambda: doNothing()
        config.lcd.standby.apply = lambda: doNothing()
        config.lcd.power = ConfigNothing()
        config.lcd.fblcddisplay = ConfigNothing()
        config.lcd.mode = ConfigNothing()
        config.lcd.hdd = ConfigNothing()
        config.lcd.scroll_speed = ConfigSelection(choices=[("500", _("Slow")),
                                                           ("300",
                                                            _("Normal")),
                                                           ("100", _("Fast"))],
                                                  default="300")
        config.lcd.scroll_delay = ConfigSelection(choices=[
            ("10000", "10 %s" % _("seconds")), ("20000",
                                                "20 %s" % _("seconds")),
            ("30000", "30 %s" % _("seconds")), ("60000", "1 %s" % _("minute")),
            ("300000", "5 %s" % _("minutes")), ("noscrolling", _("Off"))
        ],
                                                  default="10000")
        config.lcd.showoutputresolution = ConfigNothing()
        config.lcd.ledbrightness = ConfigNothing()
        config.lcd.ledbrightness.apply = lambda: doNothing()
        config.lcd.ledbrightnessstandby = ConfigNothing()
        config.lcd.ledbrightnessstandby.apply = lambda: doNothing()
        config.lcd.ledbrightnessdeepstandby = ConfigNothing()
        config.lcd.ledbrightnessdeepstandby.apply = lambda: doNothing()
        config.lcd.ledblinkingtime = ConfigNothing()
        config.lcd.picon_pack = ConfigNothing()
    config.misc.standbyCounter.addNotifier(standbyCounterChanged,
                                           initial_call=False)
Beispiel #18
0
def getCPUInfoString():
    cpuCount = 0
    cpuSpeedStr = "-"
    cpuSpeedMhz = _getCPUSpeedMhz()
    processor = ""
    lines = fileReadLines("/proc/cpuinfo", source=MODULE_NAME)
    if lines:
        for line in lines:
            line = [x.strip() for x in line.strip().split(":", 1)]
            if not processor and line[0] in ("system type", "model name",
                                             "Processor"):
                processor = line[1].split()[0]
            elif not cpuSpeedMhz and line[0] == "cpu MHz":
                cpuSpeedMhz = float(line[1])
            elif line[0] == "processor":
                cpuCount += 1
        if processor.startswith("ARM") and isfile("/proc/stb/info/chipset"):
            processor = "%s (%s)" % (fileReadLine(
                "/proc/stb/info/chipset", "",
                source=MODULE_NAME).upper(), processor)
        if not cpuSpeedMhz:
            cpuSpeed = fileReadLine(
                "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq",
                source=MODULE_NAME)
            if cpuSpeed:
                cpuSpeedMhz = int(cpuSpeed) / 1000

        temperature = None
        if isfile("/proc/stb/fp/temp_sensor_avs"):
            temperature = fileReadLine("/proc/stb/fp/temp_sensor_avs",
                                       source=MODULE_NAME)
        elif isfile("/proc/stb/power/avs"):
            temperature = fileReadLine("/proc/stb/power/avs",
                                       source=MODULE_NAME)


#		elif isfile("/proc/stb/fp/temp_sensor"):
#			temperature = fileReadLine("/proc/stb/fp/temp_sensor", source=MODULE_NAME)
#		elif isfile("/proc/stb/sensors/temp0/value"):
#			temperature = fileReadLine("/proc/stb/sensors/temp0/value", source=MODULE_NAME)
#		elif isfile("/proc/stb/sensors/temp/value"):
#			temperature = fileReadLine("/proc/stb/sensors/temp/value", source=MODULE_NAME)
        elif isfile("/sys/devices/virtual/thermal/thermal_zone0/temp"):
            temperature = fileReadLine(
                "/sys/devices/virtual/thermal/thermal_zone0/temp",
                source=MODULE_NAME)
            if temperature:
                temperature = int(temperature) / 1000
        elif isfile("/sys/class/thermal/thermal_zone0/temp"):
            temperature = fileReadLine("/sys/class/thermal/thermal_zone0/temp",
                                       source=MODULE_NAME)
            if temperature:
                temperature = int(temperature) / 1000
        elif isfile("/proc/hisi/msp/pm_cpu"):
            lines = fileReadLines("/proc/hisi/msp/pm_cpu", source=MODULE_NAME)
            if lines:
                for line in lines:
                    if "temperature = " in line:
                        temperature = int(
                            line.split("temperature = ")[1].split()[0])

        if cpuSpeedMhz and cpuSpeedMhz >= 1000:
            cpuSpeedStr = _("%s GHz") % format_string("%.1f",
                                                      cpuSpeedMhz / 1000)
        else:
            cpuSpeedStr = _("%d MHz") % int(cpuSpeedMhz)

        if temperature:
            degree = u"\u00B0"
            if not isinstance(degree, str):
                degree = degree.encode("UTF-8", errors="ignore")
            if isinstance(temperature, float):
                temperature = format_string("%.1f", temperature)
            else:
                temperature = str(temperature)
            return (processor, cpuSpeedStr,
                    ngettext("%d core", "%d cores", cpuCount) % cpuCount,
                    "%s%s C" % (temperature, degree))
            #return ("%s %s MHz (%s) %s%sC") % (processor, cpuSpeed, ngettext("%d core", "%d cores", cpuCount) % cpuCount, temperature, degree)
        return (processor, cpuSpeedStr,
                ngettext("%d core", "%d cores", cpuCount) % cpuCount, "")
def getBoxRCType():
	return fileReadLine("/proc/stb/ir/rc/type", "unknown", source=MODULE_NAME).strip()
def getBoxProcType():
	return fileReadLine("/proc/stb/info/type", "unknown", source=MODULE_NAME).strip().lower()
Beispiel #21
0
def getBuildDateString():
    version = fileReadLine("/etc/version", source=MODULE_NAME)
    if version is None:
        return _("Unknown")
    return "%s-%s-%s" % (version[:4], version[4:6], version[6:8])
    def createInitializeJob(self):
        print("[Harddisk] Initializing storage device...")
        job = Task.Job(_("Initializing storage device..."))
        size = self.diskSize()
        print("[Harddisk] Disk size: %s MB." % size)
        task = UnmountTask(job, self)
        task = Task.PythonTask(job, _("Removing partition table."))
        task.work = self.killPartitionTable
        task.weighting = 1
        task = Task.LoggingTask(job, _("Rereading partition table."))
        task.weighting = 1
        task.setTool("hdparm")
        task.args.append("-z")
        task.args.append(self.disk_path)
        task = Task.ConditionTask(job,
                                  _("Waiting for partition."),
                                  timeoutCount=20)
        task.check = lambda: not exists(self.partitionPath("1"))
        task.weighting = 1
        if exists("/usr/sbin/parted"):
            use_parted = True
        else:
            if size > 2097151:
                addInstallTask(job, "parted")
                use_parted = True
            else:
                use_parted = False
        print("[Harddisk] Creating partition.")
        task = Task.LoggingTask(job, _("Creating partition."))
        task.weighting = 5
        if use_parted:
            task.setTool("parted")
            if size < 1024:
                alignment = "min"  # On very small devices, align to block only.
            else:
                alignment = "opt"  # Prefer optimal alignment for performance.
            if size > 2097151:
                parttype = "gpt"
            else:
                parttype = "msdos"
            task.args += [
                "-a", alignment, "-s", self.disk_path, "mklabel", parttype,
                "mkpart", "primary", "0%", "100%"
            ]
        else:
            task.setTool("sfdisk")
            task.args.append("-f")
            task.args.append("-uS")
            task.args.append(self.disk_path)
            if size > 128000:
                # Start at sector 8 to better support 4k aligned disks
                print("[Harddisk] Detected >128GB disk, using 4k alignment.")
                task.initial_input = "8,,L\n;0,0\n;0,0\n;0,0\ny\n"
            else:
                # Smaller disks (CF cards, sticks etc) don't need that
                task.initial_input = ",,L\n;\n;\n;\ny\n"
        task = Task.ConditionTask(job, _("Waiting for partition"))
        task.check = lambda: exists(self.partitionPath("1"))
        task.weighting = 1
        task = MkfsTask(job, _("Creating filesystem"))
        big_o_options = ["dir_index"]
        if isFileSystemSupported("ext4"):
            task.setTool("mkfs.ext4")
            if size > 20000:
                try:
                    version = map(
                        int,
                        fileReadLine("/proc/version").split(" ", 4)[2].split(
                            ".", 2)[:2])
                    if (version[0] > 3) or (version[0] > 2
                                            and version[1] >= 2):
                        # Linux version 3.2 supports bigalloc and -C option, use 256k blocks
                        task.args += ["-C", "262144"]
                        big_o_options.append("bigalloc")
                except Exception as err:
                    print(
                        "[Harddisk] Error: Failed to detect Linux version - '%s'!"
                        % str(err))
        else:
            task.setTool("mkfs.ext3")
        if size > 250000:
            # No more than 256k i-nodes (prevent problems with fsck memory requirements)
            task.args += ["-T", "largefile", "-N", "262144"]
            big_o_options.append("sparse_super")
        elif size > 16384:
            # between 16GB and 250GB: 1 i-node per megabyte
            task.args += ["-T", "largefile"]
            big_o_options.append("sparse_super")
        elif size > 2048:
            # Over 2GB: 32 i-nodes per megabyte
            task.args += ["-T", "largefile", "-N", str(size * 32)]
        task.args += [
            "-F", "-F", "-m0", "-O", ",".join(big_o_options),
            self.partitionPath("1")
        ]
        task = MountTask(job, self)
        task.weighting = 3
        task = Task.ConditionTask(job, _("Waiting for mount"), timeoutCount=20)
        task.check = self.mountDevice
        task.weighting = 1

        task = Task.PythonTask(job, _("Create directory") + ": movie")
        task.work = self.createMovieDir
        task.weighting = 1

        return job
 def readStats(self):
     line = fileReadLine(pathjoin("/sys/block", self.device, "stat"))
     if line is None:
         return -1, -1
     data = line.split(None, 5)
     return (int(data[0]), int(data[4]))
 def getBlockDevInfo(self, blockdev):
     devpath = "/sys/block/" + blockdev
     error = False
     removable = False
     BLACKLIST = []
     if BoxInfo.getItem("HasMMC"):
         BLACKLIST = ["%s" % (BoxInfo.getItem("mtdrootfs")[0:7])]
     if BoxInfo.getItem("HasMMC") and "root=/dev/mmcblk0p1" in fileReadLine(
             "/proc/cmdline", ""):
         BLACKLIST = ["mmcblk0p1"]
     blacklisted = False
     if blockdev[:7] in BLACKLIST:
         blacklisted = True
     if blockdev.startswith("mmcblk") and (search(r"mmcblk\dboot", blockdev)
                                           or search(
                                               r"mmcblk\drpmb", blockdev)):
         blacklisted = True
     is_cdrom = False
     is_mmc = False
     partitions = []
     try:
         if exists(devpath + "/removable"):
             removable = bool(
                 int(fileReadLine(pathjoin(devpath, "/removable"), "0")))
         if exists(devpath + "/dev"):
             dev = fileReadLine(pathjoin(devpath, "dev"))
             subdev = False if int(dev.split(":")[1]) % 32 == 0 else True
             dev = int(dev.split(":")[0])
         else:
             dev = None
             subdev = False
         # blacklist ram, loop, mtdblock, romblock, ramzswap
         blacklisted = dev in [1, 7, 31, 253, 254]
         # blacklist non-root eMMC devices
         if not blacklisted and dev == 179:
             is_mmc = True
             if (BoxInfo.getItem("BootDevice") and blockdev.startswith(
                     BoxInfo.getItem("BootDevice"))) or subdev:
                 blacklisted = True
         if blockdev[0:2] == "sr":
             is_cdrom = True
         if blockdev[0:2] == "hd":
             try:
                 if "cdrom" in fileReadLine(
                         pathjoin("/proc/ide", blockdev, "media"), ""):
                     is_cdrom = True
             except (IOError, OSError):
                 error = True
         # check for partitions
         if not is_cdrom and not is_mmc and exists(devpath):
             for partition in listdir(devpath):
                 if partition[0:len(blockdev)] != blockdev:
                     continue
                 if dev == 179 and not search(r"mmcblk\dp\d+", partition):
                     continue
                 partitions.append(partition)
         else:
             self.cd = blockdev
     except (IOError, OSError):
         error = True
     # check for medium
     medium_found = True
     try:
         if exists(pathjoin("/dev", blockdev)):
             open(pathjoin("/dev", blockdev)).close()
     except (IOError, OSError) as err:
         if err.errno == 159:  # no medium present
             medium_found = False
     return error, blacklisted, removable, is_cdrom, partitions, medium_found
Beispiel #25
0
        if item in self.immutableListor or item in self.procList:
            print(
                "[BoxInfo] Error: Item '%s' is immutable and can not be deleted!"
                % item)
        elif item in self.boxInfo:
            del self.boxInfo[item]
            return True
        return False


BoxInfo = BoxInformation()

from Tools.Multiboot import getMBbootdevice, getMultibootslots  # This import needs to be here to avoid a SystemInfo load loop!

# Parse the boot commandline.
cmdline = fileReadLine("/proc/cmdline", source=MODULE_NAME)
cmdline = {k: v.strip('"') for k, v in findall(r'(\S+)=(".*?"|\S+)', cmdline)}


def getNumVideoDecoders():
    numVideoDecoders = 0
    while fileExists("/dev/dvb/adapter0/video%d" % numVideoDecoders, "f"):
        numVideoDecoders += 1
    return numVideoDecoders


def countFrontpanelLEDs():
    numLeds = fileExists("/proc/stb/fp/led_set_pattern") and 1 or 0
    while fileExists("/proc/stb/fp/led%d_pattern" % numLeds):
        numLeds += 1
    return numLeds
Beispiel #26
0
def getKernelVersionString():
    version = fileReadLine("/proc/version", source=MODULE_NAME)
    if version is None:
        return _("Unknown")
    return version.split(" ", 4)[2].split("-", 2)[0]
Beispiel #27
0
def InitLcd():
    # FIXME remove getBoxType
    if getBoxType() in ('gbx34k', 'force4', 'alien5', 'viperslim', 'lunix',
                        'lunix4k', 'purehdse', 'vipert2c', 'evoslimse',
                        'evoslimt2c', 'valalinux', 'tmtwin4k', 'tmnanom3',
                        'mbmicrov2', 'revo4k', 'force3uhd', 'force2nano',
                        'evoslim', 'wetekplay', 'wetekplay2', 'wetekhub',
                        'ultrabox', 'novaip', 'dm520', 'dm525', 'purehd',
                        'mutant11', 'xpeedlxpro', 'zgemmai55', 'sf98',
                        'et7x00mini', 'xpeedlxcs2', 'xpeedlxcc', 'e4hd',
                        'e4hdhybrid', 'mbmicro', 'beyonwizt2', 'amikomini',
                        'dynaspark', 'amiko8900', 'sognorevolution',
                        'arguspingulux', 'arguspinguluxmini',
                        'arguspinguluxplus', 'sparkreloaded', 'sabsolo',
                        'sparklx', 'gis8120', 'gb800se', 'gb800solo',
                        'gb800seplus', 'gbultrase', 'gbipbox', 'tmsingle',
                        'tmnano2super', 'iqonios300hd', 'iqonios300hdv2',
                        'optimussos1plus', 'optimussos1', 'vusolo', 'et4x00',
                        'et5x00', 'et6x00', 'et7000', 'et7100', 'mixosf7',
                        'mixoslumi', 'gbx1', 'gbx2', 'gbx3', 'gbx3h'):
        detected = False
    elif getBoxType() in ('pulse4kmini', ):
        detected = True
    else:
        detected = eDBoxLCD.getInstance().detected()
    BoxInfo.setItem("Display", detected)
    config.lcd = ConfigSubsection()

    if exists("/proc/stb/lcd/mode"):
        can_lcdmodechecking = fileReadLine("/proc/stb/lcd/mode")
    else:
        can_lcdmodechecking = False
    BoxInfo.setItem("LCDMiniTV", can_lcdmodechecking)

    if detected:
        ilcd = LCD()
        if can_lcdmodechecking:

            def setLCDModeMinitTV(configElement):
                print("[Lcd] setLCDModeMinitTV='%s'." % configElement.value)
                fileWriteLine("/proc/stb/lcd/mode", configElement.value)

            def setMiniTVFPS(configElement):
                print("[Lcd] setMiniTVFPS='%s'." % configElement.value)
                fileWriteLine("/proc/stb/lcd/fps", configElement.value)

            def setLCDModePiP(configElement):
                pass  # DEBUG: Should this be doing something?

            def setLCDScreenshot(configElement):
                ilcd.setScreenShot(configElement.value)

            config.lcd.modepip = ConfigSelection(choices={
                "0": _("Off"),
                "5": _("PiP"),
                "7": _("PiP with OSD")
            },
                                                 default="0")
            config.lcd.modepip.addNotifier(setLCDModePiP)
            config.lcd.screenshot = ConfigYesNo(default=False)
            config.lcd.screenshot.addNotifier(setLCDScreenshot)
            config.lcd.modeminitv = ConfigSelection(choices={
                "0": _("normal"),
                "1": _("MiniTV"),
                "2": _("OSD"),
                "3": _("MiniTV with OSD")
            },
                                                    default="0")
            config.lcd.fpsminitv = ConfigSlider(default=30, limits=(0, 30))
            config.lcd.modeminitv.addNotifier(setLCDModeMinitTV)
            config.lcd.fpsminitv.addNotifier(setMiniTVFPS)
        else:
            config.lcd.modeminitv = ConfigNothing()
            config.lcd.screenshot = ConfigNothing()
            config.lcd.fpsminitv = ConfigNothing()
        config.lcd.scroll_speed = ConfigSelection(choices=[("500", _("slow")),
                                                           ("300",
                                                            _("normal")),
                                                           ("100", _("fast"))],
                                                  default="300")
        config.lcd.scroll_delay = ConfigSelection(choices=[
            ("10000", "10 %s" % _("seconds")), ("20000",
                                                "20 %s" % _("seconds")),
            ("30000", "30 %s" % _("seconds")), ("60000", "1 %s" % _("minute")),
            ("300000", "5 %s" % _("minutes")), ("noscrolling", _("Off"))
        ],
                                                  default="10000")

        def setLCDbright(configElement):
            ilcd.setBright(configElement.value)

        def setLCDstandbybright(configElement):
            ilcd.setStandbyBright(configElement.value)

        def setLCDdimbright(configElement):
            ilcd.setDimBright(configElement.value)

        def setLCDdimdelay(configElement):
            ilcd.setDimDelay(configElement.value)

        def setLCDcontrast(configElement):
            ilcd.setContrast(configElement.value)

        def setLCDinverted(configElement):
            ilcd.setInverted(configElement.value)

        def setLCDflipped(configElement):
            ilcd.setFlipped(configElement.value)

        def setLCDminitvmode(configElement):
            ilcd.setLCDMiniTVMode(configElement.value)

        def setLCDminitvpipmode(configElement):
            ilcd.setLCDMiniTVPIPMode(configElement.value)

        def setLCDminitvfps(configElement):
            ilcd.setLCDMiniTVFPS(configElement.value)

        def setLEDnormalstate(configElement):
            ilcd.setLEDNormalState(configElement.value)

        def setLEDdeepstandby(configElement):
            ilcd.setLEDDeepStandbyState(configElement.value)

        def setLEDblinkingtime(configElement):
            ilcd.setLEDBlinkingTime(configElement.value)

        def setPowerLEDstate(configElement):
            if exists("/proc/stb/power/powerled"):
                fileWriteLine("/proc/stb/power/powerled",
                              "on" if configElement.value else "off")

        def setPowerLEDstate2(configElement):
            if exists("/proc/stb/power/powerled2"):
                fileWriteLine("/proc/stb/power/powerled2",
                              "on" if configElement.value else "off")

        def setPowerLEDstanbystate(configElement):
            if exists("/proc/stb/power/standbyled"):
                fileWriteLine("/proc/stb/power/standbyled",
                              "on" if configElement.value else "off")

        def setPowerLEDdeepstanbystate(configElement):
            if exists("/proc/stb/power/suspendled"):
                fileWriteLine("/proc/stb/power/suspendled",
                              "on" if configElement.value else "off")

        def setLedPowerColor(configElement):
            if exists("/proc/stb/fp/ledpowercolor"):
                fileWriteLine("/proc/stb/fp/ledpowercolor",
                              configElement.value)

        def setLedStandbyColor(configElement):
            if exists("/proc/stb/fp/ledstandbycolor"):
                fileWriteLine("/proc/stb/fp/ledstandbycolor",
                              configElement.value)

        def setLedSuspendColor(configElement):
            if exists("/proc/stb/fp/ledsuspendledcolor"):
                fileWriteLine("/proc/stb/fp/ledsuspendledcolor",
                              configElement.value)

        def setLedBlinkControlColor(configElement):
            if exists("/proc/stb/fp/led_blink"):
                fileWriteLine("/proc/stb/fp/led_blink", configElement.value)

        def setLedBrightnessControl(configElement):
            if exists("/proc/stb/fp/led_brightness"):
                fileWriteLine("/proc/stb/fp/led_brightness",
                              configElement.value)

        def setLedColorControlColor(configElement):
            if exists("/proc/stb/fp/led_color"):
                fileWriteLine("/proc/stb/fp/led_color", configElement.value)

        def setLedFadeControlColor(configElement):
            if exists("/proc/stb/fp/led_fade"):
                fileWriteLine("/proc/stb/fp/led_fade", configElement.value)

        def setPower4x7On(configElement):
            if exists("/proc/stb/fp/power4x7on"):
                fileWriteLine("/proc/stb/fp/power4x7on",
                              "on" if configElement.value else "off")

        def setPower4x7Standby(configElement):
            if exists("/proc/stb/fp/power4x7standby"):
                fileWriteLine("/proc/stb/fp/power4x7standby",
                              "on" if configElement.value else "off")

        def setPower4x7Suspend(configElement):
            if exists("/proc/stb/fp/power4x7suspend"):
                fileWriteLine("/proc/stb/fp/power4x7suspend",
                              "on" if configElement.value else "off")

        def setXcoreVFD(configElement):
            if exists("/sys/module/brcmstb_osmega/parameters/pt6302_cgram"):
                fileWriteLine(
                    "/sys/module/brcmstb_osmega/parameters/pt6302_cgram",
                    configElement.value)
            if exists("/sys/module/brcmstb_spycat4k/parameters/pt6302_cgram"):
                fileWriteLine(
                    "/sys/module/brcmstb_spycat4k/parameters/pt6302_cgram",
                    configElement.value)
            if exists(
                    "/sys/module/brcmstb_spycat4kmini/parameters/pt6302_cgram"
            ):
                fileWriteLine(
                    "/sys/module/brcmstb_spycat4kmini/parameters/pt6302_cgram",
                    configElement.value)
            if exists(
                    "/sys/module/brcmstb_spycat4kcombo/parameters/pt6302_cgram"
            ):
                fileWriteLine(
                    "/sys/module/brcmstb_spycat4kcombo/parameters/pt6302_cgram",
                    configElement.value)

        config.usage.vfd_xcorevfd = ConfigSelection(choices=[
            ("0", _("12 character")), ("1", _("8 character"))
        ],
                                                    default="0")
        config.usage.vfd_xcorevfd.addNotifier(setXcoreVFD)
        config.usage.lcd_powerled = ConfigOnOff(default=True)
        config.usage.lcd_powerled.addNotifier(setPowerLEDstate)
        config.usage.lcd_powerled2 = ConfigOnOff(default=True)
        config.usage.lcd_powerled2.addNotifier(setPowerLEDstate2)
        config.usage.lcd_standbypowerled = ConfigOnOff(default=True)
        config.usage.lcd_standbypowerled.addNotifier(setPowerLEDstanbystate)
        config.usage.lcd_deepstandbypowerled = ConfigOnOff(default=True)
        config.usage.lcd_deepstandbypowerled.addNotifier(
            setPowerLEDdeepstanbystate)

        if getBoxType() in ('dual', ):
            config.usage.lcd_ledpowercolor = ConfigSelection(
                default="1", choices=[("0", _("off")), ("1", _("blue"))])
            config.usage.lcd_ledpowercolor.addNotifier(setLedPowerColor)

            config.usage.lcd_ledstandbycolor = ConfigSelection(
                default="1", choices=[("0", _("off")), ("1", _("blue"))])
            config.usage.lcd_ledstandbycolor.addNotifier(setLedStandbyColor)

            config.usage.lcd_ledsuspendcolor = ConfigSelection(
                default="1", choices=[("0", _("off")), ("1", _("blue"))])
            config.usage.lcd_ledsuspendcolor.addNotifier(setLedSuspendColor)
        else:
            config.usage.lcd_ledpowercolor = ConfigSelection(
                default="1",
                choices=[("0", _("Off")), ("1", _("blue")), ("2", _("red")),
                         ("3", _("violet"))])
            config.usage.lcd_ledpowercolor.addNotifier(setLedPowerColor)

            config.usage.lcd_ledstandbycolor = ConfigSelection(
                default="3",
                choices=[("0", _("Off")), ("1", _("blue")), ("2", _("red")),
                         ("3", _("violet"))])
            config.usage.lcd_ledstandbycolor.addNotifier(setLedStandbyColor)

            config.usage.lcd_ledsuspendcolor = ConfigSelection(
                default="2",
                choices=[("0", _("Off")), ("1", _("blue")), ("2", _("red")),
                         ("3", _("violet"))])
            config.usage.lcd_ledsuspendcolor.addNotifier(setLedSuspendColor)

        config.usage.lcd_power4x7on = ConfigOnOff(default=True)
        config.usage.lcd_power4x7on.addNotifier(setPower4x7On)

        config.usage.lcd_power4x7standby = ConfigOnOff(default=True)
        config.usage.lcd_power4x7standby.addNotifier(setPower4x7Standby)

        config.usage.lcd_power4x7suspend = ConfigOnOff(default=True)
        config.usage.lcd_power4x7suspend.addNotifier(setPower4x7Suspend)

        if model in ('dm900', 'dm920', 'e4hdultra', 'protek4k'):
            standby_default = 4
        elif model in ("spycat4kmini", "osmega"):
            standby_default = 10
        else:
            standby_default = 1
        if not ilcd.isOled():
            config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
            config.lcd.contrast.addNotifier(setLCDcontrast)
        else:
            config.lcd.contrast = ConfigNothing()

        if model in ('novatwin', 'novacombo', 'mixosf5', 'mixosf5mini',
                     'gi9196m', 'gi9196lite', 'zgemmas2s', 'zgemmash1',
                     'zgemmash2', 'zgemmass', 'zgemmahs', 'zgemmah2s',
                     'zgemmah2h', 'spycat'):
            config.lcd.standby = ConfigSlider(default=standby_default,
                                              limits=(0, 4))
            config.lcd.dimbright = ConfigSlider(default=standby_default,
                                                limits=(0, 4))
            config.lcd.bright = ConfigSlider(default=4, limits=(0, 4))
        elif model in ("spycat4kmini", "osmega"):
            config.lcd.standby = ConfigSlider(default=standby_default,
                                              limits=(0, 10))
            config.lcd.dimbright = ConfigSlider(default=standby_default,
                                                limits=(0, 10))
            config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
        else:
            config.lcd.standby = ConfigSlider(default=standby_default,
                                              limits=(0, 10))
            config.lcd.dimbright = ConfigSlider(default=standby_default,
                                                limits=(0, 10))
            config.lcd.bright = ConfigSlider(
                default=BoxInfo.getItem("DefaultDisplayBrightness"),
                limits=(0, 10))
        config.lcd.dimbright.addNotifier(setLCDdimbright)
        config.lcd.dimbright.apply = lambda: setLCDdimbright(config.lcd.
                                                             dimbright)
        config.lcd.dimdelay = ConfigSelection(choices=[
            ("5", "5 %s" % _("seconds")), ("10", "10 %s" % _("seconds")),
            ("15", "15 %s" % _("seconds")), ("20", "20 %s" % _("seconds")),
            ("30", "30 %s" % _("seconds")), ("60", "1 %s" % _("minute")),
            ("120", "2 %s" % _("minutes")), ("300", "5 %s" % _("minutes")),
            ("0", _("Off"))
        ],
                                              default="0")
        config.lcd.dimdelay.addNotifier(setLCDdimdelay)
        config.lcd.standby.addNotifier(setLCDstandbybright)
        config.lcd.standby.apply = lambda: setLCDstandbybright(config.lcd.
                                                               standby)
        config.lcd.bright.addNotifier(setLCDbright)
        config.lcd.bright.apply = lambda: setLCDbright(config.lcd.bright)
        config.lcd.bright.callNotifiersOnSaveAndCancel = True
        config.lcd.invert = ConfigYesNo(default=False)
        config.lcd.invert.addNotifier(setLCDinverted)

        config.lcd.flip = ConfigYesNo(default=False)
        config.lcd.flip.addNotifier(setLCDflipped)

        if BoxInfo.getItem("LcdLiveTV"):

            def lcdLiveTvChanged(configElement):
                open(BoxInfo.getItem("LcdLiveTV"),
                     "w").write(configElement.value and "0" or "1")
                try:
                    InfoBarInstance = InfoBar.instance
                    InfoBarInstance and InfoBarInstance.session.open(
                        dummyScreen)
                except:
                    pass

            config.lcd.showTv = ConfigYesNo(default=False)
            config.lcd.showTv.addNotifier(lcdLiveTvChanged)

        if BoxInfo.getItem("LCDMiniTV") and config.misc.boxtype.value not in (
                'gbquad', 'gbquadplus', 'gbquad4k', 'gbue4k'):
            config.lcd.minitvmode = ConfigSelection(
                [("0", _("normal")), ("1", _("MiniTV")), ("2", _("OSD")),
                 ("3", _("MiniTV with OSD"))], "0")
            config.lcd.minitvmode.addNotifier(setLCDminitvmode)
            config.lcd.minitvpipmode = ConfigSelection(
                [("0", _("Off")), ("5", _("PiP")),
                 ("7", _("PiP with OSD"))], "0")
            config.lcd.minitvpipmode.addNotifier(setLCDminitvpipmode)
            config.lcd.minitvfps = ConfigSlider(default=30, limits=(0, 30))
            config.lcd.minitvfps.addNotifier(setLCDminitvfps)

        if BoxInfo.getItem("VFD_scroll_repeats") and model not in (
                'ixussone',
                'ixusszero') and getDisplayType() not in ('7segment', ):

            def scroll_repeats(el):
                open(BoxInfo.getItem("VFD_scroll_repeats"),
                     "w").write(el.value)

            choicelist = [("0", _("None")), ("1", _("1x")), ("2", _("2x")),
                          ("3", _("3x")), ("4", _("4x")),
                          ("500", _("Continues"))]
            config.usage.vfd_scroll_repeats = ConfigSelection(
                default="3", choices=choicelist)
            config.usage.vfd_scroll_repeats.addNotifier(
                scroll_repeats, immediate_feedback=False)
        else:
            config.usage.vfd_scroll_repeats = ConfigNothing()

        if BoxInfo.getItem("VFD_scroll_delay") and model not in (
                'ixussone',
                'ixusszero') and getDisplayType() not in ('7segment', ):

            def scroll_delay(el):
                # add workaround for Boxes who need hex code
                if model in ('sf4008', 'beyonwizu4'):
                    open(BoxInfo.getItem("VFD_scroll_delay"),
                         "w").write(hex(int(el.value)))
                else:
                    open(BoxInfo.getItem("VFD_scroll_delay"),
                         "w").write(str(el.value))

            config.usage.vfd_scroll_delay = ConfigSlider(default=150,
                                                         increment=10,
                                                         limits=(0, 500))
            config.usage.vfd_scroll_delay.addNotifier(scroll_delay,
                                                      immediate_feedback=False)
            config.lcd.hdd = ConfigYesNo(default=True)
        else:
            config.lcd.hdd = ConfigNothing()
            config.usage.vfd_scroll_delay = ConfigNothing()

        if BoxInfo.getItem("VFD_initial_scroll_delay") and model not in (
                'ixussone',
                'ixusszero') and getDisplayType() not in ('7segment', ):

            def initial_scroll_delay(el):
                if model in ('sf4008', 'beyonwizu4'):
                    # add workaround for Boxes who need hex code
                    open(BoxInfo.getItem("VFD_initial_scroll_delay"),
                         "w").write(hex(int(el.value)))
                else:
                    open(BoxInfo.getItem("VFD_initial_scroll_delay"),
                         "w").write(el.value)

            config.usage.vfd_initial_scroll_delay = ConfigSelection(
                choices=[("3000", "3 %s" % _("seconds")),
                         ("5000", "5 %s" % _("seconds")),
                         ("10000", "10 %s" % _("seconds")),
                         ("20000", "20 %s" % _("seconds")),
                         ("30000", "30 %s" % _("seconds")),
                         ("0", _("No delay"))],
                default="10000")
            config.usage.vfd_initial_scroll_delay.addNotifier(
                initial_scroll_delay, immediate_feedback=False)
        else:
            config.usage.vfd_initial_scroll_delay = ConfigNothing()

        if BoxInfo.getItem("VFD_final_scroll_delay") and model not in (
                'ixussone',
                'ixusszero') and getDisplayType() not in ('7segment', ):

            def final_scroll_delay(el):
                if model in ('sf4008', 'beyonwizu4'):
                    # add workaround for Boxes who need hex code
                    open(BoxInfo.getItem("VFD_final_scroll_delay"),
                         "w").write(hex(int(el.value)))
                else:
                    open(BoxInfo.getItem("VFD_final_scroll_delay"),
                         "w").write(el.value)

            config.usage.vfd_final_scroll_delay = ConfigSelection(
                choices=[("3000", "3 %s" % _("seconds")),
                         ("5000", "5 %s" % _("seconds")),
                         ("10000", "10 %s" % _("seconds")),
                         ("20000", "20 %s" % _("seconds")),
                         ("30000", "30 %s" % _("seconds")),
                         ("0", _("No delay"))],
                default="10000")
            config.usage.vfd_final_scroll_delay.addNotifier(
                final_scroll_delay, immediate_feedback=False)
        else:
            config.usage.vfd_final_scroll_delay = ConfigNothing()
        if exists("/proc/stb/lcd/show_symbols"):

            def setLCDmode(configElement):
                ilcd.setMode("1" if configElement.value else "0")

            config.lcd.mode = ConfigYesNo(default=True)
            config.lcd.mode.addNotifier(setLCDmode)
        else:
            config.lcd.mode = ConfigNothing()
        if exists("/proc/stb/power/vfd") or exists("/proc/stb/lcd/vfd"):

            def setLCDpower(configElement):
                ilcd.setPower("1" if configElement.value else "0")

            config.lcd.power = ConfigYesNo(default=True)
            config.lcd.power.addNotifier(setLCDpower)
        else:
            config.lcd.power = ConfigNothing()
        if exists("/proc/stb/fb/sd_detach"):

            def setfblcddisplay(configElement):
                ilcd.setfblcddisplay("1" if configElement.value else "0")

            config.lcd.fblcddisplay = ConfigYesNo(default=True)
            config.lcd.fblcddisplay.addNotifier(setfblcddisplay)
        else:
            config.lcd.fblcddisplay = ConfigNothing()
        if exists("/proc/stb/lcd/show_outputresolution"):

            def setLCDshowoutputresolution(configElement):
                ilcd.setShowoutputresolution(
                    "1" if configElement.value else "0")

            config.lcd.showoutputresolution = ConfigYesNo(default=True)
            config.lcd.showoutputresolution.addNotifier(
                setLCDshowoutputresolution)
        else:
            config.lcd.showoutputresolution = ConfigNothing()
        if model == "vuultimo":
            config.lcd.ledblinkingtime = ConfigSlider(default=5,
                                                      increment=1,
                                                      limits=(0, 15))
            config.lcd.ledblinkingtime.addNotifier(setLEDblinkingtime)
            config.lcd.ledbrightnessdeepstandby = ConfigSlider(default=1,
                                                               increment=1,
                                                               limits=(0, 15))
            config.lcd.ledbrightnessdeepstandby.addNotifier(setLEDnormalstate)
            config.lcd.ledbrightnessdeepstandby.addNotifier(setLEDdeepstandby)
            config.lcd.ledbrightnessdeepstandby.apply = lambda: setLEDdeepstandby(
                config.lcd.ledbrightnessdeepstandby)
            config.lcd.ledbrightnessstandby = ConfigSlider(default=1,
                                                           increment=1,
                                                           limits=(0, 15))
            config.lcd.ledbrightnessstandby.addNotifier(setLEDnormalstate)
            config.lcd.ledbrightnessstandby.apply = lambda: setLEDnormalstate(
                config.lcd.ledbrightnessstandby)
            config.lcd.ledbrightness = ConfigSlider(default=3,
                                                    increment=1,
                                                    limits=(0, 15))
            config.lcd.ledbrightness.addNotifier(setLEDnormalstate)
            config.lcd.ledbrightness.apply = lambda: setLEDnormalstate(
                config.lcd.ledbrightness)
            config.lcd.ledbrightness.callNotifiersOnSaveAndCancel = True
        else:

            def doNothing():
                pass

            config.lcd.ledbrightness = ConfigNothing()
            config.lcd.ledbrightness.apply = lambda: doNothing()
            config.lcd.ledbrightnessstandby = ConfigNothing()
            config.lcd.ledbrightnessstandby.apply = lambda: doNothing()
            config.lcd.ledbrightnessdeepstandby = ConfigNothing()
            config.lcd.ledbrightnessdeepstandby.apply = lambda: doNothing()
            config.lcd.ledblinkingtime = ConfigNothing()
    else:

        def doNothing():
            pass

        config.lcd.contrast = ConfigNothing()
        config.lcd.bright = ConfigNothing()
        config.lcd.standby = ConfigNothing()
        config.lcd.bright.apply = lambda: doNothing()
        config.lcd.standby.apply = lambda: doNothing()
        config.lcd.power = ConfigNothing()
        config.lcd.fblcddisplay = ConfigNothing()
        config.lcd.mode = ConfigNothing()
        config.lcd.hdd = ConfigNothing()
        config.lcd.scroll_speed = ConfigSelection(choices=[("500", _("slow")),
                                                           ("300",
                                                            _("normal")),
                                                           ("100", _("fast"))],
                                                  default="300")
        config.lcd.scroll_delay = ConfigSelection(choices=[
            ("10000", "10 %s" % _("seconds")), ("20000",
                                                "20 %s" % _("seconds")),
            ("30000", "30 %s" % _("seconds")), ("60000", "1 %s" % _("minute")),
            ("300000", "5 %s" % _("minutes")), ("noscrolling", _("Off"))
        ],
                                                  default="10000")
        config.lcd.showoutputresolution = ConfigNothing()
        config.lcd.ledbrightness = ConfigNothing()
        config.lcd.ledbrightness.apply = lambda: doNothing()
        config.lcd.ledbrightnessstandby = ConfigNothing()
        config.lcd.ledbrightnessstandby.apply = lambda: doNothing()
        config.lcd.ledbrightnessdeepstandby = ConfigNothing()
        config.lcd.ledbrightnessdeepstandby.apply = lambda: doNothing()
        config.lcd.ledblinkingtime = ConfigNothing()

    config.misc.standbyCounter.addNotifier(standbyCounterChanged,
                                           initial_call=False)
profile("Keymap")
from Components.ActionMap import loadKeymap
loadKeymap(config.usage.keymap.value)

profile("Network")
from Components.Network import InitNetwork
InitNetwork()

profile("LCD")
import Components.Lcd
Components.Lcd.InitLcd()
Components.Lcd.IconCheck()

if platform == "dm4kgen" or model in ("dm7080", "dm820"):
	filename = "/proc/stb/hdmi-rx/0/hdmi_rx_monitor"
	check = fileReadLine(filename, "", source=MODULE_NAME)
	if check.startswith("on"):
		fileWriteLine(filename, "off", source=MODULE_NAME)
	filename = "/proc/stb/audio/hdmi_rx_monitor"
	check = fileReadLine(filename, "", source=MODULE_NAME)
	if check.startswith("on"):
		fileWriteLine(filename, "off", source=MODULE_NAME)

profile("RFMod")
from Components.RFmod import InitRFmod
InitRFmod()

profile("CommonInterface")
from Screens.Ci import CiHandler, InitCiConfig
InitCiConfig()
Beispiel #29
0
	def readRemoteControlType(self):
		return fileReadLine("/proc/stb/ir/rc/type", "0", source=MODULE_NAME)
Beispiel #30
0
from glob import glob
from tempfile import mkdtemp

from Components.Console import Console
from Components.SystemInfo import BoxInfo
from Tools.Directories import fileReadLine, fileReadLines

MODULE_NAME = __name__.split(".")[-1]

PREFIX = "MultiBoot_"
MOUNT = "/bin/mount"
UMOUNT = "/bin/umount"

startupDevice = None
bootSlots = {}
bootArgs = fileReadLine("/sys/firmware/devicetree/base/chosen/bootargs",
                        source=MODULE_NAME)


def getArgValue(line, arg):
    return line.replace("userdataroot",
                        "rootuserdata").rsplit("%s=" % arg,
                                               1)[1].split(" ", 1)[0]


def getSlotImageData(imageDir):
    imageData = {}
    path = pathjoin(imageDir, "usr/lib/enigma.info")
    if isfile(path):
        lines = fileReadLines(path, source=MODULE_NAME)
        if lines:
            modified = BoxInfo.checkChecksum(lines)