Beispiel #1
0
 def getText(self):
     text = _('N/A')
     if self.type == self.HDDTEMP:
         text = self.getHddTemp()
     elif self.type == self.LOADAVG:
         text = self.getLoadAvg()
     else:
         entry = {
             self.MEMTOTAL: ('Mem', 'Ram'),
             self.MEMFREE: ('Mem', 'Ram'),
             self.SWAPTOTAL: ('Swap', 'Swap'),
             self.SWAPFREE: ('Swap', 'Swap'),
             self.USBINFO: ('/media/usb', 'USB'),
             self.HDDINFO: ('/media/hdd', 'HDD'),
             self.FLASHINFO: ('/', 'Flash')
         }[self.type]
         if self.type in (self.USBINFO, self.HDDINFO, self.FLASHINFO):
             list = self.getDiskInfo(entry[0])
         else:
             list = self.getMemInfo(entry[0])
         if list[0] == 0:
             text = _('%s: Not Available') % entry[1]
         elif self.shortFormat:
             text = _('%s: %s, in use: %s%%') % (
                 entry[1], self.getSizeStr(list[0]), list[3])
         elif self.fullFormat:
             text = _('%s: %s Free: %s Used: %s (%s%%)') % (
                 entry[1], self.getSizeStr(list[0]), self.getSizeStr(
                     list[2]), self.getSizeStr(list[1]), list[3])
         else:
             text = _('%s: %s Used: %s Free: %s') % (
                 entry[1], self.getSizeStr(list[0]), self.getSizeStr(
                     list[1]), self.getSizeStr(list[2]))
     return text
Beispiel #2
0
    def getLoadAvg(self):
        textvalue = _('No info')
        info = '0'
        try:
            out_line = popen('cat /proc/loadavg').readline()
            info = 'loadavg:' + out_line[:15]
            textvalue = info
        except:
            pass

        return textvalue
Beispiel #3
0
    def getHddTemp(self):
        textvalue = _('No info')
        info = '0'
        try:
            out_line = popen('hddtemp -n -q /dev/sda').readline()
            info = 'Hdd C:' + out_line[:4]
            textvalue = info
        except:
            pass

        return textvalue
    def runningSoftCamName(self, fullName=False):
        if DBG:
            j00zekDEBUG(
                '[j00zekModCaidInfo2:runningSoftCamName] >>> fullName="%s"' %
                str(fullName))

        def checkCam(txt):
            for scName in ('oscam_emu', 'oscam', 'cccam', 'mgcam'):
                if scName in procStat.lower():
                    if fullName:
                        return procStat
                    else:
                        return scName
            return None

        #trying to use last PID
        try:
            procStat = open(os.path.join("/proc", str(self.currPID), 'stat'),
                            "r").read().split('(')[1].split(')')[0]
            foundSC = checkCam(procStat)
            if not foundSC is None:
                return foundSC
        except Exception as e:
            if DBG:
                j00zekDEBUG(
                    '\t Exception trying to get name of curr.PID= %s : %s' %
                    (os.path.join("/proc", str(self.currPID)), str(e)))
        #searching for new PID
        for f in os.listdir("/proc"):
            if os.path.isdir(os.path.join("/proc", f)):
                try:
                    pid = int(f)
                    if pid > self.currPID:
                        procStat = open(os.path.join("/proc", f, 'stat'),
                                        "r").read().split('(')[1].split(')')[0]
                        foundSC = checkCam(procStat)
                        if not foundSC is None:
                            self.currPID = pid
                            return foundSC
                except Exception as e:
                    if DBG:
                        j00zekDEBUG('\t Exception trying to analyze %s : %s' %
                                    (os.path.join("/proc", f), str(e)))
        return _('None SoftCam is running')
    def getText(self):
        if DBG:
            j00zekDEBUG(
                '[j00zekModCaidInfo2:getText] >>>self.type="%s", ciFormat.value="%s"'
                % (self.type, config.plugins.j00zekCC.ciFormat.value))
        textvalue = ""
        server = ""
        softCamName = ''
        service = self.source.service
        # name softcam name is independent, so here to always return it when requested
        if self.type == self.USE_CFG:
            if config.plugins.j00zekCC.ciFormat.value == '':
                return self.runningSoftCamName(True)
            elif '%SCN' in config.plugins.j00zekCC.ciFormat.value:
                softCamName = self.runningSoftCamName(False)
            elif '%SCFN' in config.plugins.j00zekCC.ciFormat.value:
                softCamName = self.runningSoftCamName(True)
        elif self.type == self.FORMAT:
            if '%SCN' in self.sfmt:
                softCamName = self.runningSoftCamName(False)
            elif '%SCFN' in self.sfmt:
                softCamName = self.runningSoftCamName(True)
        elif self.type == self.SOFTCAMNAME:
            return self.runningSoftCamName()
        elif self.type == self.SOFTCAMFULLNAME:
            return self.runningSoftCamName(True)
        #
        if not service:
            return softCamName
        else:
            info = service and service.info()
            ecm_info = self.ecmfile()
            if not info: return softCamName
            elif not info.getInfoObject(iServiceInformation.sCAIDs):
                return _('Free-to-air')
            elif not ecm_info:
                return _("no data from the emulator")
            elif self.type == self.ECMFILECONTENT:
                return self.ecmfileContent()
            elif self.type == self.CAIDS:
                return '?'
            elif self.type == self.CRYPT2:
                self.poll_interval = self.my_interval
                self.poll_enabled = True
                info = service and service.info()
                if fileExists("/tmp/ecm.info"):
                    try:
                        caid = "%0.4X" % int(ecm_info.get("caid", ""), 16)
                        textvalue = "%s" % self.systemTxtCaids.get(caid[:2])
                    except Exception:
                        textvalue = _('nondecode')
                return textvalue
            else:
                self.poll_interval = self.my_interval
                self.poll_enabled = True
                # caid
                caid = "%0.4X" % int(ecm_info.get("caid", ""), 16)
                if self.type == self.CAID:
                    return caid
                # crypt
                if self.type == self.CRYPT:
                    return "%s" % self.systemTxtCaids.get(caid[:2].upper())
                #pid
                try:
                    pid = "%0.4X" % int(ecm_info.get("pid", ""), 16)
                except:
                    pid = ""
                if self.type == self.PID:
                    return pid
                # oscam
                try:
                    prov = "%0.6X" % int(ecm_info.get("prov", ""), 16)
                except Exception:
                    prov = ecm_info.get("prov", "")
                if self.type == self.PROV:
                    return prov
                if ecm_info.get("ecm time", "").find("msec") > -1:
                    ecm_time = ecm_info.get("ecm time", "")
                else:
                    ecm_time = ecm_info.get("ecm time", "").replace(
                        ".", "").lstrip("0") + " msec"
                if self.type == self.DELAY:
                    return ecm_time
                #protocol
                protocol = ecm_info.get("protocol", "")
                #port
                port = ecm_info.get("port", "")
                # source
                source = ecm_info.get("source", "")
                # server
                server = ecm_info.get("server", "")
                # hops
                hops = ecm_info.get("hops", "")
                #system
                system = ecm_info.get("system", "")
                #provider
                provider = ecm_info.get("provider", "")
                # reader
                reader = ecm_info.get("reader", "")
                if self.type == self.CRDTXT:
                    info_card = "False"
                    #oscam
                    if source == "sci":
                        info_card = "True"
                    #wicardd
                    if source != "cache" and source != "net" and source.find(
                            "emu") == -1:
                        info_card = "True"
                    return info_card
                if self.type == self.HOST:
                    return server
                if self.type == self.FORMAT or self.type == self.USE_CFG:
                    if self.type == self.USE_CFG:
                        self.sfmt = config.plugins.j00zekCC.ciFormat.value
                    textvalue = ""
                    params = self.sfmt.split(" ")

                    for param in params:
                        if param != '':
                            if param[0] != '%':
                                textvalue += param
                                #server
                            elif param == "%S":
                                textvalue += server
                                #hops
                            elif param == "%H":
                                textvalue += hops
                                #system
                            elif param == "%SY":
                                textvalue += system
                                #provider
                            elif param == "%PV":
                                textvalue += provider
                                #port
                            elif param == "%SP":
                                textvalue += port
                                #protocol
                            elif param == "%PR":
                                textvalue += protocol
                                #caid
                            elif param == "%C":
                                textvalue += caid
                                #Pid
                            elif param == "%P":
                                textvalue += pid
                                #prov
                            elif param == "%p":
                                textvalue += prov
                                #sOurce
                            elif param == "%O":
                                textvalue += source
                                #Reader
                            elif param == "%R":
                                textvalue += reader
                                #ECM Time
                            elif param == "%T":
                                textvalue += ecm_time
                                #SoftCamName
                            elif param == "%SCN":
                                textvalue += softCamName
                                #SoftCamFullName
                            elif param == "%SCFN":
                                textvalue += softCamName
                                #tabulator
                            elif param == "%t":
                                textvalue += "\t"
                                #new line
                            elif param == "%n":
                                textvalue += "\n"
                            elif param[1:].isdigit():
                                textvalue = textvalue.ljust(
                                    len(textvalue) + int(param[1:]))

                            if len(textvalue) > 0:
                                if textvalue[-1] != "\t" and textvalue[
                                        -1] != "\n":
                                    textvalue += " "
                    return textvalue[:-1]
                if self.type == self.ALL:
                    if source == "emu":
                        textvalue = "%s - %s (Prov: %s, Caid: %s)" % (
                            source, self.systemTxtCaids.get(
                                caid[:2]), prov, caid)
                    #new oscam ecm.info with port parametr
                    elif reader != "" and source == "net" and port != "":
                        textvalue = "%s - Prov: %s, Caid: %s, Reader: %s, %s (%s:%s) - %s" % (
                            source, prov, caid, reader, protocol, server, port,
                            ecm_time.replace('msec', 'ms'))
                    elif reader != "" and source == "net":
                        textvalue = "%s - Prov: %s, Caid: %s, Reader: %s, %s (%s) - %s" % (
                            source, prov, caid, reader, protocol, server,
                            ecm_time.replace('msec', 'ms'))
                    elif reader != "" and source != "net":
                        textvalue = "%s - Prov: %s, Caid: %s, Reader: %s, %s (local) - %s" % (
                            source, prov, caid, reader, protocol,
                            ecm_time.replace('msec', 'ms'))
                    elif server == "" and port == "" and protocol != "":
                        textvalue = "%s - Prov: %s, Caid: %s, %s - %s" % (
                            source, prov, caid, protocol,
                            ecm_time.replace('msec', 'ms'))
                    elif server == "" and port == "" and protocol == "":
                        textvalue = "%s - Prov: %s, Caid: %s - %s" % (
                            source, prov, caid, ecm_time.replace('msec', 'ms'))
                    else:
                        try:
                            textvalue = "%s - Prov: %s, Caid: %s, %s (%s:%s) - %s" % (
                                source, prov, caid, protocol, server, port,
                                ecm_time.replace('msec', 'ms'))
                        except Exception:
                            pass
                if self.type == self.SHORT:
                    if source == "emu":
                        textvalue = "%s - %s (Prov: %s, Caid: %s)" % (
                            source, self.systemTxtCaids.get(
                                caid[:2]), prov, caid)
                    elif server == "" and port == "":
                        textvalue = "%s - Prov: %s, Caid: %s - %s" % (
                            source, prov, caid, ecm_time.replace('msec', 'ms'))
                    else:
                        try:
                            textvalue = "%s - Prov: %s, Caid: %s, %s:%s - %s" % (
                                source, prov, caid, server, port,
                                ecm_time.replace('msec', 'ms'))
                        except Exception:
                            pass
        return textvalue