def __init__(self, session, infobar_mode=False): if FULLHD: if config.plugins.bitrate.style_skin.value == "compact": self.skin = self.skin_compact_fullhd else: self.skin = self.skin_info_fullhd else: if config.plugins.bitrate.style_skin.value == "compact": self.skin = self.skin_compact else: self.skin = self.skin_info Screen.__init__(self, session) self.infobar_mode = infobar_mode self.style_skin = config.plugins.bitrate.style_skin.value self.startDelayTimer = eTimer() self.startDelayTimer.callback.append(self.bitrateAfrterDelayStart) if config.plugins.bitrate.style_skin.value == "compact": self["video_caption"] = StaticText(_("Video:")) self["audio_caption"] = StaticText(_("Audio:")) self["video"] = StaticText() self["audio"] = StaticText() else: self.setTitle(_("Bitrate viewer")) self["vmin"] = Label("") self["vmax"] = Label("") self["vavg"] = Label("") self["vcur"] = Label("") self["amin"] = Label("") self["amax"] = Label("") self["aavg"] = Label("") self["acur"] = Label("") if not infobar_mode: self["actions"] = ActionMap( ["WizardActions"], { "back": self.keyCancel, "ok": self.keyCancel, "right": self.keyCancel, "left": self.keyCancel, "down": self.keyCancel, "up": self.keyCancel, }, -1) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self.onLayoutFinish.append(self.__layoutFinished)
def __init__(self, session, oids={}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, }) bisectoidstore.BisectOIDStore.__init__(self, OIDs=oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None
def __init__(self, session): self.skin = BitrateViewer.skin Screen.__init__(self, session) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self["cancel"] = Button(_("Exit")) self["vmin"] = Label("") self["vmax"] = Label("") self["vavg"] = Label("") self["vcur"] = Label("") self["amin"] = Label("") self["amax"] = Label("") self["aavg"] = Label("") self["acur"] = Label("") self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], { "ok": self.keyCancel, "cancel": self.keyCancel, "red": self.keyCancel, }, -2) self.onLayoutFinish.append( self.bitrate.start) # dont start before gui is finished
def __init__(self, session): self.skin = BitrateViewer.skin Screen.__init__(self, session) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self["cancel"] = Button(_("Exit")) self["vmin"] = Label("") self["vmax"] = Label("") self["vavg"] = Label("") self["vcur"] = Label("") self["amin"] = Label("") self["amax"] = Label("") self["aavg"] = Label("") self["acur"] = Label("") self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], {"ok": self.keyCancel, "cancel": self.keyCancel, "red": self.keyCancel}, -2, ) self.onLayoutFinish.append(self.bitrate.start) # dont start before gui is finished
def __init__(self, session, oids = {}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, }) bisectoidstore.BisectOIDStore.__init__(self, OIDs = oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None
def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get( ): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get( ): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[ 0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None
def __init__(self, session, oids={}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.SNRDB_OID: self.getValue, self.LOCK_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.TUNERTYPE_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, self.CPU_USER: self.getValue, self.CPU_NICE: self.getValue, self.CPU_SYSTEM: self.getValue, self.CPU_IDLE: self.getValue, self.CPU_WAIT: self.getValue, self.LOAD_AVR1: self.getValue, self.LOAD_AVR5: self.getValue, self.LOAD_AVR15: self.getValue, self.MEM_TOTAL: self.getValue, self.MEM_TOTAL2: self.getValue, self.MEM_USED: self.getValue, self.MEM_FREE: self.getValue, self.MEM_BUFFER: self.getValue, self.MEM_CACHED: self.getValue, self.MEM_SWAPTOTAL: self.getValue, self.MEM_SWAPFREE: self.getValue, self.IF_NUMBER: self.getValue, }) # Add disk info's totaldisks = GetDiskInfo(DiskInfoTypes.totalmounts, 0) for i in range(totaldisks): key = '%s.%d' % (self.DISK_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_PATHNAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_DEVICENAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_AVAIL, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_USED, (i + 1)) oids[key] = self.getValue # Add network info's totalnetworks = GetNetworkInfo(NetworkInfoTypes.total, 0) for i in range(totalnetworks): key = '%s.%d' % (self.IF_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_DESC, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_TYPE, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_MTU, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_SPEED, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HWADDR, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_STATUS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_NAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_ALIAS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HSPEED, (i + 1)) oids[key] = self.getValue #special OID: IP address key = '%s.%s' % (self.IP_ADENTIFINDEX, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentifindex_ref[key] = i + 1 key = '%s.%s' % (self.IF_IPADENTADDR, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentaddr_ref[key] = GetNetworkInfo( NetworkInfoTypes.ipaddr, i) bisectoidstore.BisectOIDStore.__init__(self, OIDs=oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None
class ourOIDStore(bisectoidstore.BisectOIDStore): startTime = time.time() haspicture = False oldframes = 0 iface = 'eth0' ip_adentifindex_ref = {} ip_adentaddr_ref = {} SYSUPTIME_OID = '.1.3.6.1.2.1.1.3.0' SYSTEMDESCRIPTION_OID = '.1.3.6.1.2.1.1.1.0' SYSTEMNAME_OID = '.1.3.6.1.2.1.1.6.0' SUPPORTADDRESS_OID = '.1.3.6.1.2.1.1.4.0' LOCATION_OID = '.1.3.6.1.2.1.1.5.0' BER_OID = '.1.3.6.1.2.1.1.10000.0' AGC_OID = '.1.3.6.1.2.1.1.10001.0' SNR_OID = '.1.3.6.1.2.1.1.10002.0' SNRDB_OID = '.1.3.6.1.2.1.1.10003.0' LOCK_OID = '.1.3.6.1.2.1.1.10004.0' HASPICTURE_OID = '.1.3.6.1.2.1.1.10009.0' CHANNELNAME_OID = '.1.3.6.1.2.1.1.10010.0' SERVICESTRING_OID = '.1.3.6.1.2.1.1.10011.0' FASTSCANSTRING_OID = '.1.3.6.1.2.1.1.10012.0' SERVICEPARAMS_OID = '.1.3.6.1.2.1.1.10013.0' TUNERTYPE_OID = '.1.3.6.1.2.1.1.10014.0' MANAGERIP_OID = '.1.3.6.1.2.1.1.10020.0' ENABLE_BITRATE_OID = '.1.3.6.1.2.1.1.10030.0' VIDEO_BITRATE_OID = '.1.3.6.1.2.1.1.10031.0' AUDIO_BITRATE_OID = '.1.3.6.1.2.1.1.10032.0' IP_OID = '.1.3.6.1.2.1.1.10050.0' NETMASK_OID = '.1.3.6.1.2.1.1.10051.0' GATEWAY_OID = '.1.3.6.1.2.1.1.10052.0' ENABLE_EMM_OID = '.1.3.6.1.2.1.1.10060.0' EMM_OID = '.1.3.6.1.2.1.1.10061.0' CPU_USER = '******' CPU_NICE = '.1.3.6.1.4.1.2021.11.51.0' CPU_SYSTEM = '.1.3.6.1.4.1.2021.11.52.0' CPU_IDLE = '.1.3.6.1.4.1.2021.11.53.0' CPU_WAIT = '.1.3.6.1.4.1.2021.11.54.0' LOAD_AVR1 = '.1.3.6.1.4.1.2021.10.1.3.1' LOAD_AVR5 = '.1.3.6.1.4.1.2021.10.1.3.2' LOAD_AVR15 = '.1.3.6.1.4.1.2021.10.1.3.3' MEM_TOTAL = '.1.3.6.1.4.1.2021.4.5.0' MEM_TOTAL2 = '.1.3.6.1.2.1.25.2.2.0' MEM_USED = '.1.3.6.1.4.1.2021.4.11.0' MEM_FREE = '.1.3.6.1.4.1.2021.4.6.0' MEM_BUFFER = '.1.3.6.1.4.1.2021.4.14.0' MEM_CACHED = '.1.3.6.1.4.1.2021.4.15.0' MEM_SWAPTOTAL = '.1.3.6.1.4.1.2021.4.3.0' MEM_SWAPFREE = '.1.3.6.1.4.1.2021.4.4.0' DISK_INDEX = '.1.3.6.1.4.1.2021.9.1.1' DISK_PATHNAME = '.1.3.6.1.4.1.2021.9.1.2' DISK_DEVICENAME = '.1.3.6.1.4.1.2021.9.1.3' DISK_AVAIL = '.1.3.6.1.4.1.2021.9.1.7' DISK_USED = '.1.3.6.1.4.1.2021.9.1.8' IF_NUMBER = '.1.3.6.1.2.1.2.1.0' IF_INDEX = '.1.3.6.1.2.1.2.2.1.1' IF_DESC = '.1.3.6.1.2.1.2.2.1.2' IF_TYPE = '.1.3.6.1.2.1.2.2.1.3' IF_MTU = '.1.3.6.1.2.1.2.2.1.4' IF_SPEED = '.1.3.6.1.2.1.2.2.1.5' IF_HWADDR = '.1.3.6.1.2.1.2.2.1.6' IF_STATUS = '.1.3.6.1.2.1.2.2.1.8' IF_INOCTANTS = '.1.3.6.1.2.1.2.2.1.10' IF_INDISCARD = '.1.3.6.1.2.1.2.2.1.13' IF_INERRORS = '.1.3.6.1.2.1.2.2.1.14' IF_OUTOCTANTS = '.1.3.6.1.2.1.2.2.1.16' IF_OUTDISCARD = '.1.3.6.1.2.1.2.2.1.19' IF_OUTERRORS = '.1.3.6.1.2.1.2.2.1.20' IF_IPADENTADDR = '.1.3.6.1.2.1.4.20.1.1' IP_ADENTIFINDEX = '.1.3.6.1.2.1.4.20.1.2' IF_NAME = '.1.3.6.1.2.1.31.1.1.1.1' IF_HSPEED = '.1.3.6.1.2.1.31.1.1.1.15' IF_ALIAS = '.1.3.6.1.2.1.31.1.1.1.18' def __init__(self, session, oids={}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.SNRDB_OID: self.getValue, self.LOCK_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.TUNERTYPE_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, self.CPU_USER: self.getValue, self.CPU_NICE: self.getValue, self.CPU_SYSTEM: self.getValue, self.CPU_IDLE: self.getValue, self.CPU_WAIT: self.getValue, self.LOAD_AVR1: self.getValue, self.LOAD_AVR5: self.getValue, self.LOAD_AVR15: self.getValue, self.MEM_TOTAL: self.getValue, self.MEM_TOTAL2: self.getValue, self.MEM_USED: self.getValue, self.MEM_FREE: self.getValue, self.MEM_BUFFER: self.getValue, self.MEM_CACHED: self.getValue, self.MEM_SWAPTOTAL: self.getValue, self.MEM_SWAPFREE: self.getValue, self.IF_NUMBER: self.getValue, }) # Add disk info's totaldisks = GetDiskInfo(DiskInfoTypes.totalmounts, 0) for i in range(totaldisks): key = '%s.%d' % (self.DISK_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_PATHNAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_DEVICENAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_AVAIL, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_USED, (i + 1)) oids[key] = self.getValue # Add network info's totalnetworks = GetNetworkInfo(NetworkInfoTypes.total, 0) for i in range(totalnetworks): key = '%s.%d' % (self.IF_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_DESC, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_TYPE, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_MTU, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_SPEED, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HWADDR, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_STATUS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_NAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_ALIAS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HSPEED, (i + 1)) oids[key] = self.getValue #special OID: IP address key = '%s.%s' % (self.IP_ADENTIFINDEX, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentifindex_ref[key] = i + 1 key = '%s.%s' % (self.IF_IPADENTADDR, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentaddr_ref[key] = GetNetworkInfo( NetworkInfoTypes.ipaddr, i) bisectoidstore.BisectOIDStore.__init__(self, OIDs=oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None def timerPoll(self): data = '' try: file = open('/proc/stb/vmpeg/0/stat_picture_displayed', 'r') data = file.readline() file.close() except: pass if len(data): frames = int(data, 16) if self.oldframes <> frames: self.haspicture = True self.oldframes = frames else: self.haspicture = False def gotServiceEvent(self, event): if self.bitrate: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.bitrate.stop() else: #don't start bitrate measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo( ) fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.bitrate.start() if self.emm: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.emm.stop() else: #don't start emm measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo( ) fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.emm.start() def getValue(self, oid, storage): oidstring = bisectoidstore.sortableToOID(oid) strOID = str(oidstring) if oidstring == self.SYSTEMDESCRIPTION_OID: return v1.OctetString( str(config.plugins.SnmpAgent.systemdescription.value)) elif oidstring == self.SYSUPTIME_OID: return self.getSysUpTime() elif oidstring == self.CPU_USER: return v1.Counter(GetCPUStatForType(CPUStatTypes.user)) elif oidstring == self.CPU_NICE: return v1.Counter(GetCPUStatForType(CPUStatTypes.nice)) elif oidstring == self.CPU_SYSTEM: return v1.Counter(GetCPUStatForType(CPUStatTypes.system)) elif oidstring == self.CPU_IDLE: return v1.Counter(GetCPUStatForType(CPUStatTypes.idle)) elif oidstring == self.CPU_WAIT: return v1.Counter(GetCPUStatForType(CPUStatTypes.iowait)) elif oidstring == self.LOAD_AVR1: return v1.OctetString(GetCPULoadForType(CPULoadTypes.one)) elif oidstring == self.LOAD_AVR5: return v1.OctetString(GetCPULoadForType(CPULoadTypes.five)) elif oidstring == self.LOAD_AVR15: return v1.OctetString(GetCPULoadForType(CPULoadTypes.fifteen)) elif oidstring == self.MEM_TOTAL: return v1.Integer(GetMemoryForType(MemoryTypes.total)) elif oidstring == self.MEM_TOTAL2: return v1.Integer(GetMemoryForType(MemoryTypes.total)) elif oidstring == self.MEM_USED: return v1.Integer(GetMemoryForType(MemoryTypes.used)) elif oidstring == self.MEM_FREE: return v1.Integer(GetMemoryForType(MemoryTypes.free)) elif oidstring == self.MEM_BUFFER: return v1.Integer(GetMemoryForType(MemoryTypes.buffers)) elif oidstring == self.MEM_CACHED: return v1.Integer(GetMemoryForType(MemoryTypes.cached)) elif oidstring == self.MEM_SWAPTOTAL: return v1.Integer(GetMemoryForType(MemoryTypes.swaptotal)) elif oidstring == self.MEM_SWAPFREE: return v1.Integer(GetMemoryForType(MemoryTypes.swapfree)) elif strOID.startswith(str(self.DISK_INDEX)): return v1.Integer(int(strOID[len(str(self.DISK_INDEX)) + 1:])) elif strOID.startswith(str(self.DISK_PATHNAME)): return v1.OctetString( GetDiskInfo(DiskInfoTypes.mountpoint, int(strOID[len(str(self.DISK_PATHNAME)) + 1:]) - 1)) elif strOID.startswith(str(self.DISK_DEVICENAME)): return v1.OctetString( GetDiskInfo( DiskInfoTypes.filesystem, int(strOID[len(str(self.DISK_DEVICENAME)) + 1:]) - 1)) elif strOID.startswith(str(self.DISK_AVAIL)): return v1.Integer( GetDiskInfo(DiskInfoTypes.avail, int(strOID[len(str(self.DISK_AVAIL)) + 1:]) - 1)) elif strOID.startswith(str(self.DISK_USED)): return v1.Integer( GetDiskInfo(DiskInfoTypes.used, int(strOID[len(str(self.DISK_USED)) + 1:]) - 1)) elif oidstring == self.IF_NUMBER: return v1.Integer(GetNetworkInfo(NetworkInfoTypes.total, 0)) elif strOID.startswith(str(self.IP_ADENTIFINDEX)): return v1.Integer(self.ip_adentifindex_ref[strOID]) elif strOID.startswith(str(self.IF_IPADENTADDR)): return v1.IpAddress(self.ip_adentaddr_ref[strOID]) elif strOID.startswith(str(self.IF_INOCTANTS)): return v1.Counter( GetNetworkInfo( NetworkInfoTypes.inoctants, int(strOID[len(str(self.IF_INOCTANTS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_INDISCARD)): return v1.Counter( GetNetworkInfo( NetworkInfoTypes.indiscard, int(strOID[len(str(self.IF_INDISCARD)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_INERRORS)): return v1.Counter( GetNetworkInfo( NetworkInfoTypes.inerrors, int(strOID[len(str(self.IF_INERRORS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_OUTOCTANTS)): return v1.Counter( GetNetworkInfo( NetworkInfoTypes.outoctacts, int(strOID[len(str(self.IF_OUTOCTANTS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_OUTDISCARD)): return v1.Counter( GetNetworkInfo( NetworkInfoTypes.outdiscard, int(strOID[len(str(self.IF_OUTDISCARD)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_OUTERRORS)): return v1.Counter( GetNetworkInfo( NetworkInfoTypes.outerrors, int(strOID[len(str(self.IF_OUTERRORS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_ALIAS)): return v1.OctetString( GetNetworkInfo(NetworkInfoTypes.alias, int(strOID[len(str(self.IF_ALIAS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_HSPEED)): return v1.Gauge( GetNetworkInfo(NetworkInfoTypes.hspeed, int(strOID[len(str(self.IF_HSPEED)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_INDEX)): return v1.Integer(int(strOID[len(str(self.IF_INDEX)) + 1:])) elif strOID.startswith(str(self.IF_DESC)): return v1.OctetString( GetNetworkInfo(NetworkInfoTypes.desc, int(strOID[len(str(self.IF_DESC)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_NAME)): return v1.OctetString( GetNetworkInfo(NetworkInfoTypes.desc, int(strOID[len(str(self.IF_NAME)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_TYPE)): return v1.Integer( GetNetworkInfo(NetworkInfoTypes.type, int(strOID[len(str(self.IF_TYPE)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_MTU)): return v1.Integer( GetNetworkInfo(NetworkInfoTypes.mtu, int(strOID[len(str(self.IF_MTU)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_SPEED)): return v1.Gauge( GetNetworkInfo(NetworkInfoTypes.speed, int(strOID[len(str(self.IF_SPEED)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_HWADDR)): return v1.OctetString( GetNetworkInfo(NetworkInfoTypes.hwaddr, int(strOID[len(str(self.IF_HWADDR)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_STATUS)): return v1.Integer( GetNetworkInfo(NetworkInfoTypes.status, int(strOID[len(str(self.IF_STATUS)) + 1:]) - 1)) elif oidstring == self.SUPPORTADDRESS_OID: return v1.OctetString( str(config.plugins.SnmpAgent.supportaddress.value)) elif oidstring == self.SYSTEMNAME_OID: return v1.OctetString( str(config.plugins.SnmpAgent.systemname.value)) elif oidstring == self.LOCATION_OID: return v1.OctetString(str(config.plugins.SnmpAgent.location.value)) elif oidstring == self.BER_OID: return self.getBER() elif oidstring == self.AGC_OID: return self.getAGC() elif oidstring == self.SNR_OID: return self.getSNR() elif oidstring == self.SNRDB_OID: return self.getSNRDB() elif oidstring == self.LOCK_OID: return self.getLock() elif oidstring == self.HASPICTURE_OID: return self.haspicture elif oidstring == self.VIDEO_BITRATE_OID: if self.bitrate: return self.bitrate.vcur else: return 0 elif oidstring == self.AUDIO_BITRATE_OID: if self.bitrate: return self.bitrate.acur else: return 0 elif oidstring == self.CHANNELNAME_OID: return v1.OctetString(self.getChannelName()) elif oidstring == self.SERVICESTRING_OID: return v1.OctetString(self.getServiceString()) elif oidstring == self.FASTSCANSTRING_OID: return v1.OctetString('') elif oidstring == self.SERVICEPARAMS_OID: return v1.OctetString(self.getServiceParams()) elif oidstring == self.TUNERTYPE_OID: return self.getTunerType() elif oidstring == self.MANAGERIP_OID: return v1.OctetString(str( config.plugins.SnmpAgent.managerip.value)) elif oidstring == self.ENABLE_BITRATE_OID: return config.plugins.SnmpAgent.measurebitrate.value elif oidstring == self.IP_OID: value = "%d.%d.%d.%d" % tuple( iNetwork.getAdapterAttribute(self.iface, "ip")) return v1.IpAddress(value) elif oidstring == self.NETMASK_OID: value = "%d.%d.%d.%d" % tuple( iNetwork.getAdapterAttribute(self.iface, "netmask")) return v1.IpAddress(value) elif oidstring == self.GATEWAY_OID: value = "%d.%d.%d.%d" % tuple( iNetwork.getAdapterAttribute(self.iface, "gateway")) return v1.IpAddress(value) elif oidstring == self.ENABLE_EMM_OID: return config.plugins.SnmpAgent.checkemm.value elif oidstring == self.EMM_OID: if self.emm: return v1.OctetString(self.emm.pids) else: return v1.OctetString('') def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get( ): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get( ): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[ 0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None def zapTo(self, reftozap): self.session.nav.playService(reftozap) def getSysUpTime(self): seconds = time.time() - self.startTime return int(round(seconds * 100, 0)) def getBER(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.bitErrorRate) return 0 def getAGC(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo( iFrontendInformation.signalPower) * 100 / 65536 return 0 def getSNR(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo( iFrontendInformation.signalQuality) * 100 / 65536 return 0 def getSNRDB(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() retval = feinfo.getFrontendInfo( iFrontendInformation.signalQualitydB) if retval == 0x12345678: #cable tuner? does not have SNR return v1.OctetString(0.0) return v1.OctetString(str(int(retval) / 100.0)) return 0 def getTunerType(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() frontendData = feinfo and feinfo.getAll(True) if frontendData is not None: ttype = frontendData.get("tuner_type", "UNKNOWN") return v1.OctetString(ttype) return v1.OctetString("UNKNOWN") def getLock(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.lockState) return 0 def getChannelName(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService( ): name = self.session.nav.getCurrentService().info().getName() return name def getServiceString(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService( ): name = self.session.nav.getCurrentService().info().getInfoString( iServiceInformation.sServiceref) return name def getServiceParams(self): orbital_pos = 0 tsid = 0 onid = 0 sid = 0 servicetype = 0 if self.session and self.session.nav and self.session.nav.getCurrentService( ): info = self.session.nav.getCurrentService().info() serviceref = info.getInfoString(iServiceInformation.sServiceref) servicedata = serviceref.split(':') orbital_pos = int(servicedata[6], 16) / 65536 tsid = int(servicedata[4], 16) onid = int(servicedata[5], 16) sid = int(servicedata[3], 16) servicetype = servicedata[2] params = str(orbital_pos) + "," + str(tsid) + "," + str( onid) + "," + str(sid) + "," + str(servicetype) return params
class SysInfo(Screen): skin = """ <screen name="SySInfo" position="0,0" size="1280,720" flags="wfNoBorder" backgroundColor="background" title=""> <widget backgroundColor="background" font="Regular;26" foregroundColor="2ndFG" position="30,15" render="Label" size="1050,35" source="Title" transparent="1" /> <ePixmap position="545,70" size="7,552" pixmap="skin_default/sysinfo/menuline.png" zPosition="2" alphatest="blend" /> <!-- Panel Info 1 --> <ePixmap pixmap="skin_default/sysinfo/mem.png" position="163,80" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/root.png" position="264,80" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/swap.png" position="359,80" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/summ.png" position="457,80" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <widget name="mem_labels" font="Regular;17" position="50,135" zPosition="1" size="100,110" valign="top" halign="left" backgroundColor="background" foregroundColor="un666666" transparent="1" /> <widget name="ram" font="Regular;17" position="163,135" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="root" font="Regular;17" position="264,135" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="swap" font="Regular;17" position="359,135" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="mem_tot" font="Regular;17" position="454,135" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="membar" position="148,155" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="rootbar" position="249,155" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="swapbar" position="342,155" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="memtotalbar" position="437,155" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="148,155" size="5,75" zPosition="1" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="249,155" size="5,75" zPosition="1" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="342,155" size="5,75" zPosition="1" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="437,155" size="5,75" zPosition="1" backgroundColor="background" alphatest="blend" /> <!-- Panel Info 2 --> <ePixmap pixmap="skin_default/sysinfo/hdd.png" position="163,270" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/usbmem.png" position="264,270" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/usbmem.png" position="359,270" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/usbmem.png" position="454,270" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <widget name="space_labels" font="Regular;17" position="50,325" zPosition="1" size="100,110" valign="top" halign="left" backgroundColor="background" foregroundColor="un666666" transparent="1" /> <widget name="hdd" font="Regular;17" position="163,325" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="usb" font="Regular;17" position="264,325" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="usb1" font="Regular;17" position="359,325" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="usb2" font="Regular;17" position="454,325" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="hddbar" position="148,340" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="usbbar" position="249,340" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="usb1bar" position="342,340" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="usb2bar" position="435,340" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="148,340" size="5,75" zPosition="1" backgroundColor="background" alphatest="on" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="249,340" size="5,75" zPosition="1" backgroundColor="background" alphatest="on" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="342,340" size="5,75" zPosition="1" backgroundColor="background" alphatest="on" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="435,340" size="5,75" zPosition="1" backgroundColor="background" alphatest="on" /> <!-- Panel Info 3 --> <widget name="HDDCPULabels" font="Regular;17" position="50,460" size="100,110" halign="left" valign="top" noWrap="1" zPosition="1" backgroundColor="background" foregroundColor="un666666" transparent="1" /> <widget name="usb3" font="Regular;17" position="163,460" zPosition="1" size="90,110" valign="top" halign="left" backgroundColor="background" transparent="1" /> <widget name="hddtemperature" font="Regular;17" position="229,460" zPosition="1" size="110,100" valign="top" halign="center" backgroundColor="background" transparent="1" /> <widget name="cpusys" font="Regular;17" position="327,460" zPosition="1" size="110,100" valign="top" halign="center" backgroundColor="background" transparent="1" /> <widget name="cpuusr" font="Regular;17" position="423,460" zPosition="1" size="110,90" valign="top" halign="center" backgroundColor="background" transparent="1" /> <ePixmap pixmap="skin_default/sysinfo/hdd_temp.png" position="264,510" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/summ.png" position="359,510" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <ePixmap pixmap="skin_default/sysinfo/summ.png" position="454,510" size="40,80" zPosition="2" backgroundColor="background" alphatest="blend" /> <widget name="usb3bar" position="148,480" size="5,75" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="hddtempbar" position="246,500" size="5,44" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="cpusysbar" position="341,500" size="5,44" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <widget name="cpuusrbar" position="436,500" size="5,44" pixmap="skin_default/sysinfo/bar.png" orientation="orBottomToTop" zPosition="2" backgroundColor="background" transparent="1" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="148,480" size="5,75" zPosition="1" backgroundColor="background" alphatest="on" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="246,500" size="5,44" zPosition="1" backgroundColor="background" alphatest="on" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="341,500" size="5,44" zPosition="1" backgroundColor="background" alphatest="on" /> <ePixmap pixmap="skin_default/sysinfo/bar_back.png" position="436,500" size="5,44" zPosition="1" backgroundColor="background" alphatest="on" /> <!-- Panel Time --> <widget name="uptime" position="560,80" size="32,32" zPosition="2" pixmap="skin_default/sysinfo/clock.png" transparent="1" alphatest="on" /> <eLabel text="Uptime:" position="610,80" size="150,25" font="Regular;20" halign="left" backgroundColor="background" foregroundColor="blue" transparent="1" /> <widget name="utday" position="560,110" size="100,25" font="Regular;17" valign="top" halign="left" zPosition="1" backgroundColor="background" foregroundColor="blue" transparent="1" /> <widget name="utdayval" position="640,110" size="100,25" font="Regular;17" valign="top" halign="right" zPosition="1" backgroundColor="background" transparent="1" /> <widget name="uthour" position="560,140" size="100,25" font="Regular;17" valign="top" halign="left" zPosition="1" backgroundColor="background" foregroundColor="blue" transparent="1" /> <widget name="uthourval" position="640,140" size="100,25" font="Regular;17" valign="top" halign="right" zPosition="1" backgroundColor="background" transparent="1" /> <widget name="utmin" position="560,170" size="100,25" font="Regular;17" valign="top" halign="left" zPosition="1" backgroundColor="background" foregroundColor="blue" transparent="1" /> <widget name="utminval" position="640,170" size="100,25" font="Regular;17" valign="top" halign="right" zPosition="1" backgroundColor="background" transparent="1" /> <widget name="utsec" position="560,200" size="100,25" font="Regular;17" valign="top" halign="left" zPosition="1" backgroundColor="background" foregroundColor="blue" transparent="1" /> <widget name="utsecval" position="640,200" size="100,25" font="Regular;17" valign="top" halign="right" zPosition="1" backgroundColor="background" transparent="1" /> <!-- Panel Audio/Video --> <widget source="video" render="Label" position="850,80" zPosition="2" foregroundColor="blue" backgroundColor="background" transparent="1" size="80,20" font="Regular;20" /> <widget source="min" render="Label" position="850,110" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="vmin" position="850,140" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="max" render="Label" position="920,110" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="vmax" position="920,140" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="avg" render="Label" position="990,110" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="vavg" position="990,140" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="cur" render="Label" position="1090,110" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="vcur" position="1090,140" size="80,20" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="audio" render="Label" position="850,170" zPosition="2" foregroundColor="blue" backgroundColor="background" transparent="1" size="80,20" font="Regular;20" /> <widget source="min" render="Label" position="850,200" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="amin" position="850,230" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="max" render="Label" position="920,200" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="amax" position="920,230" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="avg" render="Label" position="990,200" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="aavg" position="990,230" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <widget source="cur" render="Label" position="1090,200" zPosition="2" backgroundColor="background" transparent="1" size="80,25" font="Regular;20" /> <widget name="acur" position="1090,230" size="80,25" font="Regular;20" zPosition="2" backgroundColor="background" transparent="1" /> <eLabel position="560, 260" size="680, 1" backgroundColor="background" zPosition="1" /> <eLabel position="560, 260" size="682, 1" backgroundColor="background" zPosition="1" /> <!-- Panel Kernel Info --> <eLabel text="Kernelversion:" position="560,290" size="140,25" font="Regular;20" halign="left" foregroundColor="blue" backgroundColor="background" transparent="1" /> <widget name="kernelversion" position="560,320" size="680,200" font="Regular;19" halign="left" zPosition="2" backgroundColor="background" transparent="1" /> <eLabel position="560, 460" size="673, 1" backgroundColor="background" zPosition="1" /> <eLabel position="560, 462" size="673, 1" backgroundColor="background" zPosition="1" /> <!-- Panel Audio/Video --> <eLabel text="Dmesg Info" font="Regular;20" position="560,460" size="680,25" halign="left" foregroundColor="blue" backgroundColor="background" transparent="1"/> <widget name="DmesgInfo" noWrap="1" position="560,490" size="680,160" font="Regular;17" zPosition="2" halign="left" valign="top" backgroundColor="background" transparent="1" /> <widget name="key_red" position="30,671" size="300,26" zPosition="1" font="Regular;22" halign="center" foregroundColor="white" backgroundColor="black" transparent="1" /> <widget name="key_green" position="335,671" size="300,26" zPosition="1" font="Regular;22" halign="center" foregroundColor="white" backgroundColor="black" transparent="1" /> <widget name="key_yellow" position="640,671" size="300,26" zPosition="1" font="Regular;22" halign="center" foregroundColor="white" backgroundColor="black" transparent="1" valign="center" /> <eLabel name="bar_red" position="30,667" size="300,3" zPosition="3" backgroundColor="red" /> <eLabel name="bar_green" position="335,667" size="300,3" zPosition="3" backgroundColor="green" /> <eLabel name="bar_yellow" position="640,667" size="300,3" zPosition="3" backgroundColor="yellow" /> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session Screen.setTitle(self, _("System Info Panel")) self['mem_labels'] = Label(_('\nTotal:\nFree:\nUsed:\nUsed(%):')) self['ram'] = Label() self['root'] = Label() self['swap'] = Label() self['mem_tot'] = Label() self['membar'] = ProgressBar() self['rootbar'] = ProgressBar() self['swapbar'] = ProgressBar() self['memtotalbar'] = ProgressBar() self['space_labels'] = Label(_('\nTotal:\nFree:\nUsed:\nUsed(%):')) self['hdd'] = Label() self['usb'] = Label() self['usb1'] = Label() self['usb2'] = Label() self['hddbar'] = ProgressBar() self['usbbar'] = ProgressBar() self['usb1bar'] = ProgressBar() self['usb2bar'] = ProgressBar() self['HDDCPULabels'] = Label(_('Sensor:\nValue:')) self['usb3'] = Label() self['hddtemperature'] = Label(_('HDD Temp:\n....')) self['cpusys'] = Label() self['cpuusr'] = Label() self['usb3bar'] = ProgressBar() self['hddtempbar'] = ProgressBar() self['cpusysbar'] = ProgressBar() self['cpuusrbar'] = ProgressBar() self['uptime'] = Pixmap() self['utday'] = Label() self['uthour'] = Label() self['utmin'] = Label() self['utsec'] = Label() self['utdayval'] = Label() self['uthourval'] = Label() self['utminval'] = Label() self['utsecval'] = Label() self['utday'].hide() self['uthour'].hide() self['utmin'].hide() self['utsec'].hide() self['utdayval'].hide() self['uthourval'].hide() self['utminval'].hide() self['utsecval'].hide() self['kernelversion'] = Label('N/A') self['key1'] = Pixmap() self['key2'] = Pixmap() self['key3'] = Pixmap() self['key4'] = Pixmap() self['key5'] = Pixmap() self['key6'] = Pixmap() self['key_red'] = Label(_('Close')) self['key_green'] = Label(_('Refresh')) self['key_yellow'] = Label(_('Start Bitrate')) self['video'] = Label(_('Video')) self['audio'] = Label(_('Audio')) self['min'] = Label(_('Min')) self['max'] = Label(_('Max')) self['cur'] = Label(_('Current')) self['avg'] = Label(_('Average')) self['vmin'] = Label('') self['vmax'] = Label('') self['vavg'] = Label('') self['vcur'] = Label('') self['amin'] = Label('') self['amax'] = Label('') self['aavg'] = Label('') self['acur'] = Label('') self['DmesgInfo'] = ScrollLabel('') self['actions'] = ActionMap( ['OkCancelActions', 'WizardActions', 'ColorActions'], { 'down': self.pageDown, 'up': self.pageUp, 'ok': self.keyCancel, 'cancel': self.keyCancel, 'back': self.keyCancel, 'red': self.keyCancel, 'green': self.KeyGreen, 'yellow': self.KeyYellow, }) self.startDelayTimer = eTimer() self.startDelayTimer.callback.append(self.bitrateAfterDelayStart) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self.onLayoutFinish.append(self.updateList) def updateList(self): self.getUptime() self.getMemInfo() self.getSpaceInfo() self.getCPUInfo() self.getKernelVersion() self.bitrateStopped() self['DmesgInfo'].setText(self.getDmesg()) def KeyGreen(self): self.refresh() def KeyYellow(self): if self.bitrateUpdateStatus(): self.bitrate.stop() self['key_yellow'].setText(_('Start Bitrate')) else: self.bitrate.start() self['key_yellow'].setText(_('Stop Bitrate')) def keyCancel(self): self.bitrate.stop() self.close() def pageUp(self): self['DmesgInfo'].pageUp() def pageDown(self): self['DmesgInfo'].pageDown() def refresh(self): self.updateList() def bitrateUpdateStart(self, delay=0): self.startDelayTimer.stop() self.startDelayTimer.start(delay, True) def bitrateAfterDelayStart(self): if not self.bitrateUpdateStatus(): self.bitrate.start() def bitrateUpdateStatus(self): return self.bitrate.running def bitrateUpdateStop(self): self.startDelayTimer.stop() if self.bitrateUpdateStatus(): self.bitrate.stop() def bitrateStopped(self): self.refreshEvent() def refreshEvent(self): self["vmin"].setText(str(self.bitrate.vmin)) self["vmax"].setText(str(self.bitrate.vmax)) self["vavg"].setText(str(self.bitrate.vavg)) self["vcur"].setText(str(self.bitrate.vcur)) self["amin"].setText(str(self.bitrate.amin)) self["amax"].setText(str(self.bitrate.amax)) self["aavg"].setText(str(self.bitrate.aavg)) self["acur"].setText(str(self.bitrate.acur)) def getCPUInfo(self): cmd = ( 'mpstat | grep "all" | awk \'{print $3 " " $5}\' > /tmp/cpuinfo.tmp' ) system(cmd) if fileExists('/tmp/cpuinfo.tmp'): f = open('/tmp/cpuinfo.tmp', 'r') line = f.readlines() for lines in line: parts = lines.split(' ') if len(parts) > 1: usr = parts[0].replace(' ', '') sys = parts[1].replace(' ', '') usrint = int(float(usr)) sysint = int(float(sys)) self['cpuusrbar'].setValue(usrint) self['cpusysbar'].setValue(sysint) self['cpuusr'].setText('CPU Usr:\n' + usr + ' %') self['cpusys'].setText('CPU Sys:\n' + sys + ' %') f.close() remove('/tmp/cpuinfo.tmp') cmd = ('killall -9 top') system(cmd) def getUptime(self): fp = open('/proc/uptime') contents = fp.read().split() fp.close() total_seconds = float(contents[0]) days = int(total_seconds / 86400) hours = int(total_seconds / 3600 - days * 24) minutes = int(total_seconds / 60 - days * 1440 - hours * 60) seconds = int(total_seconds % 60) if days > 0: print days if days == 1: days = str(days) self['utday'].setText(_('Day')) self['utday'].show() self['utdayval'].setText(days) self['utdayval'].show() else: days = str(days) self['utday'].setText(_('Days')) self['utday'].show() self['utdayval'].setText(days) self['utdayval'].show() if hours > 0: if hours == 1: hours = str(hours) self['uthour'].setText(_('Hour:')) self['uthour'].show() self['uthourval'].setText(hours) self['uthourval'].show() else: hours = str(hours) self['uthour'].setText(_('Hours:')) self['uthour'].show() self['uthourval'].setText(hours) self['uthourval'].show() if minutes > 0: if minutes == 1: minutes = str(minutes) self['utmin'].setText(_('Minute:')) self['utmin'].show() self['utminval'].setText(minutes) self['utminval'].show() else: minutes = str(minutes) self['utmin'].setText(_('Minutes:')) self['utmin'].show() self['utminval'].setText(minutes) self['utminval'].show() if seconds > 0: if seconds == 1: seconds = str(seconds) self['utsec'].setText(_('Second:')) self['utsec'].show() self['utsecval'].setText(seconds) self['utsecval'].show() else: seconds = str(seconds) self['utsec'].setText(_('Seconds:')) self['utsec'].show() self['utsecval'].setText(seconds) self['utsecval'].show() def getKernelVersion(self): try: fp = open('/proc/version', 'r') line = fp.readline() fp.close except: line = 'N/A' self['kernelversion'].setText(line.replace('\n', '')) def getMemInfo(self): ramperc = 0 swapperc = 0 totperc = 0 ramtot = 0 swaptot = 0 tottot = 0 ramfree = 0 swapfree = 0 totfree = 0 ramused = 0 swapused = 0 totused = 0 rc = system('free -t > /tmp/ninfo.tmp') if fileExists('/tmp/ninfo.tmp'): f = open('/tmp/ninfo.tmp', 'r') for line in f.readlines(): parts = line.strip().split() if parts[0] == 'Mem:': ramperc = int(int(parts[2]) * 100 / int(parts[1])) ramtot = int(int(parts[1]) / 1000) ramfree = int(int(parts[3]) / 1000) ramused = int(int(parts[2]) / 1000) elif parts[0] == 'Swap:': if int(parts[1]) > 1: swapperc = int(int(parts[2]) * 100 / int(parts[1])) swaptot = int(int(parts[1]) / 1000) swapfree = int(int(parts[3]) / 1000) swapused = int(int(parts[2]) / 1000) elif parts[0] == 'Total:': totperc = int(int(parts[2]) * 100 / int(parts[1])) tottot = int(int(parts[1]) / 1000) totfree = int(int(parts[3]) / 1000) totused = int(int(parts[2]) / 1000) f.close() remove('/tmp/ninfo.tmp') self['ram'].setText('Ram:\n' + str(ramtot) + 'MB\n' + str(ramfree) + 'MB\n' + str(ramused) + 'MB\n' + str(ramperc) + '%') self['swap'].setText('Swap:\n' + str(swaptot) + 'MB\n' + str(swapfree) + 'MB\n' + str(swapused) + 'MB\n' + str(swapperc) + '%') self['mem_tot'].setText('Total:\n' + str(tottot) + 'MB\n' + str(totfree) + 'MB\n' + str(totused) + 'MB\n' + str(totperc) + '%') self['memtotalbar'].setValue(int(totperc)) self['swapbar'].setValue(int(swapperc)) self['membar'].setValue(int(ramperc)) def getSpace(self): rc = system('df -m > /tmp/ninfo.tmp') flashperc = 0 flashused = 0 flashtot = 0 cfused = 0 cftot = 0 cfperc = 0 usused = 0 ustot = 0 usperc = 0 us1used = 0 us1tot = 0 us1perc = 0 hdused = 0 hdtot = 0 hdperc = 0 fperc = 0 if fileExists('/tmp/ninfo.tmp'): f = open('/tmp/ninfo.tmp', 'r') for line in f.readlines(): line = line.replace('part1', ' ') parts = line.strip().split() totsp = len(parts) - 1 if parts[totsp] == '/': flashperc2 = parts[4] flashperc = int(parts[4].replace('%', '')) flashtot = int(parts[1]) flashused = int(parts[2]) if parts[totsp] == '/media/usb': usperc = int(parts[4].replace('%', '')) ustot = int(parts[1]) usused = int(parts[2]) if parts[totsp] == '/media/usb1': us1perc = int(parts[4].replace('%', '')) us1tot = int(parts[1]) us1used = int(parts[2]) if parts[totsp] == '/media/hdd': strview = parts[4].replace('%', '') if strview.isdigit(): hdperc = int(parts[4].replace('%', '')) hdtot = int(parts[1]) hdused = int(parts[2]) f.close() remove('/tmp/ninfo.tmp') ftot = cftot + ustot + us1used + hdtot fused = int(cfused) + int(usused) + int(us1used) + int(hdused) if ftot > 100: fperc = fused * 100 / ftot self['flashg'].setValue(int(flashperc)) self['usbg'].setValue(int(usperc * 100 / 120 + 50)) hddbar = str(hdperc) self['hddg'].setValue(int(hdperc)) def getSpaceInfo(self): rc = system('df -h > /tmp/ninfo.tmp') flashperc = 0 flashused = 0 flashtot = 0 rootperc = 0 roottot = 0 rootused = 0 rootfree = 0 usbused = 0 usbtot = 0 usbperc = 0 usb1used = 0 usb1tot = 0 usb1perc = 0 usb2used = 0 usb2tot = 0 usb2perc = 0 usb3used = 0 usb3tot = 0 usb3perc = 0 hddused = 0 hddtot = 0 hddperc = 0 fperc = 0 usbsumm = 'USB:\n.... \n.... \n.... \n....' usb1summ = 'USB1:\n.... \n.... \n.... \n....' usb2summ = 'USB2:\n.... \n.... \n.... \n....' usb3summ = 'USB3:\n.... \n.... \n.... \n....' hddsumm = 'HDD:\n.... \n.... \n.... \n....' if fileExists('/tmp/ninfo.tmp'): f = open('/tmp/ninfo.tmp', 'r') for line in f.readlines(): line = line.replace('part1', ' ') parts = line.strip().split() totsp = len(parts) - 1 if parts[totsp] == '/': rootperc = parts[4] roottot = parts[1] rootused = parts[2] rootfree = parts[3] self['root'].setText('Flash:\n' + str(roottot) + 'B\n' + str(rootfree) + 'B\n' + str(rootused) + 'B\n' + str(rootperc)) rootperc = rootperc.replace('%', '') self['rootbar'].setValue(int(rootperc)) if parts[totsp] == '/media/usb': usbperc = parts[4] usbtot = parts[1] usbused = parts[2] usbfree = parts[3] usbsumm = 'USB:\n' + str(usbtot) + 'B\n' + str( usbfree) + 'B\n' + str(usbused) + 'B\n' + str(usbperc) usbperc = usbperc.replace('%', '') if parts[totsp] == '/media/usb1': usb1perc = parts[4] usb1tot = parts[1] usb1used = parts[2] usb1free = parts[3] usb1summ = 'USB1:\n' + str(usb1tot) + 'B\n' + str( usb1free) + 'B\n' + str(usb1used) + 'B\n' + str( usb1perc) usb1perc = usb1perc.replace('%', '') if parts[totsp] == '/media/usb2': usb2perc = parts[4] usb2tot = parts[1] usb2used = parts[2] usb2free = parts[3] usb2summ = 'USB2:\n' + str(usb2tot) + 'B\n' + str( usb2free) + 'B\n' + str(usb2used) + 'B\n' + str( usb2perc) usb2perc = usb2perc.replace('%', '') if parts[totsp] == '/media/usb3': usb3perc = parts[4] usb3tot = parts[1] usb3used = parts[2] usb3free = parts[3] usb3summ = 'USB3:\n' + str(usb3tot) + 'B\n' + str( usb3free) + 'B\n' + str(usb3used) + 'B\n' + str( usb3perc) usb3perc = usb3perc.replace('%', '') if parts[totsp] == '/media/hdd': strview = parts[4].replace('%', '') if strview.isdigit(): hddperc = parts[4] hddtot = parts[1] hddused = parts[2] hddfree = parts[3] hddsumm = 'HDD:\n' + str(hddtot) + 'B\n' + str( hddfree) + 'B\n' + str(hddused) + 'B\n' + str( hddperc) hddperc = hddperc.replace('%', '') f.close() remove('/tmp/ninfo.tmp') self['usb'].setText(usbsumm) self['usb1'].setText(usb1summ) self['usb2'].setText(usb2summ) self['usb3'].setText(usb3summ) self['hdd'].setText(hddsumm) self['usbbar'].setValue(int(usbperc)) self['usb1bar'].setValue(int(usb1perc)) self['usb2bar'].setValue(int(usb2perc)) self['usb3bar'].setValue(int(usb3perc)) self['hddbar'].setValue(int(hddperc)) def getHddtemp(self): temperature = 'N/A' temperc = 0 hddloc = '' if fileExists('/proc/mounts'): f = open('/proc/mounts', 'r') for line in f.readlines(): if line.find('/hdd') != -1: hddloc = line pos = hddloc.find(' ') hddloc = hddloc[0:pos] hddloc = hddloc.strip() f.close() if hddloc: cmd = 'hddtemp -w ' + hddloc + ' > /tmp/ninfo.tmp' rc = system(cmd) if fileExists('/tmp/ninfo.tmp'): f = open('/tmp/ninfo.tmp', 'r') for line in f.readlines(): if line.find('WARNING') != -1: continue parts = line.strip().split(':') temperature = parts[2].strip() pos = temperature.find(' ') temperature = temperature[0:pos] if temperature.isdigit(): temperc = int(temperature) else: temperature = 'N/A' f.close() remove('/tmp/ninfo.tmp') temperature = str(temperc) self['hddtempg'].setRange((0, 80)) self['hddtempg'].setValue(temperc) self['hddtempbar'].setRange((0, 80)) self['hddtempbar'].setValue(temperc) def getHddTempInfo(self): temperature = 'HDD Temp:\nN/A' temperc = 0 hddloc = '' if fileExists('/proc/mounts'): f = open('/proc/mounts', 'r') for line in f.readlines(): if line.find('/hdd') != -1: hddloc = line pos = hddloc.find(' ') hddloc = hddloc[0:pos] hddloc = hddloc.strip() f.close() if hddloc: cmd = 'hddtemp -w ' + hddloc + ' > /tmp/ninfo.tmp' rc = system(cmd) if fileExists('/tmp/ninfo.tmp'): f = open('/tmp/ninfo.tmp', 'r') for line in f.readlines(): if line.find('WARNING') != -1: continue parts = line.strip().split(':') temperature = parts[2].strip() pos = temperature.find(' ') temperature = temperature[0:pos] if temperature.isdigit(): temperc = int(temperature) else: temperature = 'HDD Temp:\nN/A' f.close() remove('/tmp/ninfo.tmp') temperature = str(temperc) self['hddtempbar'].setRange((0, 80)) self['hddtempbar'].setValue(int(temperc)) self['hddtemperature'].setText('HDD Temp:\n' + temperature + ' \xc2\xb0C') def getDmesg(self): dmesg = '' system('dmesg > /tmp/tempinfo.tmp') if fileExists('/tmp/tempinfo.tmp'): f = open('/tmp/tempinfo.tmp', 'r') for line in f.readlines(): txt = line.strip() + '\n' dmesg += txt f.close() remove('/tmp/tempinfo.tmp') return dmesg
def __init__(self, session): Screen.__init__(self, session) self.session = session Screen.setTitle(self, _("System Info Panel")) self['mem_labels'] = Label(_('\nTotal:\nFree:\nUsed:\nUsed(%):')) self['ram'] = Label() self['root'] = Label() self['swap'] = Label() self['mem_tot'] = Label() self['membar'] = ProgressBar() self['rootbar'] = ProgressBar() self['swapbar'] = ProgressBar() self['memtotalbar'] = ProgressBar() self['space_labels'] = Label(_('\nTotal:\nFree:\nUsed:\nUsed(%):')) self['hdd'] = Label() self['usb'] = Label() self['usb1'] = Label() self['usb2'] = Label() self['hddbar'] = ProgressBar() self['usbbar'] = ProgressBar() self['usb1bar'] = ProgressBar() self['usb2bar'] = ProgressBar() self['HDDCPULabels'] = Label(_('Sensor:\nValue:')) self['usb3'] = Label() self['hddtemperature'] = Label(_('HDD Temp:\n....')) self['cpusys'] = Label() self['cpuusr'] = Label() self['usb3bar'] = ProgressBar() self['hddtempbar'] = ProgressBar() self['cpusysbar'] = ProgressBar() self['cpuusrbar'] = ProgressBar() self['uptime'] = Pixmap() self['utday'] = Label() self['uthour'] = Label() self['utmin'] = Label() self['utsec'] = Label() self['utdayval'] = Label() self['uthourval'] = Label() self['utminval'] = Label() self['utsecval'] = Label() self['utday'].hide() self['uthour'].hide() self['utmin'].hide() self['utsec'].hide() self['utdayval'].hide() self['uthourval'].hide() self['utminval'].hide() self['utsecval'].hide() self['kernelversion'] = Label('N/A') self['key1'] = Pixmap() self['key2'] = Pixmap() self['key3'] = Pixmap() self['key4'] = Pixmap() self['key5'] = Pixmap() self['key6'] = Pixmap() self['key_red'] = Label(_('Close')) self['key_green'] = Label(_('Refresh')) self['key_yellow'] = Label(_('Start Bitrate')) self['video'] = Label(_('Video')) self['audio'] = Label(_('Audio')) self['min'] = Label(_('Min')) self['max'] = Label(_('Max')) self['cur'] = Label(_('Current')) self['avg'] = Label(_('Average')) self['vmin'] = Label('') self['vmax'] = Label('') self['vavg'] = Label('') self['vcur'] = Label('') self['amin'] = Label('') self['amax'] = Label('') self['aavg'] = Label('') self['acur'] = Label('') self['DmesgInfo'] = ScrollLabel('') self['actions'] = ActionMap( ['OkCancelActions', 'WizardActions', 'ColorActions'], { 'down': self.pageDown, 'up': self.pageUp, 'ok': self.keyCancel, 'cancel': self.keyCancel, 'back': self.keyCancel, 'red': self.keyCancel, 'green': self.KeyGreen, 'yellow': self.KeyYellow, }) self.startDelayTimer = eTimer() self.startDelayTimer.callback.append(self.bitrateAfterDelayStart) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self.onLayoutFinish.append(self.updateList)
class BitrateViewer(Screen): skin = """ <screen position="c-175,c-75" size="350,230" title="Bitrate viewer"> <eLabel position="5,10" size="80,20" text="video" font="Regular;16" /> <eLabel position="5,30" size="80,20" text="min" font="Regular;16" /> <widget name="vmin" position="5,50" size="80,20" font="Regular;16" /> <eLabel position="85,30" size="80,20" text="max" font="Regular;16" /> <widget name="vmax" position="85,50" size="80,20" font="Regular;16" /> <eLabel position="165,30" size="80,20" text="average" font="Regular;16" /> <widget name="vavg" position="165,50" size="80,20" font="Regular;16" /> <eLabel position="245,30" size="80,20" text="current" font="Regular;16" /> <widget name="vcur" position="245,50" size="80,20" font="Regular;16" /> <eLabel position="5,80" size="80,20" text="audio" font="Regular;16" /> <eLabel position="5,100" size="80,20" text="min" font="Regular;16" /> <widget name="amin" position="5,120" size="80,20" font="Regular;16" /> <eLabel position="85,100" size="80,20" text="max" font="Regular;16" /> <widget name="amax" position="85,120" size="80,20" font="Regular;16" /> <eLabel position="165,100" size="80,20" text="average" font="Regular;16" /> <widget name="aavg" position="165,120" size="80,20" font="Regular;16" /> <eLabel position="245,100" size="80,20" text="current" font="Regular;16" /> <widget name="acur" position="245,120" size="80,20" font="Regular;16" /> <ePixmap pixmap="skin_default/buttons/red.png" position="c-70,e-45" zPosition="0" size="140,40" alphatest="on" /> <widget name="cancel" position="c-70,e-45" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="red" /> </screen>""" def __init__(self, session): self.skin = BitrateViewer.skin Screen.__init__(self, session) self.setTitle(_("Bitrate viewer")) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self["cancel"] = Button(_("Exit")) self["vmin"] = Label("") self["vmax"] = Label("") self["vavg"] = Label("") self["vcur"] = Label("") self["amin"] = Label("") self["amax"] = Label("") self["aavg"] = Label("") self["acur"] = Label("") self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "ok": self.keyCancel, "cancel": self.keyCancel, "red": self.keyCancel, }, -2) self.onLayoutFinish.append(self.bitrate.start) # dont start before gui is finished def refreshEvent(self): self["vmin"].setText(self.bitrate.vmin) self["vmax"].setText(self.bitrate.vmax) self["vavg"].setText(self.bitrate.vavg) self["vcur"].setText(self.bitrate.vcur) self["amin"].setText(self.bitrate.amin) self["amax"].setText(self.bitrate.amax) self["aavg"].setText(self.bitrate.aavg) self["acur"].setText(self.bitrate.acur) def keyCancel(self): self.bitrate.stop() self.close() def bitrateStopped(self, retval): self.close()
class BitrateViewer(Screen): skin = """ <screen position="c-175,c-75" size="350,230" title="Bitrate viewer"> <eLabel position="5,10" size="80,20" text="video" font="Regular;16" /> <eLabel position="5,30" size="80,20" text="min" font="Regular;16" /> <widget name="vmin" position="5,50" size="80,20" font="Regular;16" /> <eLabel position="85,30" size="80,20" text="max" font="Regular;16" /> <widget name="vmax" position="85,50" size="80,20" font="Regular;16" /> <eLabel position="165,30" size="80,20" text="average" font="Regular;16" /> <widget name="vavg" position="165,50" size="80,20" font="Regular;16" /> <eLabel position="245,30" size="80,20" text="current" font="Regular;16" /> <widget name="vcur" position="245,50" size="80,20" font="Regular;16" /> <eLabel position="5,80" size="80,20" text="audio" font="Regular;16" /> <eLabel position="5,100" size="80,20" text="min" font="Regular;16" /> <widget name="amin" position="5,120" size="80,20" font="Regular;16" /> <eLabel position="85,100" size="80,20" text="max" font="Regular;16" /> <widget name="amax" position="85,120" size="80,20" font="Regular;16" /> <eLabel position="165,100" size="80,20" text="average" font="Regular;16" /> <widget name="aavg" position="165,120" size="80,20" font="Regular;16" /> <eLabel position="245,100" size="80,20" text="current" font="Regular;16" /> <widget name="acur" position="245,120" size="80,20" font="Regular;16" /> <ePixmap pixmap="skin_default/buttons/red.png" position="c-70,e-45" zPosition="0" size="140,40" alphatest="on" /> <widget name="cancel" position="c-70,e-45" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="red" /> </screen>""" def __init__(self, session): self.skin = BitrateViewer.skin Screen.__init__(self, session) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self["cancel"] = Button(_("Exit")) self["vmin"] = Label("") self["vmax"] = Label("") self["vavg"] = Label("") self["vcur"] = Label("") self["amin"] = Label("") self["amax"] = Label("") self["aavg"] = Label("") self["acur"] = Label("") self["actions"] = ActionMap( ["OkCancelActions", "ColorActions"], { "ok": self.keyCancel, "cancel": self.keyCancel, "red": self.keyCancel, }, -2) self.onLayoutFinish.append( self.bitrate.start) # dont start before gui is finished def refreshEvent(self): self["vmin"].setText(self.bitrate.vmin) self["vmax"].setText(self.bitrate.vmax) self["vavg"].setText(self.bitrate.vavg) self["vcur"].setText(self.bitrate.vcur) self["amin"].setText(self.bitrate.amin) self["amax"].setText(self.bitrate.amax) self["aavg"].setText(self.bitrate.aavg) self["acur"].setText(self.bitrate.acur) def keyCancel(self): self.bitrate.stop() self.close() def bitrateStopped(self, retval): self.close()
def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get(): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get(): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None
def __init__(self, session, oids={}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.SNRDB_OID: self.getValue, self.LOCK_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.TUNERTYPE_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, self.CPU_USER: self.getValue, self.CPU_NICE: self.getValue, self.CPU_SYSTEM: self.getValue, self.CPU_IDLE: self.getValue, self.CPU_WAIT: self.getValue, self.LOAD_AVR1: self.getValue, self.LOAD_AVR5: self.getValue, self.LOAD_AVR15: self.getValue, self.MEM_TOTAL: self.getValue, self.MEM_TOTAL2: self.getValue, self.MEM_USED: self.getValue, self.MEM_FREE: self.getValue, self.MEM_BUFFER: self.getValue, self.MEM_CACHED: self.getValue, self.MEM_SWAPTOTAL: self.getValue, self.MEM_SWAPFREE: self.getValue, self.IF_NUMBER: self.getValue, }) # Add disk info's totaldisks = GetDiskInfo(DiskInfoTypes.totalmounts, 0) for i in range(totaldisks): key = '%s.%d' % (self.DISK_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_PATHNAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_DEVICENAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_AVAIL, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_USED, (i + 1)) oids[key] = self.getValue # Add network info's totalnetworks = GetNetworkInfo(NetworkInfoTypes.total, 0) for i in range(totalnetworks): key = '%s.%d' % (self.IF_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_DESC, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_TYPE, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_MTU, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_SPEED, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HWADDR, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_STATUS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_NAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_ALIAS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HSPEED, (i + 1)) oids[key] = self.getValue #special OID: IP address key = '%s.%s' % (self.IP_ADENTIFINDEX, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentifindex_ref[key] = i + 1 key = '%s.%s' % (self.IF_IPADENTADDR, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentaddr_ref[key] = GetNetworkInfo(NetworkInfoTypes.ipaddr, i) bisectoidstore.BisectOIDStore.__init__(self, OIDs=oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None
class ourOIDStore(bisectoidstore.BisectOIDStore): startTime = time.time() haspicture = False oldframes = 0 iface = 'eth0' ip_adentifindex_ref = {} ip_adentaddr_ref = {} SYSUPTIME_OID = '.1.3.6.1.2.1.1.3.0' SYSTEMDESCRIPTION_OID = '.1.3.6.1.2.1.1.1.0' SUPPORTADDRESS_OID = '.1.3.6.1.2.1.1.4.0' SYSTEMNAME_OID = '.1.3.6.1.2.1.1.5.0' LOCATION_OID = '.1.3.6.1.2.1.1.6.0' BER_OID = '.1.3.6.1.2.1.1.10000.0' AGC_OID = '.1.3.6.1.2.1.1.10001.0' SNR_OID = '.1.3.6.1.2.1.1.10002.0' SNRDB_OID = '.1.3.6.1.2.1.1.10003.0' LOCK_OID = '.1.3.6.1.2.1.1.10004.0' HASPICTURE_OID = '.1.3.6.1.2.1.1.10009.0' CHANNELNAME_OID = '.1.3.6.1.2.1.1.10010.0' SERVICESTRING_OID = '.1.3.6.1.2.1.1.10011.0' FASTSCANSTRING_OID = '.1.3.6.1.2.1.1.10012.0' SERVICEPARAMS_OID = '.1.3.6.1.2.1.1.10013.0' TUNERTYPE_OID = '.1.3.6.1.2.1.1.10014.0' MANAGERIP_OID = '.1.3.6.1.2.1.1.10020.0' ENABLE_BITRATE_OID = '.1.3.6.1.2.1.1.10030.0' VIDEO_BITRATE_OID = '.1.3.6.1.2.1.1.10031.0' AUDIO_BITRATE_OID = '.1.3.6.1.2.1.1.10032.0' IP_OID = '.1.3.6.1.2.1.1.10050.0' NETMASK_OID = '.1.3.6.1.2.1.1.10051.0' GATEWAY_OID = '.1.3.6.1.2.1.1.10052.0' ENABLE_EMM_OID = '.1.3.6.1.2.1.1.10060.0' EMM_OID = '.1.3.6.1.2.1.1.10061.0' CPU_USER = '******' CPU_NICE = '.1.3.6.1.4.1.2021.11.51.0' CPU_SYSTEM = '.1.3.6.1.4.1.2021.11.52.0' CPU_IDLE = '.1.3.6.1.4.1.2021.11.53.0' CPU_WAIT = '.1.3.6.1.4.1.2021.11.54.0' LOAD_AVR1 = '.1.3.6.1.4.1.2021.10.1.3.1' LOAD_AVR5 = '.1.3.6.1.4.1.2021.10.1.3.2' LOAD_AVR15 = '.1.3.6.1.4.1.2021.10.1.3.3' MEM_TOTAL = '.1.3.6.1.4.1.2021.4.5.0' MEM_TOTAL2 = '.1.3.6.1.2.1.25.2.2.0' MEM_USED = '.1.3.6.1.4.1.2021.4.11.0' MEM_FREE = '.1.3.6.1.4.1.2021.4.6.0' MEM_BUFFER = '.1.3.6.1.4.1.2021.4.14.0' MEM_CACHED = '.1.3.6.1.4.1.2021.4.15.0' MEM_SWAPTOTAL = '.1.3.6.1.4.1.2021.4.3.0' MEM_SWAPFREE = '.1.3.6.1.4.1.2021.4.4.0' DISK_INDEX = '.1.3.6.1.4.1.2021.9.1.1' DISK_PATHNAME = '.1.3.6.1.4.1.2021.9.1.2' DISK_DEVICENAME = '.1.3.6.1.4.1.2021.9.1.3' DISK_AVAIL = '.1.3.6.1.4.1.2021.9.1.7' DISK_USED = '.1.3.6.1.4.1.2021.9.1.8' IF_NUMBER = '.1.3.6.1.2.1.2.1.0' IF_INDEX = '.1.3.6.1.2.1.2.2.1.1' IF_DESC = '.1.3.6.1.2.1.2.2.1.2' IF_TYPE = '.1.3.6.1.2.1.2.2.1.3' IF_MTU = '.1.3.6.1.2.1.2.2.1.4' IF_SPEED = '.1.3.6.1.2.1.2.2.1.5' IF_HWADDR = '.1.3.6.1.2.1.2.2.1.6' IF_STATUS = '.1.3.6.1.2.1.2.2.1.8' IF_INOCTANTS = '.1.3.6.1.2.1.2.2.1.10' IF_INDISCARD = '.1.3.6.1.2.1.2.2.1.13' IF_INERRORS = '.1.3.6.1.2.1.2.2.1.14' IF_OUTOCTANTS = '.1.3.6.1.2.1.2.2.1.16' IF_OUTDISCARD = '.1.3.6.1.2.1.2.2.1.19' IF_OUTERRORS = '.1.3.6.1.2.1.2.2.1.20' IF_IPADENTADDR = '.1.3.6.1.2.1.4.20.1.1' IP_ADENTIFINDEX = '.1.3.6.1.2.1.4.20.1.2' IF_NAME = '.1.3.6.1.2.1.31.1.1.1.1' IF_HSPEED = '.1.3.6.1.2.1.31.1.1.1.15' IF_ALIAS = '.1.3.6.1.2.1.31.1.1.1.18' def __init__(self, session, oids={}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.SNRDB_OID: self.getValue, self.LOCK_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.TUNERTYPE_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, self.CPU_USER: self.getValue, self.CPU_NICE: self.getValue, self.CPU_SYSTEM: self.getValue, self.CPU_IDLE: self.getValue, self.CPU_WAIT: self.getValue, self.LOAD_AVR1: self.getValue, self.LOAD_AVR5: self.getValue, self.LOAD_AVR15: self.getValue, self.MEM_TOTAL: self.getValue, self.MEM_TOTAL2: self.getValue, self.MEM_USED: self.getValue, self.MEM_FREE: self.getValue, self.MEM_BUFFER: self.getValue, self.MEM_CACHED: self.getValue, self.MEM_SWAPTOTAL: self.getValue, self.MEM_SWAPFREE: self.getValue, self.IF_NUMBER: self.getValue, }) # Add disk info's totaldisks = GetDiskInfo(DiskInfoTypes.totalmounts, 0) for i in range(totaldisks): key = '%s.%d' % (self.DISK_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_PATHNAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_DEVICENAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_AVAIL, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.DISK_USED, (i + 1)) oids[key] = self.getValue # Add network info's totalnetworks = GetNetworkInfo(NetworkInfoTypes.total, 0) for i in range(totalnetworks): key = '%s.%d' % (self.IF_INDEX, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_DESC, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_TYPE, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_MTU, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_SPEED, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HWADDR, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_STATUS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_INERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTOCTANTS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTDISCARD, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_OUTERRORS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_NAME, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_ALIAS, (i + 1)) oids[key] = self.getValue key = '%s.%d' % (self.IF_HSPEED, (i + 1)) oids[key] = self.getValue #special OID: IP address key = '%s.%s' % (self.IP_ADENTIFINDEX, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentifindex_ref[key] = i + 1 key = '%s.%s' % (self.IF_IPADENTADDR, GetNetworkInfo(NetworkInfoTypes.ipaddr, i)) oids[key] = self.getValue self.ip_adentaddr_ref[key] = GetNetworkInfo(NetworkInfoTypes.ipaddr, i) bisectoidstore.BisectOIDStore.__init__(self, OIDs=oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None def timerPoll(self): data = '' try: file = open('/proc/stb/vmpeg/0/stat_picture_displayed', 'r') data = file.readline() file.close() except: pass if len(data): frames = int(data, 16) if self.oldframes <> frames: self.haspicture = True self.oldframes = frames else: self.haspicture = False def gotServiceEvent(self, event): if self.bitrate: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.bitrate.stop() else: #don't start bitrate measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.bitrate.start() if self.emm: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.emm.stop() else: #don't start emm measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.emm.start() def getValue(self, oid, storage): oidstring = bisectoidstore.sortableToOID(oid) strOID = str(oidstring) if oidstring == self.SYSTEMDESCRIPTION_OID: return v1.OctetString(str(config.plugins.SnmpAgent.systemdescription.value)) elif oidstring == self.SYSUPTIME_OID: return self.getSysUpTime() elif oidstring == self.CPU_USER: return v1.Counter(GetCPUStatForType(CPUStatTypes.user)) elif oidstring == self.CPU_NICE: return v1.Counter(GetCPUStatForType(CPUStatTypes.nice)) elif oidstring == self.CPU_SYSTEM: return v1.Counter(GetCPUStatForType(CPUStatTypes.system)) elif oidstring == self.CPU_IDLE: return v1.Counter(GetCPUStatForType(CPUStatTypes.idle)) elif oidstring == self.CPU_WAIT: return v1.Counter(GetCPUStatForType(CPUStatTypes.iowait)) elif oidstring == self.LOAD_AVR1: return v1.OctetString(GetCPULoadForType(CPULoadTypes.one)) elif oidstring == self.LOAD_AVR5: return v1.OctetString(GetCPULoadForType(CPULoadTypes.five)) elif oidstring == self.LOAD_AVR15: return v1.OctetString(GetCPULoadForType(CPULoadTypes.fifteen)) elif oidstring == self.MEM_TOTAL: return v1.Integer(GetMemoryForType(MemoryTypes.total)) elif oidstring == self.MEM_TOTAL2: return v1.Integer(GetMemoryForType(MemoryTypes.total)) elif oidstring == self.MEM_USED: return v1.Integer(GetMemoryForType(MemoryTypes.used)) elif oidstring == self.MEM_FREE: return v1.Integer(GetMemoryForType(MemoryTypes.free)) elif oidstring == self.MEM_BUFFER: return v1.Integer(GetMemoryForType(MemoryTypes.buffers)) elif oidstring == self.MEM_CACHED: return v1.Integer(GetMemoryForType(MemoryTypes.cached)) elif oidstring == self.MEM_SWAPTOTAL: return v1.Integer(GetMemoryForType(MemoryTypes.swaptotal)) elif oidstring == self.MEM_SWAPFREE: return v1.Integer(GetMemoryForType(MemoryTypes.swapfree)) elif strOID.startswith(str(self.DISK_INDEX)): return v1.Integer(int(strOID[len(str(self.DISK_INDEX)) + 1:])) elif strOID.startswith(str(self.DISK_PATHNAME)): return v1.OctetString(GetDiskInfo(DiskInfoTypes.mountpoint, int(strOID[len(str(self.DISK_PATHNAME)) + 1:]) - 1)) elif strOID.startswith(str(self.DISK_DEVICENAME)): return v1.OctetString(GetDiskInfo(DiskInfoTypes.filesystem, int(strOID[len(str(self.DISK_DEVICENAME)) + 1:]) - 1)) elif strOID.startswith(str(self.DISK_AVAIL)): return v1.Integer(GetDiskInfo(DiskInfoTypes.avail, int(strOID[len(str(self.DISK_AVAIL)) + 1:]) - 1)) elif strOID.startswith(str(self.DISK_USED)): return v1.Integer(GetDiskInfo(DiskInfoTypes.used, int(strOID[len(str(self.DISK_USED)) + 1:]) - 1)) elif oidstring == self.IF_NUMBER: return v1.Integer(GetNetworkInfo(NetworkInfoTypes.total, 0)) elif strOID.startswith(str(self.IP_ADENTIFINDEX)): return v1.Integer(self.ip_adentifindex_ref[strOID]) elif strOID.startswith(str(self.IF_IPADENTADDR)): return v1.IpAddress(self.ip_adentaddr_ref[strOID]) elif strOID.startswith(str(self.IF_INOCTANTS)): return v1.Counter(GetNetworkInfo(NetworkInfoTypes.inoctants, int(strOID[len(str(self.IF_INOCTANTS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_INDISCARD)): return v1.Counter(GetNetworkInfo(NetworkInfoTypes.indiscard, int(strOID[len(str(self.IF_INDISCARD)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_INERRORS)): return v1.Counter(GetNetworkInfo(NetworkInfoTypes.inerrors, int(strOID[len(str(self.IF_INERRORS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_OUTOCTANTS)): return v1.Counter(GetNetworkInfo(NetworkInfoTypes.outoctacts, int(strOID[len(str(self.IF_OUTOCTANTS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_OUTDISCARD)): return v1.Counter(GetNetworkInfo(NetworkInfoTypes.outdiscard, int(strOID[len(str(self.IF_OUTDISCARD)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_OUTERRORS)): return v1.Counter(GetNetworkInfo(NetworkInfoTypes.outerrors, int(strOID[len(str(self.IF_OUTERRORS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_ALIAS)): return v1.OctetString(GetNetworkInfo(NetworkInfoTypes.alias, int(strOID[len(str(self.IF_ALIAS)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_HSPEED)): return v1.Gauge(GetNetworkInfo(NetworkInfoTypes.hspeed, int(strOID[len(str(self.IF_HSPEED)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_INDEX)): return v1.Integer(int(strOID[len(str(self.IF_INDEX)) + 1:])) elif strOID.startswith(str(self.IF_DESC)): return v1.OctetString(GetNetworkInfo(NetworkInfoTypes.desc, int(strOID[len(str(self.IF_DESC)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_NAME)): return v1.OctetString(GetNetworkInfo(NetworkInfoTypes.desc, int(strOID[len(str(self.IF_NAME)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_TYPE)): return v1.Integer(GetNetworkInfo(NetworkInfoTypes.type, int(strOID[len(str(self.IF_TYPE)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_MTU)): return v1.Integer(GetNetworkInfo(NetworkInfoTypes.mtu, int(strOID[len(str(self.IF_MTU)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_SPEED)): return v1.Gauge(GetNetworkInfo(NetworkInfoTypes.speed, int(strOID[len(str(self.IF_SPEED)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_HWADDR)): return v1.OctetString(GetNetworkInfo(NetworkInfoTypes.hwaddr, int(strOID[len(str(self.IF_HWADDR)) + 1:]) - 1)) elif strOID.startswith(str(self.IF_STATUS)): return v1.Integer(GetNetworkInfo(NetworkInfoTypes.status, int(strOID[len(str(self.IF_STATUS)) + 1:]) - 1)) elif oidstring == self.SUPPORTADDRESS_OID: return v1.OctetString(str(config.plugins.SnmpAgent.supportaddress.value)) elif oidstring == self.SYSTEMNAME_OID: return v1.OctetString(str(config.plugins.SnmpAgent.systemname.value)) elif oidstring == self.LOCATION_OID: return v1.OctetString(str(config.plugins.SnmpAgent.location.value)) elif oidstring == self.BER_OID: return self.getBER() elif oidstring == self.AGC_OID: return self.getAGC() elif oidstring == self.SNR_OID: return self.getSNR() elif oidstring == self.SNRDB_OID: return self.getSNRDB() elif oidstring == self.LOCK_OID: return self.getLock() elif oidstring == self.HASPICTURE_OID: return self.haspicture elif oidstring == self.VIDEO_BITRATE_OID: if self.bitrate: return self.bitrate.vcur else: return 0 elif oidstring == self.AUDIO_BITRATE_OID: if self.bitrate: return self.bitrate.acur else: return 0 elif oidstring == self.CHANNELNAME_OID: return v1.OctetString(self.getChannelName()) elif oidstring == self.SERVICESTRING_OID: return v1.OctetString(self.getServiceString()) elif oidstring == self.FASTSCANSTRING_OID: return v1.OctetString('') elif oidstring == self.SERVICEPARAMS_OID: return v1.OctetString(self.getServiceParams()) elif oidstring == self.TUNERTYPE_OID: return self.getTunerType() elif oidstring == self.MANAGERIP_OID: return v1.OctetString(str(config.plugins.SnmpAgent.managerip.value)) elif oidstring == self.ENABLE_BITRATE_OID: return config.plugins.SnmpAgent.measurebitrate.value elif oidstring == self.IP_OID: value = "%d.%d.%d.%d" % tuple(iNetwork.getAdapterAttribute(self.iface, "ip")) return v1.IpAddress(value) elif oidstring == self.NETMASK_OID: value = "%d.%d.%d.%d" % tuple(iNetwork.getAdapterAttribute(self.iface, "netmask")) return v1.IpAddress(value) elif oidstring == self.GATEWAY_OID: value = "%d.%d.%d.%d" % tuple(iNetwork.getAdapterAttribute(self.iface, "gateway")) return v1.IpAddress(value) elif oidstring == self.ENABLE_EMM_OID: return config.plugins.SnmpAgent.checkemm.value elif oidstring == self.EMM_OID: if self.emm: return v1.OctetString(self.emm.pids) else: return v1.OctetString('') def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get(): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get(): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None def zapTo(self, reftozap): self.session.nav.playService(reftozap) def getSysUpTime(self): seconds = time.time() - self.startTime return int(round(seconds * 100, 0)) def getBER(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() if feinfo: return feinfo.getFrontendInfo(iFrontendInformation.bitErrorRate) return 0 def getAGC(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.signalPower) * 100 / 65536 return 0 def getSNR(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() if feinfo: return feinfo.getFrontendInfo(iFrontendInformation.signalQuality) * 100 / 65536 return 0 def getSNRDB(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() if feinfo: retval = feinfo.getFrontendInfo(iFrontendInformation.signalQualitydB) if retval == 0x12345678: #cable tuner? does not have SNR return v1.OctetString ( 0.0 ) return v1.OctetString (str (int(retval) / 100.0)) return 0 def getTunerType(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() frontendData = feinfo and feinfo.getAll(True) if frontendData is not None: ttype = frontendData.get("tuner_type", "UNKNOWN") return v1.OctetString ( ttype ) return v1.OctetString ( "UNKNOWN" ) def getLock(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() if feinfo: return feinfo.getFrontendInfo(iFrontendInformation.lockState) return 0 def getChannelName(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService(): name = self.session.nav.getCurrentService().info().getName() return name def getServiceString(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService(): name = self.session.nav.getCurrentService().info().getInfoString(iServiceInformation.sServiceref) return name def getServiceParams(self): orbital_pos = 0 tsid = 0 onid = 0 sid = 0 servicetype = 0 if self.session and self.session.nav and self.session.nav.getCurrentService(): info = self.session.nav.getCurrentService().info() serviceref = info.getInfoString(iServiceInformation.sServiceref) servicedata = serviceref.split(':') orbital_pos = int(servicedata[6], 16) / 65536 tsid = int(servicedata[4], 16) onid = int(servicedata[5], 16) sid = int(servicedata[3], 16) servicetype = servicedata[2] params = str(orbital_pos) + "," + str(tsid) + "," + str(onid) + "," + str(sid) + "," + str(servicetype) return params
class ourOIDStore(bisectoidstore.BisectOIDStore): startTime = time.time() haspicture = False oldframes = 0 iface = 'eth0' SYSUPTIME_OID = '.1.3.6.1.2.1.1.3.0' SYSTEMDESCRIPTION_OID = '.1.3.6.1.2.1.1.1.0' SYSTEMNAME_OID = '.1.3.6.1.2.1.1.6.0' SUPPORTADDRESS_OID = '.1.3.6.1.2.1.1.4.0' LOCATION_OID = '.1.3.6.1.2.1.1.5.0' BER_OID = '.1.3.6.1.2.1.1.10000.0' AGC_OID = '.1.3.6.1.2.1.1.10001.0' SNR_OID = '.1.3.6.1.2.1.1.10002.0' HASPICTURE_OID = '.1.3.6.1.2.1.1.10003.0' CHANNELNAME_OID = '.1.3.6.1.2.1.1.10010.0' SERVICESTRING_OID = '.1.3.6.1.2.1.1.10011.0' FASTSCANSTRING_OID = '.1.3.6.1.2.1.1.10012.0' SERVICEPARAMS_OID = '.1.3.6.1.2.1.1.10013.0' MANAGERIP_OID = '.1.3.6.1.2.1.1.10020.0' ENABLE_BITRATE_OID = '.1.3.6.1.2.1.1.10030.0' VIDEO_BITRATE_OID = '.1.3.6.1.2.1.1.10031.0' AUDIO_BITRATE_OID = '.1.3.6.1.2.1.1.10032.0' IP_OID = '.1.3.6.1.2.1.1.10050.0' NETMASK_OID = '.1.3.6.1.2.1.1.10051.0' GATEWAY_OID = '.1.3.6.1.2.1.1.10052.0' ENABLE_EMM_OID = '.1.3.6.1.2.1.1.10060.0' EMM_OID = '.1.3.6.1.2.1.1.10061.0' def __init__(self, session, oids = {}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, }) bisectoidstore.BisectOIDStore.__init__(self, OIDs = oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None def timerPoll(self): data = '' try: file = open('/proc/stb/vmpeg/0/stat_picture_displayed', 'r') data = file.readline() file.close() except: pass if len(data): frames = int(data, 16) if self.oldframes <> frames: self.haspicture = True self.oldframes = frames else: self.haspicture = False def gotServiceEvent(self, event): if self.bitrate: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.bitrate.stop() else: #don't start bitrate measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.bitrate.start() if self.emm: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.emm.stop() else: #don't start emm measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.emm.start() def getValue(self, oid, storage): oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.SYSTEMDESCRIPTION_OID: return v1.OctetString(str(config.plugins.SnmpAgent.systemdescription.value)) elif oidstring == self.SYSUPTIME_OID: return self.getSysUpTime() elif oidstring == self.SUPPORTADDRESS_OID: return v1.OctetString(str(config.plugins.SnmpAgent.supportaddress.value)) elif oidstring == self.SYSTEMNAME_OID: return v1.OctetString(str(config.plugins.SnmpAgent.systemname.value)) elif oidstring == self.LOCATION_OID: return v1.OctetString(str(config.plugins.SnmpAgent.location.value)) elif oidstring == self.BER_OID: return self.getBER() elif oidstring == self.AGC_OID: return self.getACG() elif oidstring == self.SNR_OID: return self.getSNR() elif oidstring == self.HASPICTURE_OID: return self.haspicture elif oidstring == self.VIDEO_BITRATE_OID: if self.bitrate: return self.bitrate.vcur else: return 0 elif oidstring == self.AUDIO_BITRATE_OID: if self.bitrate: return self.bitrate.acur else: return 0 elif oidstring == self.CHANNELNAME_OID: return v1.OctetString(self.getChannelName()) elif oidstring == self.SERVICESTRING_OID: return v1.OctetString(self.getServiceString()) elif oidstring == self.FASTSCANSTRING_OID: return v1.OctetString('') elif oidstring == self.SERVICEPARAMS_OID: return v1.OctetString(self.getServiceParams()) elif oidstring == self.MANAGERIP_OID: return v1.OctetString(str(config.plugins.SnmpAgent.managerip.value)) elif oidstring == self.ENABLE_BITRATE_OID: return config.plugins.SnmpAgent.measurebitrate.value elif oidstring == self.IP_OID: value = "%d.%d.%d.%d" % tuple(iNetwork.getAdapterAttribute(self.iface, "ip")) return v1.IpAddress(value) elif oidstring == self.NETMASK_OID: value = "%d.%d.%d.%d" % tuple(iNetwork.getAdapterAttribute(self.iface, "netmask")) return v1.IpAddress(value) elif oidstring == self.GATEWAY_OID: value = "%d.%d.%d.%d" % tuple(iNetwork.getAdapterAttribute(self.iface, "gateway")) return v1.IpAddress(value) elif oidstring == self.ENABLE_EMM_OID: return config.plugins.SnmpAgent.checkemm.value elif oidstring == self.EMM_OID: if self.emm: return v1.OctetString(self.emm.pids) else: return v1.OctetString('') def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get(): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get(): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func = self.zapTo, validate_commands = False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid,tsid,freq,id1,id2,sid,orbital_pos,f1,f2,f3,symbolrate,f4,name,provider,servicetype = fields[0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos,tsid,onid,sid,servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None def zapTo(self, reftozap): self.session.nav.playService(reftozap) def getSysUpTime(self): seconds = time.time() - self.startTime return int(round(seconds * 100, 0)) def getBER(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.bitErrorRate) return 0 def getAGC(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.signalQuality) * 100 / 65536 return 0 def getSNR(self): if self.session and self.session.nav and self.session.nav.getCurrentService(): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.signalPower) * 100 / 65536 return 0 def getChannelName(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService(): name = self.session.nav.getCurrentService().info().getName() return name def getServiceString(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService(): name = self.session.nav.getCurrentService().info().getInfoString(iServiceInformation.sServiceref) return name def getServiceParams(self): orbital_pos = 0 tsid = 0 onid = 0 sid = 0 servicetype = 0 if self.session and self.session.nav and self.session.nav.getCurrentService(): info = self.session.nav.getCurrentService().info() serviceref = info.getInfoString(iServiceInformation.sServiceref) servicedata = serviceref.split(':') orbital_pos = int(servicedata[6], 16) / 65536 tsid = int(servicedata[4], 16) onid = int(servicedata[5], 16) sid = int(servicedata[3], 16) servicetype = servicedata[2] params = str(orbital_pos) + "," + str(tsid), "," + str(onid) + "," + str(sid) + "," + str(servicetype) return params
class BitrateViewerExtra(Screen): skin_compact_fullhd = """ <screen position="200,40" size="300,90" zPosition="%s" flags="wfNoBorder" backgroundColor="%s" title="Bitrate viewer"> <widget render="Label" source="video_caption" position="10,10" zPosition="1" size="100,32" font="Regular;30" transparent="1"/> <widget render="Label" source="audio_caption" position="10,50" zPosition="1" size="100,32" font="Regular;30" transparent="1"/> <widget render="Label" source="video" position="105,10" zPosition="1" size="185,32" font="Regular;30" halign="right" transparent="1"/> <widget render="Label" source="audio" position="105,50" zPosition="1" size="185,32" font="Regular;30" halign="right" transparent="1"/> </screen>""" % (config.plugins.bitrate.z.value, config.plugins.bitrate.background.value) skin_info_fullhd = """ <screen position="200,300" size="350,160" zPosition="%s" title="Bitrate viewer"> <eLabel position="5,10" size="80,22" text="video" font="Regular;20" /> <eLabel position="5,30" size="80,22" text="min" font="Regular;20" /> <widget name="vmin" position="5,50" size="80,22" font="Regular;20" /> <eLabel position="85,30" size="80,22" text="max" font="Regular;20" /> <widget name="vmax" position="85,50" size="80,22" font="Regular;20" /> <eLabel position="165,30" size="80,22" text="average" font="Regular;20" /> <widget name="vavg" position="165,50" size="80,22" font="Regular;20" /> <eLabel position="245,30" size="80,22" text="current" font="Regular;20" /> <widget name="vcur" position="245,50" size="80,22" font="Regular;20" /> <eLabel position="5,80" size="80,22" text="audio" font="Regular;20" /> <eLabel position="5,100" size="80,22" text="min" font="Regular;20" /> <widget name="amin" position="5,120" size="80,22" font="Regular;20" /> <eLabel position="85,100" size="80,22" text="max" font="Regular;20" /> <widget name="amax" position="85,120" size="80,22" font="Regular;20" /> <eLabel position="165,100" size="80,22" text="average" font="Regular;20" /> <widget name="aavg" position="165,120" size="80,22" font="Regular;20" /> <eLabel position="245,100" size="80,22" text="current" font="Regular;20" /> <widget name="acur" position="245,120" size="80,22" font="Regular;20" /> </screen>""" % (config.plugins.bitrate.z.value) skin_compact = """ <screen position="200,40" size="200,60" zPosition="%s" backgroundColor="%s" flags="wfNoBorder" title="Bitrate viewer"> <widget render="Label" source="video_caption" position="10,10" zPosition="1" size="70,22" font="Regular;20" transparent="1"/> <widget render="Label" source="audio_caption" position="10,35" zPosition="1" size="70,22" font="Regular;20" transparent="1"/> <widget render="Label" source="video" position="85,10" zPosition="1" size="110,22" font="Regular;20" halign="right" transparent="1"/> <widget render="Label" source="audio" position="85,35" zPosition="1" size="110,22" font="Regular;20" halign="right" transparent="1"/> </screen>""" % (config.plugins.bitrate.z.value, config.plugins.bitrate.background.value) skin_info = """ <screen position="200,300" size="350,160" zPosition="%s" title="Bitrate viewer"> <eLabel position="5,10" size="80,20" text="video" font="Regular;16" /> <eLabel position="5,30" size="80,20" text="min" font="Regular;16" /> <widget name="vmin" position="5,50" size="80,20" font="Regular;16" /> <eLabel position="85,30" size="80,20" text="max" font="Regular;16" /> <widget name="vmax" position="85,50" size="80,20" font="Regular;16" /> <eLabel position="165,30" size="80,20" text="average" font="Regular;16" /> <widget name="vavg" position="165,50" size="80,20" font="Regular;16" /> <eLabel position="245,30" size="80,20" text="current" font="Regular;16" /> <widget name="vcur" position="245,50" size="80,20" font="Regular;16" /> <eLabel position="5,80" size="80,20" text="audio" font="Regular;16" /> <eLabel position="5,100" size="80,20" text="min" font="Regular;16" /> <widget name="amin" position="5,120" size="80,20" font="Regular;16" /> <eLabel position="85,100" size="80,20" text="max" font="Regular;16" /> <widget name="amax" position="85,120" size="80,20" font="Regular;16" /> <eLabel position="165,100" size="80,20" text="average" font="Regular;16" /> <widget name="aavg" position="165,120" size="80,20" font="Regular;16" /> <eLabel position="245,100" size="80,20" text="current" font="Regular;16" /> <widget name="acur" position="245,120" size="80,20" font="Regular;16" /> </screen>""" % (config.plugins.bitrate.z.value) def __init__(self, session, infobar_mode=False): if FULLHD: if config.plugins.bitrate.style_skin.value == "compact": self.skin = self.skin_compact_fullhd else: self.skin = self.skin_info_fullhd else: if config.plugins.bitrate.style_skin.value == "compact": self.skin = self.skin_compact else: self.skin = self.skin_info Screen.__init__(self, session) self.infobar_mode = infobar_mode self.style_skin = config.plugins.bitrate.style_skin.value self.startDelayTimer = eTimer() self.startDelayTimer.callback.append(self.bitrateAfrterDelayStart) if config.plugins.bitrate.style_skin.value == "compact": self["video_caption"] = StaticText(_("Video:")) self["audio_caption"] = StaticText(_("Audio:")) self["video"] = StaticText() self["audio"] = StaticText() else: self.setTitle(_("Bitrate viewer")) self["vmin"] = Label("") self["vmax"] = Label("") self["vavg"] = Label("") self["vcur"] = Label("") self["amin"] = Label("") self["amax"] = Label("") self["aavg"] = Label("") self["acur"] = Label("") if not infobar_mode: self["actions"] = ActionMap( ["WizardActions"], { "back": self.keyCancel, "ok": self.keyCancel, "right": self.keyCancel, "left": self.keyCancel, "down": self.keyCancel, "up": self.keyCancel, }, -1) self.bitrate = Bitrate(session, self.refreshEvent, self.bitrateStopped) self.onLayoutFinish.append(self.__layoutFinished) def __layoutFinished(self): if self.instance: self.instance.move( ePoint(config.plugins.bitrate.x.value, config.plugins.bitrate.y.value)) if not self.infobar_mode: self.bitrateUpdateStart() def bitrateUpdateStart(self, delay=0): self.startDelayTimer.stop() self.startDelayTimer.start(delay, True) def bitrateAfrterDelayStart(self): if not self.bitrateUpdateStatus(): self.bitrate.start() def bitrateUpdateStatus(self): return self.bitrate.running def bitrateUpdateStop(self): self.startDelayTimer.stop() if self.bitrateUpdateStatus(): self.bitrate.stop() if self.infobar_mode: self.refreshEvent() def refreshEvent(self): if self.style_skin == "compact": self["video"].setText(str(self.bitrate.vcur) + _(" kbit/s")) self["audio"].setText(str(self.bitrate.acur) + _(" kbit/s")) else: self["vmin"].setText(str(self.bitrate.vmin)) self["vmax"].setText(str(self.bitrate.vmax)) self["vavg"].setText(str(self.bitrate.vavg)) self["vcur"].setText(str(self.bitrate.vcur)) self["amin"].setText(str(self.bitrate.amin)) self["amax"].setText(str(self.bitrate.amax)) self["aavg"].setText(str(self.bitrate.aavg)) self["acur"].setText(str(self.bitrate.acur)) def keyCancel(self): self.bitrate.stop() self.close() def bitrateStopped(self, retval): if not self.infobar_mode: self.close() else: self.refreshEvent() if self.shown: self.hide()
class ourOIDStore(bisectoidstore.BisectOIDStore): startTime = time.time() haspicture = False oldframes = 0 iface = 'eth0' SYSUPTIME_OID = '.1.3.6.1.2.1.1.3.0' SYSTEMDESCRIPTION_OID = '.1.3.6.1.2.1.1.1.0' SYSTEMNAME_OID = '.1.3.6.1.2.1.1.6.0' SUPPORTADDRESS_OID = '.1.3.6.1.2.1.1.4.0' LOCATION_OID = '.1.3.6.1.2.1.1.5.0' BER_OID = '.1.3.6.1.2.1.1.10000.0' AGC_OID = '.1.3.6.1.2.1.1.10001.0' SNR_OID = '.1.3.6.1.2.1.1.10002.0' HASPICTURE_OID = '.1.3.6.1.2.1.1.10003.0' CHANNELNAME_OID = '.1.3.6.1.2.1.1.10010.0' SERVICESTRING_OID = '.1.3.6.1.2.1.1.10011.0' FASTSCANSTRING_OID = '.1.3.6.1.2.1.1.10012.0' SERVICEPARAMS_OID = '.1.3.6.1.2.1.1.10013.0' MANAGERIP_OID = '.1.3.6.1.2.1.1.10020.0' ENABLE_BITRATE_OID = '.1.3.6.1.2.1.1.10030.0' VIDEO_BITRATE_OID = '.1.3.6.1.2.1.1.10031.0' AUDIO_BITRATE_OID = '.1.3.6.1.2.1.1.10032.0' IP_OID = '.1.3.6.1.2.1.1.10050.0' NETMASK_OID = '.1.3.6.1.2.1.1.10051.0' GATEWAY_OID = '.1.3.6.1.2.1.1.10052.0' ENABLE_EMM_OID = '.1.3.6.1.2.1.1.10060.0' EMM_OID = '.1.3.6.1.2.1.1.10061.0' def __init__(self, session, oids={}): self.session = session oids.update({ self.SYSTEMDESCRIPTION_OID: self.getValue, '.1.3.6.1.2.1.1.2.0': '.1.3.6.1.4.1.88.3.1', self.SYSUPTIME_OID: self.getValue, self.SUPPORTADDRESS_OID: self.getValue, self.SYSTEMNAME_OID: self.getValue, self.LOCATION_OID: self.getValue, self.BER_OID: self.getValue, self.AGC_OID: self.getValue, self.SNR_OID: self.getValue, self.HASPICTURE_OID: self.getValue, self.VIDEO_BITRATE_OID: self.getValue, self.AUDIO_BITRATE_OID: self.getValue, self.CHANNELNAME_OID: self.getValue, self.SERVICESTRING_OID: self.getValue, self.FASTSCANSTRING_OID: self.getValue, self.SERVICEPARAMS_OID: self.getValue, self.MANAGERIP_OID: self.getValue, self.ENABLE_BITRATE_OID: self.getValue, self.IP_OID: self.getValue, self.NETMASK_OID: self.getValue, self.GATEWAY_OID: self.getValue, self.ENABLE_EMM_OID: self.getValue, self.EMM_OID: self.getValue, }) bisectoidstore.BisectOIDStore.__init__(self, OIDs=oids) self.session.nav.event.append(self.gotServiceEvent) if config.plugins.SnmpAgent.measurebitrate.value: self.bitrate = Bitrate(session) else: self.bitrate = None if config.plugins.SnmpAgent.checkemm.value: self.emm = Emm(session) else: self.emm = None def timerPoll(self): data = '' try: file = open('/proc/stb/vmpeg/0/stat_picture_displayed', 'r') data = file.readline() file.close() except: pass if len(data): frames = int(data, 16) if self.oldframes <> frames: self.haspicture = True self.oldframes = frames else: self.haspicture = False def gotServiceEvent(self, event): if self.bitrate: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.bitrate.stop() else: #don't start bitrate measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo( ) fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.bitrate.start() if self.emm: if event is iPlayableService.evEnd or event is iPlayableService.evStopped: self.emm.stop() else: #don't start emm measurement when playing recordings if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo( ) fedata = feinfo and feinfo.getFrontendData() if fedata and 'tuner_number' in fedata: self.emm.start() def getValue(self, oid, storage): oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.SYSTEMDESCRIPTION_OID: return v1.OctetString( str(config.plugins.SnmpAgent.systemdescription.value)) elif oidstring == self.SYSUPTIME_OID: return self.getSysUpTime() elif oidstring == self.SUPPORTADDRESS_OID: return v1.OctetString( str(config.plugins.SnmpAgent.supportaddress.value)) elif oidstring == self.SYSTEMNAME_OID: return v1.OctetString( str(config.plugins.SnmpAgent.systemname.value)) elif oidstring == self.LOCATION_OID: return v1.OctetString(str(config.plugins.SnmpAgent.location.value)) elif oidstring == self.BER_OID: return self.getBER() elif oidstring == self.AGC_OID: return self.getACG() elif oidstring == self.SNR_OID: return self.getSNR() elif oidstring == self.HASPICTURE_OID: return self.haspicture elif oidstring == self.VIDEO_BITRATE_OID: if self.bitrate: return self.bitrate.vcur else: return 0 elif oidstring == self.AUDIO_BITRATE_OID: if self.bitrate: return self.bitrate.acur else: return 0 elif oidstring == self.CHANNELNAME_OID: return v1.OctetString(self.getChannelName()) elif oidstring == self.SERVICESTRING_OID: return v1.OctetString(self.getServiceString()) elif oidstring == self.FASTSCANSTRING_OID: return v1.OctetString('') elif oidstring == self.SERVICEPARAMS_OID: return v1.OctetString(self.getServiceParams()) elif oidstring == self.MANAGERIP_OID: return v1.OctetString(str( config.plugins.SnmpAgent.managerip.value)) elif oidstring == self.ENABLE_BITRATE_OID: return config.plugins.SnmpAgent.measurebitrate.value elif oidstring == self.IP_OID: value = "%d.%d.%d.%d" % tuple( iNetwork.getAdapterAttribute(self.iface, "ip")) return v1.IpAddress(value) elif oidstring == self.NETMASK_OID: value = "%d.%d.%d.%d" % tuple( iNetwork.getAdapterAttribute(self.iface, "netmask")) return v1.IpAddress(value) elif oidstring == self.GATEWAY_OID: value = "%d.%d.%d.%d" % tuple( iNetwork.getAdapterAttribute(self.iface, "gateway")) return v1.IpAddress(value) elif oidstring == self.ENABLE_EMM_OID: return config.plugins.SnmpAgent.checkemm.value elif oidstring == self.EMM_OID: if self.emm: return v1.OctetString(self.emm.pids) else: return v1.OctetString('') def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get( ): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get( ): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[ 0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None def zapTo(self, reftozap): self.session.nav.playService(reftozap) def getSysUpTime(self): seconds = time.time() - self.startTime return int(round(seconds * 100, 0)) def getBER(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo(iFrontendInformation.bitErrorRate) return 0 def getAGC(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo( iFrontendInformation.signalQuality) * 100 / 65536 return 0 def getSNR(self): if self.session and self.session.nav and self.session.nav.getCurrentService( ): feinfo = self.session.nav.getCurrentService().frontendInfo() return feinfo.getFrontendInfo( iFrontendInformation.signalPower) * 100 / 65536 return 0 def getChannelName(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService( ): name = self.session.nav.getCurrentService().info().getName() return name def getServiceString(self): name = "unknown" if self.session and self.session.nav and self.session.nav.getCurrentService( ): name = self.session.nav.getCurrentService().info().getInfoString( iServiceInformation.sServiceref) return name def getServiceParams(self): orbital_pos = 0 tsid = 0 onid = 0 sid = 0 servicetype = 0 if self.session and self.session.nav and self.session.nav.getCurrentService( ): info = self.session.nav.getCurrentService().info() serviceref = info.getInfoString(iServiceInformation.sServiceref) servicedata = serviceref.split(':') orbital_pos = int(servicedata[6], 16) / 65536 tsid = int(servicedata[4], 16) onid = int(servicedata[5], 16) sid = int(servicedata[3], 16) servicetype = servicedata[2] params = str(orbital_pos) + "," + str(tsid), "," + str( onid) + "," + str(sid) + "," + str(servicetype) return params