Example #1
0
    def ShowInfo(self):
        boxname = HardwareInfo().get_device_name()
        ram = []
        f = os.popen("free | grep 'Mem:'")
        ramtmp = f.readline().split()
        if ramtmp:
            r4 = '0%'
            r1 = str(int(ramtmp[1]) / 1024) + 'MB'
            r2 = str(int(ramtmp[2]) / 1024) + 'MB'
            r3 = str(int(ramtmp[3]) / 1024) + 'MB'
            if int(ramtmp[1]) > 0:
                r4 = str(int(ramtmp[2]) * 100 / int(ramtmp[1])) + '%'
            
            ram.append(r1)
            ram.append(r2)
            ram.append(r3)
            ram.append(r4)
        
        f.close()
        if len(ram) > 0:
            self['list2'].setList(ram)
        
        cache = []
        f = os.popen('cat /proc/meminfo |grep Cached')
        cachetmp = f.readline().split()
        if ramtmp:
            c2 = '-' + str(int(cachetmp[1]) / 1024) + 'MB'
            c3 = str(int(cachetmp[1]) / 1024) + 'MB'
            cache.append('    /')
            cache.append(c2)
            cache.append(c3)
            cache.append('    /')
        
        f.close()
        if len(cache) > 0:
            self['list10'].setList(cache)
        
        swap = []
        f = os.popen("free | grep 'Swap:'")
        swaptmp = f.readline().split()
        if swaptmp:
            s4 = '0%'
            s1 = str(int(swaptmp[1]) / 1024) + 'MB'
            s2 = str(int(swaptmp[2]) / 1024) + 'MB'
            s3 = str(int(swaptmp[3]) / 1024) + 'MB'
            if int(swaptmp[1]) > 0:
                s4 = str(int(swaptmp[2]) * 100 / int(swaptmp[1])) + '%'
            
            swap.append(s1)
            swap.append(s2)
            swap.append(s3)
            swap.append(s4)
        
        f.close()
        if len(swap) > 0:
            self['list3'].setList(swap)
        
        total = []
        t4 = '0%'
        t1 = (int(ramtmp[1]) + int(swaptmp[1])) / 1024
        t1a = str(t1) + 'MB'
        t2 = ((int(ramtmp[2]) - int(cachetmp[1])) + int(swaptmp[2])) / 1024
        t2a = str(t2) + 'MB'
        t3 = str((int(ramtmp[3]) + int(cachetmp[1]) + int(swaptmp[3])) / 1024) + 'MB'
        if t1 > 0:
            t4 = str(t2 * 100 / t1) + '%'
        
        total.append(t1a)
        total.append(t2a)
        total.append(t3)
        total.append(t4)
        if len(total) > 0:
            self['list4'].setList(total)
        
        f = os.popen('top -n1 | grep CPU:')
        cputmp = f.readline()
        f.close()
        
        try:
            ipos = cputmp.find(' sys')
            ipos1 = cputmp.find(' idle')
            self['infoM7'].setText(str(cputmp[:ipos + 4]))
            self['infoM8'].setText('CPU: ' + str(cputmp[ipos + 5:ipos1 + 5]))
        except Exception:
            print 'Error'

        if boxname == 'me' or boxname == 'minime':
            cmd = "df -h | grep 'mtd'"
        else:
            cmd = "df -h | grep '/dev/hda1'"
        nand = []
        f = os.popen(cmd)
        nandtmp = f.readline()
        f.close()
        ipos = 0
        
        try:
            ipos = nandtmp.find('/')
        except Exception:
            print 'Error'

        nand = nandtmp[5:ipos].split()
        self['list6'].setList(nand)
        uredi = []
        devpath = '/sys/block/'
        for ured in listdir(devpath):
            if (ured[:2] == 'sd' or ured[:2] == 'hd') and ured[:3] != 'hda':
                uredi.append('/dev/' + ured)
                continue
        uredi.sort()
        for i in range(0, 2):
            
            try:
                hddstate = 'drive state is:  unknown'
                cmd = 'hdparm -C ' + uredi[i]
                f = os.popen(cmd)
                hddstatetmp = f.readlines()
                f.close()
                for x in hddstatetmp:
                    ipos = x.find('drive state is:')
                    if ipos >= 0:
                        hddstate = x
                        continue
                if i == 0:
                    self['infoM10'].setText(str(uredi[i]))
                    self['infoM11'].setText(str(hddstate))
                
                if i == 1:
                    self['infoM12'].setText(str(uredi[i]))
                    self['infoM13'].setText(str(hddstate))
            except Exception:
                if i == 0:
                    self['infoM10'].setText('NC')
                    self['infoM11'].setText('')
                
                if i == 1:
                    self['infoM12'].setText('NC')
                    self['infoM13'].setText('')
                
                print 'err'

            
            try:
                cmd = 'df -h | grep ' + uredi[i]
                nand = []
                f = os.popen(cmd)
                nandtmp = f.readline()
                imedev = nandtmp[:9]
                nandtmp = nandtmp[9:]
                f.close()
                ipos = 0
                
                try:
                    ipos = nandtmp.find('/')
                except Exception:
                    nand = [
                        'NC']

                if len(nandtmp) > 0:
                    nand = nandtmp[:ipos].split()
                else:
                    nand = [
                        'NC']
                if i == 0:
                    self['list7'].setList(nand)
                    self['infoM5'].setText(str(imedev))
                
                if i == 1:
                    self['list8'].setList(nand)
                    self['infoM6'].setText(str(imedev))
            continue
            except Exception:
                if i == 0:
                    self['list7'].setList([
                        'NC'])
                
                if i == 1:
                    self['list8'].setList([
                        'NC'])
                
                i == 1
Example #2
0
    def StartScroll(self):
        
        try:
            self.slikahdd = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/hdd.png')
            self.slikahdd_temp = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/hdd_temp.png')
            self.slikaram = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/ram.png')
            self.slikaroot = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/root.png')
            self.slikasd = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/sd.png')
            self.slikasensor = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/sensor.png')
            self.slikasumm = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/summ.png')
            self.slikanand = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/nand.png')
            self.slikausb = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/usb.png')
            self.slikacpu = LoadPixmap('/usr/lib/enigma2/python/RTiTeam/RTiSySInfo/img/cpu.png')
            self['thn1'].instance.setPixmap(self.slikaram)
            self['thn12'].instance.setPixmap(self.slikaram)
            self['thn2'].instance.setPixmap(self.slikanand)
            self['thn3'].instance.setPixmap(self.slikasumm)
            self['thn4'].instance.setPixmap(self.slikanand)
            self['thn5'].instance.setPixmap(self.slikahdd)
            self['thn6'].instance.setPixmap(self.slikausb)
            self['thn7'].instance.setPixmap(self.slikacpu)
            self['thn8'].instance.setPixmap(self.slikahdd)
            self['thn9'].instance.setPixmap(self.slikausb)
            self['thn10'].instance.setPixmap(self.slikaroot)
            self['thn11'].instance.setPixmap(self.slikaroot)
        except:
            self['info'].setText('Loading pixmap error !')

        print 'ok'
        self['infoM1'].setText('RAM:')
        self['infoM16'].setText('Cache:')
        self['infoM2'].setText('Swap:')
        self['infoM3'].setText('Total:')
        self['infoM4'].setText('NAND :')
        self['infoM5'].setText('HDD1:')
        self['infoM6'].setText('USB:')
        boxname = HardwareInfo().get_device_name()
        if boxname == 'me':
            boxname1 = 'Me'
        
        if boxname == 'minime':
            boxname1 = 'miniMe'
        
        if boxname == 'elite':
            boxname1 = 'Elite'
        
        if boxname == 'premium':
            boxname1 = 'Premium'
        
        if boxname == 'premium+':
            boxname1 = 'Premium+'
        
        if boxname == 'ultra':
            boxname1 = 'Ultra'
        
        self['infoM15'].setText('Model: ' + boxname1)
        self['infoM9'].setText('LAN IP: 0.0.0.0')
        self['infoM14'].setText('WLAN IP: 0.0.0.0')
        f = os.popen('ifconfig')
        IPtmp = f.readlines()
        f.close()
        eth = 0
        for x in IPtmp:
            ipos = x.find('eth0')
            if ipos >= 0:
                eth = 1
            
            ipos = x.find('wlan0')
            if ipos >= 0:
                eth = 2
            
            ipos = x.find('lo')
            if ipos >= 0:
                eth = 3
            
            ipos = x.find('inet addr:')
            if ipos >= 0:
                ipos1 = x.find('Bcast')
                IP = x[ipos + 10:ipos1]
                if eth == 1:
                    self['infoM9'].setText('LAN IP:' + str(IP))
                
                if eth == 2:
                    self['infoM14'].setText('WLAN IP:' + str(IP))
                
            eth == 2