#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import print_function from Components.config import config, ConfigSelection, ConfigSubDict, ConfigYesNo from Components.SystemInfo import SystemInfo from Tools.CList import CList import os from enigma import getBoxType, getBoxBrand from Components.About import about from boxbranding import getHaveAVJACK, getHaveHDMI, getMachineBuild, getSoCFamily brand = getBoxBrand() socfamily = getSoCFamily().replace('bcm', '').replace('hisi', '') chipsetstring = about.getChipSetString() has_hdmi = getHaveHDMI() == "True" has_scart = SystemInfo["HasScart"] has_yuv = SystemInfo["HasYPbPr"] has_rca = SystemInfo["HasComposite"] has_avjack = getHaveAVJACK() == "True" # The "VideoHardware" is the interface to /proc/stb/video. # It generates hotplug events, and gives you the list of # available and preferred modes, as well as handling the currently # selected mode. No other strict checking is done. config.av.edid_override = ConfigYesNo(default=True) class VideoHardware: rates = {} # high-level, use selectable modes.
print("getHaveMiniTV%s<" %boxbranding.getHaveMiniTV()) print("getHaveHDMIinHD%s<" %boxbranding.getHaveHDMIinHD()) print("getHaveHDMIinFHD%s<" %boxbranding.getHaveHDMIinFHD()) print("getHaveWOL%s<" %boxbranding.getHaveWOL()) print("getHaveWWOL%s<" %boxbranding.getHaveWWOL()) print("getHaveTranscoding1%s<" %boxbranding.getHaveTranscoding1()) print("getHaveTranscoding2%s<" %boxbranding.getHaveTranscoding2()) print("getHaveCI%s<" %boxbranding.getHaveCI()) print("getOpenFIXVersion=%s<" %boxbranding.getOpenFIXVersion()) print("getOpenFIXRevision=%s<" %boxbranding.getOpenFIXRevision()) print("getDeveloperName=%s<" %boxbranding.getDeveloperName()) print("getBoxBrand=%s<" %boxbranding.getBoxBrand()) print("getMachineMtdBoot=%s<" %boxbranding.getMachineMtdBoot()) print("getForceMode=%s<" %boxbranding.getForceMode()) print("getImageFPU=%s<" %boxbranding.getImageFPU()) print("getHaveSmallFlash=%s<" %boxbranding.getHaveSmallFlash()) print("getHaveMiddleFlash=%s<" %boxbranding.getHaveMiddleFlash()) print("getHaveTranscoding=%s<" %boxbranding.getHaveTranscoding()) print("getHaveMultiTranscoding=%s<" %boxbranding.getHaveMultiTranscoding()) print("getHaveMultiLib=%s<" %boxbranding.getHaveMultiLib()) print("getHaveSVIDEO=%s<" %boxbranding.getHaveSVIDEO()) print("getBlindscanBin=%s<" %boxbranding.getBlindscanBin()) print("getSoCFamily=%s<" %boxbranding.getSoCFamily()) print("getHaveVFDSymbol=%s<" %boxbranding.getHaveVFDSymbol()) print("getKernelVersion=%s<" %boxbranding.getKernelVersion()) print("getRCType=%s<" %boxbranding.getRCType()) print("getRCName=%s<" %boxbranding.getRCName()) print("getRCIDNum=%s<" %boxbranding.getRCIDNum())
def getInfo(session=None, need_fullinfo=False): # TODO: get webif versione somewhere! info = {} global STATICBOXINFO if not (STATICBOXINFO is None or need_fullinfo): return STATICBOXINFO info['brand'] = getBoxBrand() info['model'] = getBoxType() info['platform'] = boxbranding.getMachineBuild() try: info['procmodel'] = getBoxProc() except: # noqa: E722 info['procmodel'] = boxbranding.getMachineProcModel() try: info['procmodeltype'] = getBoxProcType() except: # noqa: E722 info['procmodeltype'] = None try: info['lcd'] = getLcd() except: # noqa: E722 info['lcd'] = 0 try: info['grabpip'] = getGrabPip() except: # noqa: E722 info['grabpip'] = 0 cpu = about.getCPUInfoString() info['chipset'] = cpu info['cpubrand'] = about.getCPUBrand() info['socfamily'] = boxbranding.getSoCFamily() info['cpuarch'] = about.getCPUArch() if config.OpenWebif.about_benchmark.value is True: info['cpubenchmark'] = about.getCPUBenchmark() else: info['cpubenchmark'] = _("Disabled in configuration") info['flashtype'] = about.getFlashType() memFree = 0 for line in open("/proc/meminfo", 'r'): parts = line.split(':') key = parts[0].strip() if key == "MemTotal": info['mem1'] = parts[1].strip().replace("kB", _("kB")) elif key in ("MemFree", "Buffers", "Cached"): memFree += int(parts[1].strip().split(' ', 1)[0]) info['mem2'] = "%s %s" % (memFree, _("kB")) info['mem3'] = _("%s free / %s total") % (info['mem2'], info['mem1']) info['uptime'] = about.getBoxUptime() info["webifver"] = OPENWEBIFVER info['imagedistro'] = boxbranding.getImageDistro() info['oever'] = boxbranding.getImageBuild() info['visionversion'] = boxbranding.getVisionVersion() info['visionrevision'] = boxbranding.getVisionRevision() info['visionmodule'] = about.getVisionModule() if fileExists("/etc/openvision/multiboot"): multibootflag = open("/etc/openvision/multiboot", "r").read().strip() if multibootflag == "1": info['multiboot'] = _("Yes") else: info['multiboot'] = _("No") else: info['multiboot'] = _("Yes") info['enigmaver'] = getEnigmaVersionString() info['driverdate'] = about.getDriverInstalledDate() info['kernelver'] = boxbranding.getKernelVersion() info['dvbapitype'] = about.getDVBAPI() info['gstreamerversion'] = about.getGStreamerVersionString(cpu) info['ffmpegversion'] = about.getFFmpegVersionString() info['pythonversion'] = about.getPythonVersionString() try: info['hwserial'] = getHWSerial() except: # noqa: E722 info['hwserial'] = None if (info['hwserial'] is None or info['hwserial'] == "unknown"): info['hwserial'] = about.getCPUSerial() try: info['boxrctype'] = getBoxRCType() except: # noqa: E722 info['boxrctype'] = None if (info['boxrctype'] is None or info['boxrctype'] == "unknown"): if fileExists("/usr/bin/remotecfg"): info['boxrctype'] = _("Amlogic remote") elif fileExists("/usr/sbin/lircd"): info['boxrctype'] = _("LIRC remote") info['ovrctype'] = boxbranding.getRCType() info['ovrcname'] = boxbranding.getRCName() info['ovrcidnum'] = boxbranding.getRCIDNum() info['transcoding'] = boxbranding.getHaveTranscoding() info['multitranscoding'] = boxbranding.getHaveMultiTranscoding() info['displaytype'] = boxbranding.getDisplayType() info['updatedatestring'] = about.getUpdateDateString() info['enigmadebuglvl'] = eGetEnigmaDebugLvl() info['imagearch'] = boxbranding.getImageArch() info['imagefolder'] = boxbranding.getImageFolder() info['imagefilesystem'] = boxbranding.getImageFileSystem() info['feedsurl'] = boxbranding.getFeedsUrl() info['developername'] = boxbranding.getDeveloperName() info['builddatestring'] = about.getBuildDateString() info['imagefpu'] = boxbranding.getImageFPU() info['havemultilib'] = boxbranding.getHaveMultiLib() try: info['fp_version'] = getFPVersion() except: # noqa: E722 info['fp_version'] = None info['tuners'] = [] for i in list(range(0, nimmanager.getSlotCount())): print( "[OpenWebif] -D- tuner '%d' '%s' '%s'" % (i, nimmanager.getNimName(i), nimmanager.getNim(i).getSlotName())) info['tuners'].append({ "name": nimmanager.getNim(i).getSlotName(), "type": nimmanager.getNimName(i) + " (" + nimmanager.getNim(i).getFriendlyType() + ")", "rec": "", "live": "" }) info['ifaces'] = [] ifaces = iNetwork.getConfiguredAdapters() for iface in ifaces: info['ifaces'].append({ "name": iNetwork.getAdapterName(iface), "friendlynic": getFriendlyNICChipSet(iface), "linkspeed": getLinkSpeed(iface), "mac": iNetwork.getAdapterAttribute(iface, "mac"), "dhcp": iNetwork.getAdapterAttribute(iface, "dhcp"), "ipv4method": getIPv4Method(iface), "ip": formatIp(iNetwork.getAdapterAttribute(iface, "ip")), "mask": formatIp(iNetwork.getAdapterAttribute(iface, "netmask")), "v4prefix": sum([ bin(int(x)).count('1') for x in formatIp( iNetwork.getAdapterAttribute(iface, "netmask")).split('.') ]), "gw": formatIp(iNetwork.getAdapterAttribute(iface, "gateway")), "ipv6": getAdapterIPv6(iface)['addr'], "ipmethod": getIPMethod(iface), "firstpublic": getAdapterIPv6(iface)['firstpublic'] }) info['hdd'] = [] for hdd in harddiskmanager.hdd: dev = hdd.findMount() if dev: stat = os.statvfs(dev) free = stat.f_bavail * stat.f_frsize / 1048576. else: free = -1 if free <= 1024: free = "%i %s" % (free, _("MB")) else: free = free / 1024. free = "%.1f %s" % (free, _("GB")) size = hdd.diskSize() * 1000000 / 1048576. if size > 1048576: size = "%.1f %s" % ((size / 1048576.), _("TB")) elif size > 1024: size = "%.1f %s" % ((size / 1024.), _("GB")) else: size = "%d %s" % (size, _("MB")) iecsize = hdd.diskSize() # Harddisks > 1000 decimal Gigabytes are labelled in TB if iecsize > 1000000: iecsize = (iecsize + 50000) // float(100000) / 10 # Omit decimal fraction if it is 0 if (iecsize % 1 > 0): iecsize = "%.1f %s" % (iecsize, _("TB")) else: iecsize = "%d %s" % (iecsize, _("TB")) # Round harddisk sizes beyond ~300GB to full tens: 320, 500, 640, 750GB elif iecsize > 300000: iecsize = "%d %s" % (((iecsize + 5000) // 10000 * 10), _("GB")) # ... be more precise for media < ~300GB (Sticks, SSDs, CF, MMC, ...): 1, 2, 4, 8, 16 ... 256GB elif iecsize > 1000: iecsize = "%d %s" % (((iecsize + 500) // 1000), _("GB")) else: iecsize = "%d %s" % (iecsize, _("MB")) info['hdd'].append({ "model": hdd.model(), "capacity": size, "labelled_capacity": iecsize, "free": free, "mount": dev, "friendlycapacity": _("%s free / %s total") % (free, size + ' ("' + iecsize + '")') }) info['shares'] = [] autofiles = ('/etc/auto.network', '/etc/auto.network_vti') for autofs in autofiles: if fileExists(autofs): method = "autofs" for line in open(autofs).readlines(): if not line.startswith('#'): # Replace escaped spaces that can appear inside credentials with underscores # Not elegant but we wouldn't want to expose credentials on the OWIF anyways tmpline = line.replace("\ ", "_") tmp = tmpline.split() if not len(tmp) == 3: continue name = tmp[0].strip() type = "unknown" if "cifs" in tmp[1]: # Linux still defaults to SMBv1 type = "SMBv1.0" settings = tmp[1].split(",") for setting in settings: if setting.startswith("vers="): type = setting.replace("vers=", "SMBv") elif "nfs" in tmp[1]: type = "NFS" # Default is r/w mode = _("r/w") settings = tmp[1].split(",") for setting in settings: if setting == "ro": mode = _("r/o") uri = tmp[2] parts = [] parts = tmp[2].split(':') if parts[0] == "": server = uri.split('/')[2] uri = uri.strip()[1:] else: server = parts[0] ipaddress = None if server: # Will fail on literal IPs try: # Try IPv6 first, as will Linux if has_ipv6: tmpaddress = None tmpaddress = getaddrinfo(server, 0, AF_INET6) if tmpaddress: ipaddress = "[" + list( tmpaddress)[0][4][0] + "]" # Use IPv4 if IPv6 fails or is not present if ipaddress is None: tmpaddress = None tmpaddress = getaddrinfo(server, 0, AF_INET) if tmpaddress: ipaddress = list(tmpaddress)[0][4][0] except: # noqa: E722 pass friendlyaddress = server if ipaddress is not None and not ipaddress == server: friendlyaddress = server + " (" + ipaddress + ")" info['shares'].append({ "name": name, "method": method, "type": type, "mode": mode, "path": uri, "host": server, "ipaddress": ipaddress, "friendlyaddress": friendlyaddress }) # TODO: fstab info['EX'] = '' if session: try: # gets all current stream clients for images using eStreamServer # TODO: merge eStreamServer and streamList # TODO: get tuner info for streams # TODO: get recoding/timer info if more than one info['streams'] = [] try: from enigma import eStreamServer streamServer = eStreamServer.getInstance() if streamServer is not None: for x in streamServer.getConnectedClients(): servicename = ServiceReference( x[1]).getServiceName() or "(unknown service)" if int(x[2]) == 0: strtype = "S" else: strtype = "T" info['streams'].append({ "ref": x[1], "name": servicename, "ip": x[0], "type": strtype }) except Exception as error: print("[OpenWebif] -D- no eStreamServer %s" % error) recs = NavigationInstance.instance.getRecordings() if recs: # only one stream and only TV from Plugins.Extensions.OpenWebif.controllers.stream import streamList s_name = '' # s_cip = '' print("[OpenWebif] -D- streamList count '%d'" % len(streamList)) if len(streamList) == 1: from Screens.ChannelSelection import service_types_tv # from enigma import eEPGCache # epgcache = eEPGCache.getInstance() serviceHandler = eServiceCenter.getInstance() services = serviceHandler.list( eServiceReference('%s ORDER BY name' % (service_types_tv))) channels = services and services.getContent("SN", True) s = streamList[0] srefs = s.ref.toString() for channel in channels: if srefs == channel[0]: s_name = channel[1] + ' (' + s.clientIP + ')' break print("[OpenWebif] -D- s_name '%s'" % s_name) # only for debug for stream in streamList: srefs = stream.ref.toString() print("[OpenWebif] -D- srefs '%s'" % srefs) sname = '' timers = [] for timer in NavigationInstance.instance.RecordTimer.timer_list: if timer.isRunning() and not timer.justplay: timers.append( removeBad(timer.service_ref.getServiceName())) print("[OpenWebif] -D- timer '%s'" % timer.service_ref.getServiceName()) # TODO: more than one recording if len(timers) == 1: sname = timers[0] if sname == '' and s_name != '': sname = s_name print("[OpenWebif] -D- recs count '%d'" % len(recs)) for rec in recs: feinfo = rec.frontendInfo() frontendData = feinfo and feinfo.getAll(True) if frontendData is not None: cur_info = feinfo.getTransponderData(True) if cur_info: nr = frontendData['tuner_number'] info['tuners'][nr]['rec'] = getOrbitalText( cur_info) + ' / ' + sname service = session.nav.getCurrentService() if service is not None: sname = service.info().getName() feinfo = service.frontendInfo() frontendData = feinfo and feinfo.getAll(True) if frontendData is not None: cur_info = feinfo.getTransponderData(True) if cur_info: nr = frontendData['tuner_number'] info['tuners'][nr]['live'] = getOrbitalText( cur_info) + ' / ' + sname except Exception as error: info['EX'] = error info['timerpipzap'] = False info['timerautoadjust'] = False try: timer = RecordTimerEntry('', 0, 0, '', '', 0) if hasattr(timer, "pipzap"): info['timerpipzap'] = True if hasattr(timer, "autoadjust"): info['timerautoadjust'] = True except Exception as error: print("[OpenWebif] -D- RecordTimerEntry check %s" % error) STATICBOXINFO = info return info
import sys import os import time import re from enigma import getBoxType, getBoxBrand from Components.SystemInfo import SystemInfo import socket import fcntl import struct from Components.Console import Console from Tools.Directories import fileExists from boxbranding import getSoCFamily from subprocess import PIPE, Popen socfamily = getSoCFamily() def _ifinfo(sock, addr, ifname): iface = struct.pack('256s', ifname[:15]) info = fcntl.ioctl(sock.fileno(), addr, iface) if addr == 0x8927: return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1].upper() else: return socket.inet_ntoa(info[20:24]) def getIfConfig(ifname): ifreq = {'ifname': ifname} infos = {} sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def __init__(self, session): Screen.__init__(self, session) self.setTitle(_("About")) hddsplit = skin.parameters.get("AboutHddSplit", 0) model = getBoxType() procmodel = getBoxProc() stbplatform = boxbranding.getMachineBuild() AboutText = _("Hardware: ") + model + "\n" if stbplatform != model: AboutText += _("Platform: ") + stbplatform + "\n" if procmodel != model: AboutText += _("Proc model: ") + procmodel + "\n" procmodeltype = getBoxProcType() if procmodeltype is not None and procmodeltype != "unknown": AboutText += _("Hardware type: ") + procmodeltype + "\n" hwserial = getHWSerial() if hwserial is not None and hwserial != "unknown": AboutText += _("Hardware serial: ") + hwserial + "\n" if hwserial is not None and hwserial == "unknown": AboutText += _("Hardware serial: ") + about.getCPUSerial() + "\n" AboutText += _("Brand/Meta: ") + getBoxBrand() + "\n" AboutText += "\n" cpu = about.getCPUInfoString() AboutText += _("CPU: ") + cpu + "\n" AboutText += _("CPU brand: ") + about.getCPUBrand() + "\n" socfamily = boxbranding.getSoCFamily() if socfamily is not None: AboutText += _("SoC family: ") + socfamily + "\n" AboutText += _("CPU architecture: ") + about.getCPUArch() + "\n" if not boxbranding.getDisplayType().startswith(' '): AboutText += "\n" AboutText += _("Display type: ") + boxbranding.getDisplayType() + "\n" # [WanWizard] Removed until we find a reliable way to determine the installation date # AboutText += _("Installed: ") + about.getFlashDateString() + "\n" EnigmaVersion = about.getEnigmaVersionString() EnigmaVersion = EnigmaVersion.rsplit("-", EnigmaVersion.count("-") - 2) if len(EnigmaVersion) == 3: EnigmaVersion = EnigmaVersion[0] + " (" + EnigmaVersion[2] + "-" + EnigmaVersion[1] + ")" else: EnigmaVersion = EnigmaVersion[0] + " (" + EnigmaVersion[1] + ")" EnigmaVersion = _("Enigma2 version: ") + EnigmaVersion self["EnigmaVersion"] = StaticText(EnigmaVersion) AboutText += "\n" + EnigmaVersion + "\n" AboutText += _("Last update: ") + about.getUpdateDateString() + "\n" AboutText += _("Enigma2 (re)starts: %d\n") % config.misc.startCounter.value AboutText += _("Enigma2 debug level: %d\n") % eGetEnigmaDebugLvl() if fileExists("/etc/openvision/mediaservice"): mediaservice = open("/etc/openvision/mediaservice", "r").read().strip() AboutText += _("Media service: ") + mediaservice.replace("enigma2-plugin-systemplugins-","") + "\n" AboutText += "\n" AboutText += _("Drivers version: ") + about.getDriverInstalledDate() + "\n" AboutText += _("Kernel version: ") + boxbranding.getKernelVersion() + "\n" GStreamerVersion = _("GStreamer version: ") + about.getGStreamerVersionString(cpu).replace("GStreamer","") self["GStreamerVersion"] = StaticText(GStreamerVersion) AboutText += "\n" + GStreamerVersion + "\n" FFmpegVersion = _("FFmpeg version: ") + about.getFFmpegVersionString() self["FFmpegVersion"] = StaticText(FFmpegVersion) AboutText += FFmpegVersion + "\n" AboutText += "\n" AboutText += _("Python version: ") + about.getPythonVersionString() + "\n" AboutText += "\n" fp_version = getFPVersion() if fp_version is None: fp_version = "" else: fp_version = _("Frontprocessor version: %s") % fp_version AboutText += fp_version + "\n" self["FPVersion"] = StaticText(fp_version) AboutText += _('Skin & Resolution: %s (%sx%s)\n') % (config.skin.primary_skin.value.split('/')[0], getDesktop(0).size().width(), getDesktop(0).size().height()) self["TunerHeader"] = StaticText(_("Detected NIMs:")) AboutText += "\n" AboutText += _("Detected NIMs:") + "\n" nims = nimmanager.nimListCompressed() for count in range(len(nims)): if count < 4: self["Tuner" + str(count)] = StaticText(nims[count]) else: self["Tuner" + str(count)] = StaticText("") AboutText += nims[count] + "\n" self["HDDHeader"] = StaticText(_("Detected HDD:")) AboutText += "\n" AboutText += _("Detected HDD:") + "\n" hddlist = harddiskmanager.HDDList() hddinfo = "" if hddlist: formatstring = hddsplit and "%s:%s, %.1f %sB %s" or "%s\n(%s, %.1f %sB %s)" for count in range(len(hddlist)): if hddinfo: hddinfo += "\n" hdd = hddlist[count][1] if int(hdd.free()) > 1024: hddinfo += formatstring % (hdd.model(), hdd.capacity(), hdd.Totalfree()/1024.0, "G", _("free")) else: hddinfo += formatstring % (hdd.model(), hdd.capacity(), hdd.Totalfree(), "M", _("free")) else: hddinfo = _("none") self["hddA"] = StaticText(hddinfo) AboutText += hddinfo + "\n\n" + _("Network Info:") for x in about.GetIPsFromNetworkInterfaces(): AboutText += "\n" + x[0] + ": " + x[1] AboutText += '\n\n' + _("Uptime") + ": " + about.getBoxUptime() self["AboutScrollLabel"] = ScrollLabel(AboutText) self["key_green"] = Button(_("Translations")) self["key_red"] = Button(_("Latest Commits")) self["key_yellow"] = Button(_("Troubleshoot")) self["key_blue"] = Button(_("Memory Info")) self["actions"] = ActionMap(["ColorActions", "SetupActions", "DirectionActions"], { "cancel": self.close, "ok": self.close, "red": self.showCommits, "green": self.showTranslationInfo, "blue": self.showMemoryInfo, "yellow": self.showTroubleshoot, "up": self["AboutScrollLabel"].pageUp, "down": self["AboutScrollLabel"].pageDown })