Exemplo n.º 1
0
    def Harddiskspace(self):
        print "Harddiskspace"
        list2 = []
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            if not parts:
                continue
            device = parts[3]
            if not search('sd[a-z][1-9]', device):
                continue
            if device in list2:
                continue

            mount = '/dev/' + device
            f = open('/proc/mounts', 'r')
            for line in f.readlines():
                if line.find(device) != -1:
                    parts = line.strip().split()
                    mount = str(parts[1])
                    break
                    continue
            f.close()

            if mount.startswith('/media/hdd'):
                size = Harddisk(device).diskSize() + 0.0
                free = Harddisk(device).free()
                used = size - free + 0.0
                Pused = int((used / size) * 100)
                return Pused

        return 0
Exemplo n.º 2
0
    def populate2(self):
        self.activityTimer.stop()
        self.Console = Console()
        niminfo = ''
        nims = nimmanager.nimList()
        for count in range(len(nims)):
            if niminfo:
                niminfo += '\n'
            niminfo += nims[count]

        self['nims'].setText(niminfo)
        self.list = []
        list2 = []
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            if not parts:
                continue
            device = parts[3]
            if not search('sd[a-z][1-9]', device):
                continue
            if device in list2:
                continue
            mount = '/dev/' + device
            f = open('/proc/mounts', 'r')
            for line in f.readlines():
                if device in line:
                    parts = line.strip().split()
                    mount = str(parts[1])
                    break

            f.close()
            if not mount.startswith('/dev/'):
                size = Harddisk(device).diskSize()
                free = Harddisk(device).free()
                if float(size) / 1024 / 1024 >= 1:
                    sizeline = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB')
                elif size / 1024 >= 1:
                    sizeline = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB')
                elif size >= 1:
                    sizeline = _('Size: ') + str(size) + _('MB')
                else:
                    sizeline = _('Size: ') + _('unavailable')
                if float(free) / 1024 / 1024 >= 1:
                    freeline = _('Free: ') + str(round(float(free) / 1024 / 1024, 2)) + _('TB')
                elif free / 1024 >= 1:
                    freeline = _('Free: ') + str(round(float(free) / 1024, 2)) + _('GB')
                elif free >= 1:
                    freeline = _('Free: ') + str(free) + _('MB')
                else:
                    freeline = _('Free: ') + _('full')
                self.list.append(mount + '\t' + sizeline + ' \t' + freeline)
            else:
                self.list.append(mount + '\t' + _('Not mounted'))
            list2.append(device)

        self.list = '\n'.join(self.list)
        self['hdd'].setText(self.list)
        self.Console.ePopen("df -mh | grep -v '^Filesystem'", self.Stage1Complete)
Exemplo n.º 3
0
	def format(self):
		if SystemInfo["HasSDmmc"]:
			self.TITLE = _("Init SDCARD")
			f = open('/sys/firmware/devicetree/base/chosen/bootargs', 'r').read()
			if "sda" in f:
				self.session.open(MessageBox, _("Multiboot manager - Cannot initialize SDcard when running image on SDcard."), MessageBox.TYPE_INFO, timeout=10)
				self.close
			else:
				sda ="sda"
				size = Harddisk(sda).diskSize()

				if ((float(size) / 1024) / 1024) >= 1:
					des = _("Size: ") + str(round(((float(size) / 1024) / 1024), 2)) + _("TB")
				elif (size / 1024) >= 1:
					des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
				if "GB" in des:
					print "Multibootmgr1", des, "%s" %des[6], size
					if size/1024 < 6:
						print "Multibootmgr2", des, "%s" %des[6], size/1024 
						self.session.open(MessageBox, _("Multiboot manager - The SDcard must be at least 8MB."), MessageBox.TYPE_INFO, timeout=10)
						self.close
					else:
						#IMAGE_ALIGNMENT=1024
						#KERNEL_PARTITION_SIZE=8192
						#ROOTFS_PARTITION_SIZE=2097152
						#PARTED_START_KERNEL2 = IMAGE_ALIGNMENT
						#PARTED_END_KERNEL2 = int(PARTED_START_KERNEL2) + int(KERNEL_PARTITION_SIZE)
						#PARTED_START_ROOTFS2 = PARTED_END_KERNEL2
						#PARTED_END_ROOTFS2 = int(PARTED_END_KERNEL2) + int(ROOTFS_PARTITION_SIZE)
						#PARTED_START_KERNEL3 = PARTED_END_ROOTFS2
						#PARTED_END_KERNEL3 = int(PARTED_END_ROOTFS2) + int(KERNEL_PARTITION_SIZE)
						#PARTED_START_ROOTFS3 = PARTED_END_KERNEL3
						#PARTED_END_ROOTFS3 = int(PARTED_END_KERNEL3) + int(ROOTFS_PARTITION_SIZE)

						self.session.open(MessageBox, _("Multiboot manager - SDcard initialization run, please restart your Image."), MessageBox.TYPE_INFO, timeout=10)
						cmdlist = []
						cmdlist.append("for n in /dev/%s* ; do umount $n ; done"%sda)
						cmdlist.append("for n in /dev/%s* ; do parted -s /dev/%s rm  ${n:8} ; done"%(sda,sda))
						cmdlist.append("partprobe")
						#cmdlist.append("parted -s /dev/%s mklabel gpt"%sda)
						#cmdlist.append("parted -s /dev/%s unit KiB mkpart kernel2 ext4 %s %s"%(sda,PARTED_START_KERNEL2,PARTED_END_KERNEL2))
						#cmdlist.append("parted -s /dev/%s unit KiB mkpart rootfs2 ext4 %s %s "%(sda,PARTED_START_ROOTFS2,PARTED_END_ROOTFS2))
						#cmdlist.append("parted -s /dev/%s unit KiB mkpart kernel3 ext4 %s %s"%(sda,PARTED_START_KERNEL3,PARTED_END_KERNEL3))
						#cmdlist.append("parted -s /dev/%s unit KiB mkpart rootfs3 ext4 %s %s "%(sda,PARTED_START_ROOTFS3,PARTED_END_ROOTFS3))
						#cmdlist.append("parted -s /dev/%s print free"%sda)
						cmdlist.append("dd if=/dev/zero of=/dev/%s bs=512 count=1 conv=notrunc"%sda)
						cmdlist.append("rm -f /tmp/init.sh")
						cmdlist.append("echo -e 'sfdisk /dev/%s <<EOF' >> /tmp/init.sh"%sda)
						cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
						cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
						cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
						cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
						cmdlist.append("echo -e 'EOF' >> /tmp/init.sh")
						cmdlist.append("chmod +x /tmp/init.sh")
						cmdlist.append("/tmp/init.sh")
						cmdlist.append("partprobe")
						self.session.open(Console, title = self.TITLE, cmdlist = cmdlist, closeOnSuccess = True)
		else:
			self.close()
Exemplo n.º 4
0
    def buildMy_rec(self, device):
        mypath = ItalysatGetSkinPath()
        device2 = re.sub('[0-9]', '', device)
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = _('HARD DISK: ')
        mypixmap = mypath + 'italy_icons/dev_hdd.png'
        model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('usb') != -1:
            name = _('USB: ')
            mypixmap = mypath + 'italy_icons/dev_usb.png'
        name += model
        d1 = _('None')
        dtype = _('unavailable')
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                d1 = parts[1]
                dtype = parts[2]
                break

        f.close()
        size = Harddisk(device).diskSize()
        if float(size) / 1024 / 1024 >= 1:
            des = _('Size: ') + str(round(float(size) / 1024 / 1024,
                                          2)) + _('TB')
        elif size / 1024 >= 1:
            des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB')
        elif size >= 1:
            des = _('Size: ') + str(size) + _('MB')
        else:
            des = _('Size: ') + _('unavailable')
        item = NoSave(
            ConfigSelection(default='/media/' + device,
                            choices=[('/media/' + device, '/media/' + device),
                                     ('/media/hdd', '/media/hdd'),
                                     ('/media/hdd2', '/media/hdd2'),
                                     ('/media/hdd3', '/media/hdd3'),
                                     ('/media/usb', '/media/usb'),
                                     ('/media/usb2', '/media/usb2'),
                                     ('/media/usb3', '/media/usb3')]))
        if d1 == '/media/italyboot':
            item = NoSave(
                ConfigSelection(default='/media/italyboot',
                                choices=[('/media/italyboot',
                                          '/media/italyboot')]))
        if dtype == 'Linux':
            dtype = 'ext3'
        else:
            dtype = 'auto'
        item.value = d1.strip()
        text = name + ' ' + des + ' /dev/' + device
        res = getConfigListEntry(text, item, device, dtype)
        if des != '' and self.list.append(res):
            pass
Exemplo n.º 5
0
	def format(self):
		if SystemInfo["HasSDmmc"]:
			self.TITLE = _("Init SDCARD")
			f = open('/sys/firmware/devicetree/base/chosen/bootargs', 'r').read()
			if "sda" in f:
				self.session.open(MessageBox, _("Multiboot manager - Cannot initialize SDcard when running image on SDcard."), MessageBox.TYPE_INFO, timeout=10)
				self.close
			else:
				sda ="sda"
				size = Harddisk(sda).diskSize()

				if ((float(size) / 1024) / 1024) >= 1:
					des = _("Size: ") + str(round(((float(size) / 1024) / 1024), 2)) + _("TB")
				elif (size / 1024) >= 1:
					des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
				if "GB" in des:
					print "Multibootmgr1", des, "%s" %des[6], size
					if size/1024 < 6:
						print "Multibootmgr2", des, "%s" %des[6], size/1024 
						self.session.open(MessageBox, _("Multiboot manager - The SDcard must be at least 8MB."), MessageBox.TYPE_INFO, timeout=10)
						self.close
					else:
						IMAGE_ALIGNMENT=1024
						KERNEL_PARTITION_SIZE=16384
						ROOTFS_PARTITION_SIZE=2097152
						PARTED_START_KERNEL2 = IMAGE_ALIGNMENT
						PARTED_END_KERNEL2 = int(PARTED_START_KERNEL2) + int(KERNEL_PARTITION_SIZE)
						PARTED_START_ROOTFS2 = PARTED_END_KERNEL2
						PARTED_END_ROOTFS2 = int(PARTED_END_KERNEL2) + int(ROOTFS_PARTITION_SIZE)
						PARTED_START_KERNEL3 = PARTED_END_ROOTFS2
						PARTED_END_KERNEL3 = int(PARTED_END_ROOTFS2) + int(KERNEL_PARTITION_SIZE)
						PARTED_START_ROOTFS3 = PARTED_END_KERNEL3
						PARTED_END_ROOTFS3 = int(PARTED_END_KERNEL3) + int(ROOTFS_PARTITION_SIZE)

						self.session.open(MessageBox, _("Multiboot manager - SDcard initialization run, please restart your Image."), MessageBox.TYPE_INFO, timeout=10)
						cmdlist = []
						cmdlist.append("for n in /dev/%s* ; do umount $n > /dev/null 2>&1 ; done"%sda)
						cmdlist.append("for n in /dev/%s* ; do parted -s /dev/%s rm  ${n:8} > /dev/null 2>&1; done"%(sda,sda))
						cmdlist.append("dd if=/dev/zero of=/dev/%s bs=512 count=10240 conv=notrunc"%sda)
						cmdlist.append("partprobe /dev/%s"%sda)
						cmdlist.append("parted -s /dev/%s mklabel gpt"%sda)
						cmdlist.append("parted -s /dev/%s unit KiB mkpart kernel2 ext2 %s %s"%(sda,PARTED_START_KERNEL2,PARTED_END_KERNEL2))
						cmdlist.append("parted -s /dev/%s unit KiB mkpart rootfs2 ext2 %s %s "%(sda,PARTED_START_ROOTFS2,PARTED_END_ROOTFS2))
						cmdlist.append("parted -s /dev/%s unit KiB mkpart kernel3 ext2 %s %s"%(sda,PARTED_START_KERNEL3,PARTED_END_KERNEL3))
						cmdlist.append("parted -s /dev/%s unit KiB mkpart rootfs3 ext2 %s %s "%(sda,PARTED_START_ROOTFS3,PARTED_END_ROOTFS3))
						cmdlist.append("parted -s /dev/%s unit KiB mkpart userdata ext2 %s 100%% "%(sda,PARTED_END_ROOTFS3))  ### Tech note: should be 95% for new mSD cards with discard"

						cmdlist.append("for n in /dev/%s{1..5} ; do mkfs.ext4 $n ; done"%sda)  ###  we should do kernels in ext2, but ok for small kernel partitions 

						cmdlist.append("partprobe /dev/%s"%sda)
						self.session.open(Console, title = self.TITLE, cmdlist = cmdlist, closeOnSuccess = True)
		else:
			self.close()
Exemplo n.º 6
0
    def updateHotplugDevices(self):
        self.hotplugServices = []
        print("[update hutplug]")
        try:
            from Components.Harddisk import Harddisk
            try:
                import commands
            except:
                import subprocess as commands
            movieConfig = MovieConfig()
            lines = commands.getoutput('mount | grep /dev/sd').split('\n')
            print(lines)
            for mount in lines:
                if len(mount) < 2:
                    continue
                m = mount.split(' type')[0].split(' on ')
                m_dev, m_path = m[0], m[1]
                label = os.path.split(m_path)[-1]
                blkid = commands.getoutput('blkid ' + m_dev).split("\"")
                if len(blkid) > 2 and blkid[1]:
                    label = blkid[1]
                if os.path.normpath(m_path) == "/media/hdd" or label in ("DUMBO", "TIMOTHY"):
                    continue
                if not movieConfig.isHiddenHotplug(label):
                    if m_path[-1] != "/":
                        m_path += "/"
                    service = eServiceReferenceHotplug(m_path)
                    hdd = Harddisk(m_dev.replace("/dev/", "")[:-1])
                    if label:
                        label += " - "
                    service.setName(label + hdd.model() + " - " + hdd.capacity())
                    self.hotplugServices.append(service)

            for callback in self.notifier:
                try:
                    callback()
                except:
                    printStackTrace()
        except:
            printStackTrace()
Exemplo n.º 7
0
 def updateHotplugDevices(self):
     self.hotplugServices = []
     print "[update hutplug]"
     try:
         from Components.Harddisk import Harddisk
         import commands
         movieConfig = MovieConfig()
         lines = commands.getoutput('mount | grep /dev/sd').split('\n')
         print lines
         for mount in lines:
             if len(mount) < 2:
                 continue
             m = mount.split(' type')[0].split(' on ')
             m_dev, m_path = m[0], m[1]
             label = os.path.split(m_path)[-1]
             blkid = commands.getoutput('blkid ' + m_dev).split("\"")
             if len(blkid) > 2 and blkid[1]:
                 label = blkid[1]
             if os.path.normpath(m_path) == "/media/hdd" or label in ("DUMBO", "TIMOTHY"):
                 continue
             if not movieConfig.isHiddenHotplug(label):
                 if m_path[-1] != "/":
                     m_path += "/"
                 service = eServiceReferenceHotplug(m_path)
                 hdd = Harddisk(m_dev.replace("/dev/", "")[:-1])
                 if label:
                     label += " - "
                 service.setName(label + hdd.model() + " - " + hdd.capacity())
                 self.hotplugServices.append(service)
         
         for callback in self.notifier:
             try:
                 callback()
             except:
                 printStackTrace()
     except:
         printStackTrace()
    def __init__(self, session):
        Screen.__init__(self, session)

        self["actions"] = ActionMap(["OkCancelActions"], {
            "cancel": self.Exit,
            "ok": self.Ok
        }, -1)

        #Blocklaufwerke
        self.device_uuid = None
        list = []
        for x in listdir("/sys/block"):
            if x[0:2] == 'sd' or x[0:2] == 'hd':
                print "[FlashExpander] device", x
                devices = Harddisk(x, False)
                for y in range(devices.numPartitions()):
                    fstype = self.__getPartitionType(
                        devices.partitionPath(str(y + 1)))
                    if fstype == False:
                        fstype = self.__getPartitionType(
                            devices.partitionPath(str(y + 1)))
                    try:
                        bustype = devices.bus_type()
                    except:
                        bustype = _("unknown")
                    if fstype in ("ext2", "ext3", "ext4", "xfs"):
                        list.append(("%s (%s) - Partition %d (%s)" %
                                     (devices.model(), bustype, y + 1, fstype),
                                     (devices, y + 1, fstype)))

        #Netzlaufwerke
        try:
            for x in getMountP():
                entry = x.split(' ')
                if len(entry) > 3 and entry[2] == "nfs":
                    server = entry[0].split(':')
                    if len(server) == 2:
                        print "[FlashExpander] server", server
                        list.append(("Server (%s) - Path (%s)" %
                                     (server[0], server[1]), server))
        except:
            print "[FlashExpander] <getMountPoints>"

        if len(list) == 0:
            list.append((_(
                "No HDD-, SSD- or USB-Device found. Please first initialized."
            ), None))

        self["list"] = MenuList(list=list)
        self.Console = Console()
Exemplo n.º 9
0
    def format(self):
        self.TITLE = _("Init SDCARD")
        sda = "sda"
        size = Harddisk(sda).diskSize()

        if ((float(size) / 1024) / 1024) >= 1:
            des = _("Size: ") + str(round(
                ((float(size) / 1024) / 1024), 2)) + _("TB")
        elif (size / 1024) >= 1:
            des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
        if "GB" in des:
            print "Multibootmgr1", des, "%s" % des[6], size
            if size / 1024 < 6:
                print "Multibootmgr2", des, "%s" % des[6], size / 1024
                self.session.open(
                    MessageBox,
                    _("Multiboot manager - The SDcard must be at least 8MB."),
                    MessageBox.TYPE_INFO,
                    timeout=10)
                self.close
            else:
                self.session.open(
                    MessageBox,
                    _("Multiboot manager - SDcard initialisation run, please restart OpenBH."
                      ),
                    MessageBox.TYPE_INFO,
                    timeout=10)
                cmdlist = []
                cmdlist.append(
                    "dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc")
                cmdlist.append("rm -f /tmp/init.sh")
                cmdlist.append(
                    "echo -e 'sfdisk /dev/sda <<EOF' >> /tmp/init.sh")
                cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
                cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
                cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
                cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
                cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
                cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
                cmdlist.append("echo -e 'EOF' >> /tmp/init.sh")
                cmdlist.append("chmod +x /tmp/init.sh")
                cmdlist.append("/tmp/init.sh")
                self.session.open(Console,
                                  title=self.TITLE,
                                  cmdlist=cmdlist,
                                  closeOnSuccess=True)
Exemplo n.º 10
0
	def doFormat(self, answer):
		if answer is True:
			from Components.Harddisk import Harddisk
			sda = "sda"
			size = Harddisk(sda).diskSize()
			if size/1024 < 7:
				self.session.open(MessageBox, _("Multiboot manager - The SDcard must be at least 8MB."), MessageBox.TYPE_INFO, timeout=10)
				self.close
			else:
				IMAGE_ALIGNMENT=1024
				KERNEL_PARTITION_SIZE=8192
				ROOTFS_PARTITION_SIZE=2097152
				PARTED_START_KERNEL2 = IMAGE_ALIGNMENT
				PARTED_END_KERNEL2 = int(PARTED_START_KERNEL2) + int(KERNEL_PARTITION_SIZE)
				PARTED_START_ROOTFS2 = PARTED_END_KERNEL2
				PARTED_END_ROOTFS2 = int(PARTED_END_KERNEL2) + int(ROOTFS_PARTITION_SIZE)
				PARTED_START_KERNEL3 = PARTED_END_ROOTFS2
				PARTED_END_KERNEL3 = int(PARTED_END_ROOTFS2) + int(KERNEL_PARTITION_SIZE)
				PARTED_START_ROOTFS3 = PARTED_END_KERNEL3
				PARTED_END_ROOTFS3 = int(PARTED_END_KERNEL3) + int(ROOTFS_PARTITION_SIZE)

				self.session.open(MessageBox, _("Multiboot manager - SDcard initialization run, please restart your Image."), MessageBox.TYPE_INFO, timeout=10)
				cmdlist = []
				cmdlist.append("for n in /dev/%s* ; do umount $n > /dev/null 2>&1 ; done"%sda)
				cmdlist.append("for n in /dev/%s* ; do parted -s /dev/%s rm  ${n:8} > /dev/null 2>&1; done"%(sda,sda))
				cmdlist.append("dd if=/dev/zero of=/dev/%s bs=512 count=10240 conv=notrunc"%sda)
				cmdlist.append("partprobe /dev/%s"%sda)
				cmdlist.append("parted -s /dev/%s mklabel gpt"%sda)
				cmdlist.append("parted -s /dev/%s unit KiB mkpart kernel2 ext2 %s %s"%(sda,PARTED_START_KERNEL2,PARTED_END_KERNEL2))
				cmdlist.append("parted -s /dev/%s unit KiB mkpart rootfs2 ext4 %s %s "%(sda,PARTED_START_ROOTFS2,PARTED_END_ROOTFS2))
				cmdlist.append("parted -s /dev/%s unit KiB mkpart kernel3 ext2 %s %s"%(sda,PARTED_START_KERNEL3,PARTED_END_KERNEL3))
				cmdlist.append("parted -s /dev/%s unit KiB mkpart rootfs3 ext4 %s %s "%(sda,PARTED_START_ROOTFS3,PARTED_END_ROOTFS3))
				cmdlist.append("parted -s /dev/%s unit KiB mkpart userdata ext4 %s 100%% "%(sda,PARTED_END_ROOTFS3))
				cmdlist.append("for n in /dev/%s{1..5} ; do mkfs.ext4 $n ; done"%sda)   
				cmdlist.append("partprobe /dev/%s"%sda)
				self.session.open(Console, title = self.TITLE, cmdlist = cmdlist, closeOnSuccess = True)
		else:
			self.close()
Exemplo n.º 11
0
	def format(self):
		if SystemInfo["HasSDmmc"]:
			self.TITLE = _("Init SDCARD")
			f = open('/sys/firmware/devicetree/base/chosen/bootargs', 'r').read()
			if "sda" in f:
				self.session.open(MessageBox, _("Multiboot manager - Cannot initialise SDcard when running image on SDcard"), MessageBox.TYPE_INFO, timeout=10)
				self.close
			else:
				sda ="sda"
				size = Harddisk(sda).diskSize()

				if ((float(size) / 1024) / 1024) >= 1:
					des = _("Size: ") + str(round(((float(size) / 1024) / 1024), 2)) + _("TB")
				elif (size / 1024) >= 1:
					des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
				if "GB" in des:
					print "Multibootmgr1", des, "%s" %des[6], size
					if size/1024 < 6:
						print "Multibootmgr2", des, "%s" %des[6], size/1024 
						self.session.open(MessageBox, _("Multiboot manager - The SDcard must be at least 8MB"), MessageBox.TYPE_INFO, timeout=10)
						self.close
					else:
						self.session.open(MessageBox, _("Multiboot manager - SDcard initialisation run, please restart OpenViX"), MessageBox.TYPE_INFO, timeout=10)
						cmdlist = []
						cmdlist.append("dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc")
						cmdlist.append("rm -f /tmp/init.sh")
						cmdlist.append("echo -e 'sfdisk /dev/sda <<EOF' >> /tmp/init.sh")
						cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
						cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
						cmdlist.append("echo -e ',8M' >> /tmp/init.sh")
						cmdlist.append("echo -e ',2048M' >> /tmp/init.sh")
						cmdlist.append("echo -e 'EOF' >> /tmp/init.sh")
						cmdlist.append("chmod +x /tmp/init.sh")
						cmdlist.append("/tmp/init.sh")
						self.session.open(Console, title = self.TITLE, cmdlist = cmdlist, closeOnSuccess = True)
		else:
			self.close()
Exemplo n.º 12
0
    def __init__(self, session):
        Screen.__init__(self, session)

        self["actions"] = ActionMap(["OkCancelActions"], {"cancel": self.Exit, "ok": self.Ok}, -1)

        # Blocklaufwerke
        list = []
        for x in listdir("/sys/block"):
            if x[0:2] == "sd" or x[0:2] == "hd":
                print "[FlashExpander] device", x
                devices = Harddisk(x)
                for y in range(devices.numPartitions()):
                    fstype = self.__getPartitionType(devices.partitionPath(str(y + 1)))
                    if fstype == False:
                        fstype = self.__getPartitionType(devices.partitionPath(str(y + 1)))
                    try:
                        bustype = devices.bus_type()
                    except:
                        bustype = _("unknown")
                    if fstype in ("ext2", "ext3", "ext4", "xfs"):
                        list.append(
                            (
                                "%s (%s) - Partition %d (%s)" % (devices.model(), bustype, y + 1, fstype),
                                (devices, y + 1, fstype),
                            )
                        )

                        # Netzlaufwerke
        try:
            for x in getMountP():
                entry = x.split(" ")
                if len(entry) > 3 and entry[2] == "nfs":
                    server = entry[0].split(":")
                    if len(server) == 2:
                        print "[FlashExpander] server", server
                        list.append(("Server (%s) - Path (%s)" % (server[0], server[1]), server))
        except:
            print "[FlashExpander] <getMountPoints>"

        if len(list) == 0:
            list.append((_("No HDD-, SSD- or USB-Device found. Please first initialized."), None))

        self["list"] = MenuList(list=list)
        self.Console = Console()
Exemplo n.º 13
0
    def buildMy_rec(self, device):
        device2 = re.sub('[0-9]', '', device)
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = _("HARD DISK: ")
        if path.exists(
                resolveFilename(SCOPE_ACTIVE_SKIN, "vixcore/dev_hdd.png")):
            mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN,
                                       "vixcore/dev_hdd.png")
        else:
            mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/images/dev_hdd.png'
        model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('usb') != -1:
            name = _('USB: ')
            if path.exists(
                    resolveFilename(SCOPE_ACTIVE_SKIN, "vixcore/dev_usb.png")):
                mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN,
                                           "vixcore/dev_usb.png")
            else:
                mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/images/dev_usb.png'
        name += model
        self.Console.ePopen(
            "sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp"
        )
        sleep(0.5)
        f = open('/tmp/devices.tmp', 'r')
        swapdevices = f.read()
        f.close()
        if path.exists('/tmp/devices.tmp'):
            remove('/tmp/devices.tmp')
        swapdevices = swapdevices.replace('\n', '')
        swapdevices = swapdevices.split('/')
        f = open('/proc/mounts', 'r')
        d1 = _("None")
        dtype = _("unavailable")
        rw = _("None")
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                d1 = parts[1]
                dtype = parts[2]
                rw = parts[3]
                break
            else:
                if device in swapdevices:
                    parts = line.strip().split()
                    d1 = _("None")
                    dtype = 'swap'
                    rw = _("None")
                    break
        f.close()
        size = Harddisk(device).diskSize()

        if ((float(size) / 1024) / 1024) >= 1:
            des = _("Size: ") + str(round(
                ((float(size) / 1024) / 1024), 2)) + _("TB")
        elif (size / 1024) >= 1:
            des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
        elif size >= 1:
            des = _("Size: ") + str(size) + _("MB")
        else:
            des = _("Size: ") + _("unavailable")

        if des != '':
            if rw.startswith('rw'):
                rw = ' R/W'
            elif rw.startswith('ro'):
                rw = ' R/O'
            else:
                rw = ""
            des += '\t' + _("Mount: ") + d1 + '\n' + _(
                "Device: ") + '/dev/' + device + '\t' + _(
                    "Type: ") + dtype + rw
            png = LoadPixmap(mypixmap)
            res = (name, des, png)
            self.list.append(res)
Exemplo n.º 14
0
	def buildMy_rec(self, device):
		if re.search('mmcblk[0-9]p[0-9][0-9]', device):
			device2 = re.sub('p[0-9][0-9]', '', device)
		elif re.search('mmcblk[0-9]p[0-9]', device):
			device2 = re.sub('p[0-9]', '', device)
		else:
			device2 = re.sub('[0-9]', '', device)
		devicetype = path.realpath('/sys/block/' + device2 + '/device')
		if devicetype.find('mmc') != -1 and (devicetype.find('rdb') != -1 or (devicetype.find('soc') != -1 and  not SystemInfo["HasSDnomount"])):
			return
		if  SystemInfo["HasSDnomount"]:											# h9/i55 use mmcblk0p[0-3] for sdcard, h9combo uses mmcblk1p[0-3]
			if SystemInfo["HasSDnomount"][0] == 'Yes' and "%s" %SystemInfo["HasSDnomount"][1] in device:
				return
		d2 = device
		name = _("HARD DISK: ")
		if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_hdd.png")):
			mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_hdd.png")
		else:
			mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/OBH/images/dev_hdd.png'
		if pathExists('/sys/block/' + device2 + '/device/model'):
			model = file('/sys/block/' + device2 + '/device/model').read()
		elif pathExists('/sys/block/' + device2 + '/device/name'):
			model = file('/sys/block/' + device2 + '/device/name').read()
		model = str(model).replace('\n', '')
		des = ''
		if devicetype.find('usb') != -1:
			name = _('USB: ')
			if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_usb.png")):
				mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_usb.png")
			else:
				mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/OBH/images/dev_usb.png'
		elif devicetype.find('mmc') != -1:
			name = _('SDCARD: ')
			if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_sd.png")):
				mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_sd.png")
			else:
				mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/OBH/images/dev_sd.png'
		name += model
		d1 = _("None")
		dtype = _("unavailable")
		f = open('/proc/mounts', 'r')
		for line in f.readlines():
			if line.find(device) != -1:
				parts = line.strip().split()
				d1 = parts[1]
				dtype = parts[2]
				break
		f.close()

		size = Harddisk(device).diskSize()
		if ((float(size) / 1024) / 1024) >= 1:
			des = _("Size: ") + str(round(((float(size) / 1024) / 1024), 2)) + _("TB")
		elif (size / 1024) >= 1:
			des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
		elif size >= 1:
			des = _("Size: ") + str(size) + _("MB")
		else:
			des = _("Size: ") + _("unavailable")

		item = NoSave(ConfigSelection(default='/media/' + device, choices=[('/media/' + device, '/media/' + device),
																		   ('/media/hdd', '/media/hdd'),
																		   ('/media/hdd2', '/media/hdd2'),
																		   ('/media/hdd3', '/media/hdd3'),
																		   ('/media/usb', '/media/usb'),
																		   ('/media/usb2', '/media/usb2'),
																		   ('/media/usb3', '/media/usb3'),
																		   ('/media/sdcard', '/media/sdcard')]))
		if dtype == 'Linux':
			dtype = 'ext4'
		else:
			dtype = 'auto'
		item.value = d1.strip()
		text = name + ' ' + des + ' /dev/' + device
		res = getConfigListEntry(text, item, device, dtype)

		if des != '' and self.list.append(res):
			pass
Exemplo n.º 15
0
	def buildMy_rec(self, device):
		if re.search('mmcblk[0-9]p[0-9][0-9]', device):
			device2 = re.sub('p[0-9][0-9]', '', device)
		elif re.search('mmcblk[0-9]p[0-9]', device):
			device2 = re.sub('p[0-9]', '', device)
		else:
			device2 = re.sub('[0-9]', '', device)
		devicetype = path.realpath('/sys/block/' + device2 + '/device')
		if devicetype.find('mmc') != -1 and (devicetype.find('rdb') != -1 or (devicetype.find('soc') != -1 and  not SystemInfo["HasSDnomount"])):
			return
		if  SystemInfo["HasSDnomount"]:											# h9/i55 use mmcblk0p[0-3] for sdcard, h9combo uses mmcblk1p[0-3]
			if SystemInfo["HasSDnomount"][0] == 'Yes' and "%s" %SystemInfo["HasSDnomount"][1] in device:
				return
		d2 = device
		name = _("HARD DISK: ")
		if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_hdd.png")):
			mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_hdd.png")
		else:
			mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/OBH/images/dev_hdd.png'
		if pathExists('/sys/block/' + device2 + '/device/model'):
			model = file('/sys/block/' + device2 + '/device/model').read()
		elif pathExists('/sys/block/' + device2 + '/device/name'):
			model = file('/sys/block/' + device2 + '/device/name').read()
		model = str(model).replace('\n', '')
		des = ''
		if devicetype.find('usb') != -1:
			name = _('USB: ')
			if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_usb.png")):
				mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_usb.png")
			else:
				mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/OBH/images/dev_usb.png'
		elif devicetype.find('mmc') != -1:
			name = _('SDCARD: ')
			if path.exists(resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_sd.png")):
				mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN, "obhcore/dev_sd.png")
			else:
				mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/OBH/images/dev_sd.png'
		name += model
		# self.Console.ePopen("sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp")
		# sleep(0.5)
		# f = open('/tmp/devices.tmp', 'r')
		# swapdevices = f.read()
		# f.close()
		# if path.exists('/tmp/devices.tmp'):
		# 	remove('/tmp/devices.tmp')
		# swapdevices = swapdevices.replace('\n', '')
		# swapdevices = swapdevices.split('/')
		f = open('/proc/mounts', 'r')
		d1 = _("None")
		dtype = _("unavailable")
		rw = _("None")
		for line in f.readlines():
			if line.find(device) != -1:
				parts = line.strip().split()
				d1 = parts[1]
				dtype = parts[2]
				rw = parts[3]
				break
			# else:
			# 	if device in swapdevices:
			# 		parts = line.strip().split()
			# 		d1 = _("None")
			# 		dtype = 'swap'
			# 		rw = _("None")
			# 		break
		f.close()
		size = Harddisk(device).diskSize()

		if ((float(size) / 1024) / 1024) >= 1:
			des = _("Size: ") + str(round(((float(size) / 1024) / 1024), 2)) + _("TB")
		elif (size / 1024) >= 1:
			des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
		elif size >= 1:
			des = _("Size: ") + str(size) + _("MB")
		else:
			des = _("Size: ") + _("unavailable")

		if des != '':
			if rw.startswith('rw'):
				rw = ' R/W'
			elif rw.startswith('ro'):
				rw = ' R/O'
			else:
				rw = ""
			des += '\t' + _("Mount: ") + d1 + '\n' + _("Device: ") + '/dev/' + device + '\t' + _("Type: ") + dtype + rw
			png = LoadPixmap(mypixmap)
			res = (name, des, png)
			self.list.append(res)
Exemplo n.º 16
0
	def populate2(self):
		self.activityTimer.stop()
		self.Console = Console()
		niminfo = ""
		nims = nimmanager.nimList()
		for count in range(len(nims)):
			if niminfo:
				niminfo += "\n"
			niminfo += nims[count]
		self["nims"].setText(niminfo)

		self.list = []
		list2 = []
		f = open('/proc/partitions', 'r')
		for line in f.readlines():
			parts = line.strip().split()
			if not parts:
				continue
			device = parts[3]
			if not search('sd[a-z][1-9]', device):
				continue
			if device in list2:
				continue

			mount = '/dev/' + device
			f = open('/proc/mounts', 'r')
			for line in f.readlines():
				if device in line:
					parts = line.strip().split()
					mount = str(parts[1])
					break
			f.close()

			if not mount.startswith('/dev/'):
				size = Harddisk(device).diskSize()
				free = Harddisk(device).free()

				if ((float(size) / 1024) / 1024) >= 1:
					sizeline = _("Size: ") + str(round(((float(size) / 1024) / 1024), 2)) + " " + _("TB")
				elif (size / 1024) >= 1:
					sizeline = _("Size: ") + str(round((float(size) / 1024), 2)) +  " " + _("GB")
				elif size >= 1:
					sizeline = _("Size: ") + str(size) +  " " + _("MB")
				else:
					sizeline = _("Size: ") + _("unavailable")

				if ((float(free) / 1024) / 1024) >= 1:
					freeline = _("Free: ") + str(round(((float(free) / 1024) / 1024), 2)) +  " " + _("TB")
				elif (free / 1024) >= 1:
					freeline = _("Free: ") + str(round((float(free) / 1024), 2)) +  " " + _("GB")
				elif free >= 1:
					freeline = _("Free: ") + str(free) +  " " + _("MB")
				else:
					freeline = _("Free: ") + _("full")
				self.list.append(mount + '\t' + sizeline + ' \t' + freeline)
			else:
				self.list.append(mount + '\t' + _('Not mounted'))

			list2.append(device)
		self.list = '\n'.join(self.list)
		self["hdd"].setText(self.list)
		self["allinonedevices"].setText(
			self["TunerHeader"].getText() + "\n\n" +
			self["nims"].getText() + "\n\n" +
			self["HDDHeader"].getText() + "\n\n" +
			self["hdd"].getText() + "\n\n"
			)

		self.Console.ePopen("df -mh | grep -v '^Filesystem'", self.Stage1Complete)
Exemplo n.º 17
0
    def populate2(self):
        self.activityTimer.stop()
        self.Console = Console()

        self.AboutText = _("Model:\t%s %s\n") % (getMachineBrand(),
                                                 getMachineName())
        self.AboutText += "\n" + _("Detected NIMs:") + "\n"

        nims = nimmanager.nimList()
        for count in range(len(nims)):
            if count < 4:
                self["Tuner" + str(count)] = StaticText(nims[count])
            else:
                self["Tuner" + str(count)] = StaticText("")
            self.AboutText += nims[count] + "\n"

        self.AboutText += "\n" + _("Detected HDD:") + "\n"

        self.list = []
        list2 = []
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            if not parts:
                continue
            device = parts[3]
            if not search('sd[a-z][1-9]', device):
                continue
            if device in list2:
                continue

            mount = '/dev/' + device
            f = open('/proc/mounts', 'r')
            for line in f.readlines():
                if device in line:
                    parts = line.strip().split()
                    mount = str(parts[1])
                    break
            f.close()

            if not mount.startswith('/dev/'):
                size = Harddisk(device).diskSize()
                free = Harddisk(device).free()

                if ((float(size) / 1024) / 1024) >= 1:
                    sizeline = _("Size: ") + str(
                        round(
                            ((float(size) / 1024) / 1024), 2)) + " " + _("TB")
                elif (size / 1024) >= 1:
                    sizeline = _("Size: ") + str(round(
                        (float(size) / 1024), 2)) + " " + _("GB")
                elif size >= 1:
                    sizeline = _("Size: ") + str(size) + " " + _("MB")
                else:
                    sizeline = _("Size: ") + _("unavailable")

                if ((float(free) / 1024) / 1024) >= 1:
                    freeline = _("Free: ") + str(
                        round(
                            ((float(free) / 1024) / 1024), 2)) + " " + _("TB")
                elif (free / 1024) >= 1:
                    freeline = _("Free: ") + str(round(
                        (float(free) / 1024), 2)) + " " + _("GB")
                elif free >= 1:
                    freeline = _("Free: ") + str(free) + " " + _("MB")
                else:
                    freeline = _("Free: ") + _("full")
                self.list.append(mount + '\t' + sizeline + ' \t' + freeline)
            else:
                self.list.append(mount + '\t' + _('Not mounted'))

            list2.append(device)
        self.list = '\n'.join(self.list)

        self.AboutText += self.list + "\n"
        self.AboutText += "\n" + _("Network Servers:") + "\n"
        #self.mountinfo = _("none")
        self.Console.ePopen("df -mh | grep -v '^Filesystem'",
                            self.Stage1Complete)
Exemplo n.º 18
0
    def buildMy_rec(self, device):
        device2 = re.sub('[0-9]', '', device)
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = _("HARD DISK: ")
        if path.exists(
                resolveFilename(SCOPE_ACTIVE_SKIN, "vixcore/dev_hdd.png")):
            mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN,
                                       "vixcore/dev_hdd.png")
        else:
            mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/images/dev_hdd.png'
        model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('usb') != -1:
            name = _('USB: ')
            if path.exists(
                    resolveFilename(SCOPE_ACTIVE_SKIN, "vixcore/dev_usb.png")):
                mypixmap = resolveFilename(SCOPE_ACTIVE_SKIN,
                                           "vixcore/dev_usb.png")
            else:
                mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/ViX/images/dev_usb.png'
        name += model
        d1 = _("None")
        dtype = _("unavailable")
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                d1 = parts[1]
                dtype = parts[2]
                break
        f.close()

        size = Harddisk(device).diskSize()
        if ((float(size) / 1024) / 1024) >= 1:
            des = _("Size: ") + str(round(
                ((float(size) / 1024) / 1024), 2)) + _("TB")
        elif (size / 1024) >= 1:
            des = _("Size: ") + str(round((float(size) / 1024), 2)) + _("GB")
        elif size >= 1:
            des = _("Size: ") + str(size) + _("MB")
        else:
            des = _("Size: ") + _("unavailable")

        item = NoSave(
            ConfigSelection(default='/media/' + device,
                            choices=[('/media/' + device, '/media/' + device),
                                     ('/media/hdd', '/media/hdd'),
                                     ('/media/hdd2', '/media/hdd2'),
                                     ('/media/hdd3', '/media/hdd3'),
                                     ('/media/usb', '/media/usb'),
                                     ('/media/usb2', '/media/usb2'),
                                     ('/media/usb3', '/media/usb3')]))
        if dtype == 'Linux':
            dtype = 'ext3'
        else:
            dtype = 'auto'
        item.value = d1.strip()
        text = name + ' ' + des + ' /dev/' + device
        res = getConfigListEntry(text, item, device, dtype)

        if des != '' and self.list.append(res):
            pass
Exemplo n.º 19
0
    def populate2(self):
        self.activityTimer.stop()
        self.Console = Console()
        niminfo = ""
        nims = nimmanager.nimListCompressed()
        for count in range(len(nims)):
            if niminfo:
                niminfo += "\n"
            niminfo += nims[count]
        self["nims"].setText(niminfo)

        nims = nimmanager.nimList()
        if len(nims) <= 4:
            for count in (0, 1, 2, 3):
                if count < len(nims):
                    self["Tuner" + str(count)].setText(nims[count])
                else:
                    self["Tuner" + str(count)].setText("")
        else:
            desc_list = []
            count = 0
            cur_idx = -1
            while count < len(nims):
                data = nims[count].split(":")
                idx = data[0].strip('Tuner').strip()
                desc = data[1].strip()
                if desc_list and desc_list[cur_idx]['desc'] == desc:
                    desc_list[cur_idx]['end'] = idx
                else:
                    desc_list.append({'desc': desc, 'start': idx, 'end': idx})
                    cur_idx += 1
                count += 1

            for count in (0, 1, 2, 3):
                if count < len(desc_list):
                    if desc_list[count]['start'] == desc_list[count]['end']:
                        text = "Tuner %s: %s" % (desc_list[count]['start'],
                                                 desc_list[count]['desc'])
                    else:
                        text = "Tuner %s-%s: %s" % (desc_list[count]['start'],
                                                    desc_list[count]['end'],
                                                    desc_list[count]['desc'])
                else:
                    text = ""

                self["Tuner" + str(count)].setText(text)

        self.list = []
        list2 = []
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            parts = line.strip().split()
            if not parts:
                continue
            device = parts[3]
            if not search('sd[a-z][1-9]', device):
                continue
            if device in list2:
                continue

            mount = '/dev/' + device
            f = open('/proc/mounts', 'r')
            for line in f.readlines():
                if device in line:
                    parts = line.strip().split()
                    mount = str(parts[1])
                    break
            f.close()

            if not mount.startswith('/dev/'):
                size = Harddisk(device).diskSize()
                free = Harddisk(device).free()

                if ((float(size) / 1024) / 1024) >= 1:
                    sizeline = _("Size: ") + str(
                        round(((float(size) / 1024) / 1024), 2)) + _("TB")
                elif (size / 1024) >= 1:
                    sizeline = _("Size: ") + str(round(
                        (float(size) / 1024), 2)) + _("GB")
                elif size >= 1:
                    sizeline = _("Size: ") + str(size) + _("MB")
                else:
                    sizeline = _("Size: ") + _("unavailable")

                if ((float(free) / 1024) / 1024) >= 1:
                    freeline = _("Free: ") + str(
                        round(((float(free) / 1024) / 1024), 2)) + _("TB")
                elif (free / 1024) >= 1:
                    freeline = _("Free: ") + str(round(
                        (float(free) / 1024), 2)) + _("GB")
                elif free >= 1:
                    freeline = _("Free: ") + str(free) + _("MB")
                else:
                    freeline = _("Free: ") + _("full")
                self.list.append(mount + '\t' + sizeline + ' \t' + freeline)
            else:
                self.list.append(mount + '\t' + _('Not mounted'))

            list2.append(device)
        self.list = '\n'.join(self.list)
        self["hdd"].setText(self.list)

        self.Console.ePopen("df -mh | grep -v '^Filesystem'",
                            self.Stage1Complete)
Exemplo n.º 20
0
    def buildMy_rec(self, device):
        mypath = DeliteGetSkinPath()
        device2 = re.sub('[0-9]', '', device)
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = _('HARD DISK: ')
        mypixmap = mypath + 'icons/dev_hdd.png'
        model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('usb') != -1:
            name = _('USB: ')
            mypixmap = mypath + 'icons/dev_usb.png'
        name = name + model
        self.Console = Console()
        self.Console.ePopen("sfdisk -l /dev/sd? | grep swap | awk '{print $(NF-9)}' >/tmp/devices.tmp")
        sleep(0.5)
        f = open('/tmp/devices.tmp', 'r')
        swapdevices = f.read()
        f.close()
        if path.exists('/tmp/devices.tmp'):
            remove('/tmp/devices.tmp')
        swapdevices = swapdevices.replace('\n', '')
        swapdevices = swapdevices.split('/')
        f = open('/proc/mounts', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                d1 = parts[1]
                dtype = parts[2]
                rw = parts[3]
                break
                continue
            elif device in swapdevices:
                parts = line.strip().split()
                d1 = _('None')
                dtype = 'swap'
                rw = _('None')
                break
                continue
            else:
                d1 = _('None')
                dtype = _('unavailable')
                rw = _('None')

        f.close()
        size = Harddisk(device).diskSize()
        if float(size) / 1024 / 1024 >= 1:
            des = _('Size: ') + str(round(float(size) / 1024 / 1024, 2)) + _('TB')
        elif size / 1024 >= 1:
            des = _('Size: ') + str(round(float(size) / 1024, 2)) + _('GB')
        elif size >= 1:
            des = _('Size: ') + str(size) + _('MB')
        else:
            des = _('Size: ') + _('unavailable')
        if des != '':
            if rw.startswith('rw'):
                rw = ' R/W'
            elif rw.startswith('ro'):
                rw = ' R/O'
            else:
                rw = ''
            des += '\t' + _('Mount: ') + d1 + '\n' + _('Device: ') + '/dev/' + device + '\t' + _('Type: ') + dtype + rw
            png = LoadPixmap(mypixmap)
            res = (name, des, png)
            self.list.append(res)