Ejemplo n.º 1
0
	def updateList(self):
		self.list = []

		if fileExists("/tmp/bhspeed.tmp"):
			os_remove("/tmp/bhspeed.tmp")

		for plug in self.pluglist:
			cmd = "opkg status %s >> /tmp/bhspeed.tmp" % (plug[1])
			system(cmd)

		for plug in self.pluglist:
			item = NoSave(ConfigSelection(default="Enabled", choices=[("Enabled", _("Enabled")), ("Disabled", _("Disabled"))]))
			installed = self.checkInst(plug[1])
			if installed == True:
				item.value = "Enabled"
			else:
				item.value = "Disabled"

			res = getConfigListEntry(plug[0], item)
			self.list.append(res)

		self["config"].list = self.list
		self["config"].l.setList(self.list)

		self["lab1"].setText(_("Please disable ALL the plugins you don't need to use.\nThis will Speed Up Image Performance."))
Ejemplo n.º 2
0
	def updateList(self):
		self.list = []
		
		if fileExists("/tmp/bhspeed.tmp"):
			os_remove("/tmp/bhspeed.tmp")
		
		for plug in self.pluglist:
			cmd = "opkg status %s >> /tmp/bhspeed.tmp" % (plug[1])
			system(cmd)
		
		for plug in self.pluglist:
			item = NoSave(ConfigSelection(default = "Enabled", choices = [("Enabled", _("Enabled")), ("Disabled", _("Disabled"))]))
			installed = self.checkInst(plug[1])
			if installed == True:
				item.value = "Enabled"
			else:
				item.value = "Disabled"
			
			res = getConfigListEntry(plug[0], item)
			self.list.append(res)
		
		self["config"].list = self.list
		self["config"].l.setList(self.list)
		
		self["lab1"].setText(_("Please disable ALL the plugins you don't need to use.\nThis will Speed Up Image Performance."))
Ejemplo n.º 3
0
    def updateList(self):
        self.list = []
        mylist = []
        sorted_dict = {}
        f = open('/etc/bh_plugins.pos', 'rb')
        for line in f.readlines():
            d = line.split(':', 1)
            if len(d) > 1:
                sorted_dict[d[0].strip()] = int(d[1].strip())
            f.close()

        self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
        for plugin in self.pluginlist:
            pos = sorted_dict.get(plugin.name, 99)
            res = (plugin.name, pos)
            mylist.append(res)

        mylist2 = sorted(mylist, key=itemgetter(1))
        for x in mylist2:
            item = NoSave(ConfigInteger(limits=(1, 99), default=99))
            item.value = x[1]
            res = getConfigListEntry(x[0], item)
            self.list.append(res)

        self['config'].list = self.list
        self['config'].l.setList(self.list)
Ejemplo n.º 4
0
    def updateList(self):
        self.list = []
        mylist = []
        sorted_dict = {}
        f = open('/etc/bh_plugins.pos', 'rb')
        for line in f.readlines():
            d = line.split(':', 1)
            if len(d) > 1:
                sorted_dict[d[0].strip()] = int(d[1].strip())
            f.close()

        self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
        for plugin in self.pluginlist:
            pos = sorted_dict.get(plugin.name, 99)
            res = (plugin.name, pos)
            mylist.append(res)

        mylist2 = sorted(mylist, key=itemgetter(1))
        for x in mylist2:
            item = NoSave(ConfigInteger(limits=(1, 99), default=99))
            item.value = x[1]
            res = getConfigListEntry(x[0], item)
            self.list.append(res)

        self['config'].list = self.list
        self['config'].l.setList(self.list)
Ejemplo n.º 5
0
    def buildMy_rec(self, device):
        mypath = SkinPath()
        device2 = re.sub('[0-9]', '', device)
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = _('HARD DISK: ')
        mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/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: ')
            mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/dev_usb.png'
        if devicetype.find('usb1') != -1:
            name = _('USB1: ')
            mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/dev_usb.png'
        if devicetype.find('usb2') != -1:
            name = _('USB2: ')
            mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/NeoBoot/images/dev_usb.png'            
        name = name + model
        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
                continue
            else:
                d1 = _('None')
                dtype = _('unavailable')

        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/usb1', '/media/usb1'),
         ('/media/usb2', '/media/usb2'),
         ('/media/usb3', '/media/usb3')]))
        if dtype == 'Linux':
            dtype = 'ext2', 'ext3', '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
Ejemplo n.º 6
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
Ejemplo n.º 7
0
	def updateList(self):
		self.list = []
		for device in self.devices:
			item = NoSave(ConfigSelection(default = "No mapeado", choices = self.get_Choices()))
			item.value = self.get_currentPoint(device[1])
			res = getConfigListEntry(device[0], item, device[1])
			self.list.append(res)

		self["config"].list = self.list
		self["config"].l.setList(self.list)
		self["Linconn"].hide()
Ejemplo n.º 8
0
	def updateList(self):
		self.list = []
		for device in self.devices:
			item = NoSave(ConfigSelection(default = "Not mapped", choices = self.get_Choices()))
			item.value = self.get_currentPoint(device[1])
			res = getConfigListEntry(device[0], item, device[1])
			self.list.append(res)
		
		self["config"].list = self.list
		self["config"].l.setList(self.list)
		self["Linconn"].hide()
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
0
    def buildMy_rec(self, device):
        global device2
        try:
            if device.find('1') > 0:
                device2 = device.replace('1', '')
        except:
            device2 = ''
        try:
            if device.find('2') > 0:
                device2 = device.replace('2', '')
        except:
            device2 = ''
        try:
            if device.find('3') > 0:
                device2 = device.replace('3', '')
        except:
            device2 = ''
        try:
            if device.find('4') > 0:
                device2 = device.replace('4', '')
        except:
            device2 = ''
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = _("USB: ")
        model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('/devices/pci') != -1:
            name = _("HARD DISK: ")
        name = name + model
        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
                continue
            else:
                d1 = _("None")
                dtype = _("unavailable")
        f.close()
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                size = int(parts[2])
                if (((float(size) / 1024) / 1024) / 1024) > 1:
                    des = _("Size: ") + str(
                        round(((
                            (float(size) / 1024) / 1024) / 1024), 2)) + _("TB")
                elif ((size / 1024) / 1024) > 1:
                    des = _("Size: ") + str((size / 1024) / 1024) + _("GB")
                else:
                    des = _("Size: ") + str(size / 1024) + _("MB")
            else:
                try:
                    size = file('/sys/block/' + device2 + '/' + device +
                                '/size').read()
                    size = str(size).replace('\n', '')
                    size = int(size)
                except:
                    size = 0
                if ((((float(size) / 2) / 1024) / 1024) / 1024) > 1:
                    des = _("Size: ") + str(
                        round(((((float(size) / 2) / 1024) / 1024) / 1024),
                              2)) + _("TB")
                elif (((size / 2) / 1024) / 1024) > 1:
                    des = _("Size: ") + str(
                        ((size / 2) / 1024) / 1024) + _("GB")
                else:
                    des = _("Size: ") + str((size / 2) / 1024) + _("MB")
        f.close()
        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_hdd', '/media/usb_hdd'),
                                     ('/media/usb', '/media/usb'),
                                     ('/media/usb2', '/media/usb2'),
                                     ('/media/usb3', '/media/usb3')]))
        #if (d1 == '/media/xtrenboot'):
        #	item = NoSave(ConfigSelection(default='/media/xtrenboot', choices=[('/media/xtrenboot', '/media/xtrenboot')]))
        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
Ejemplo n.º 12
0
def buildDeviceList(device, List):
    if re.search('mmcblk[0-1]p[0-3]', device):
        device2 = re.sub('p[0-9]', '', device)
    else:
        device2 = re.sub('[0-9]', '', device)
    devicetype = path.realpath('/sys/block/' + device2 + '/device')

    # print('[MountManager] device: %s' %device)
    # print('[MountManager] device2: %s' %device2)
    # print('[MountManager] devicetype:%s' %devicetype)
    # print('[MountManager] Type:%s' %SystemInfo["MountManager"])

    name = _("Hard disk: ")
    if path.exists(
            resolveFilename(SCOPE_CURRENT_SKIN, "visioncore/dev_hdd.png")):
        mypixmap = resolveFilename(SCOPE_CURRENT_SKIN,
                                   "visioncore/dev_hdd.png")
    else:
        mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/Vision/images/dev_hdd.png'
    if path.exists('/sys/block/' + device2 + '/device/model'):
        model = open('/sys/block/' + device2 + '/device/model').read()
    elif path.exists('/sys/block/' + device2 + '/device/name'):
        model = open('/sys/block/' + device2 + '/device/name').read()
    model = str(model).replace('\n', '')

    if devicetype.find('usb') != -1:
        name = _('USB: ')
        if path.exists(
                resolveFilename(SCOPE_CURRENT_SKIN, "visioncore/dev_usb.png")):
            mypixmap = resolveFilename(SCOPE_CURRENT_SKIN,
                                       "visioncore/dev_usb.png")
        else:
            mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/Vision/images/dev_usb.png'
    elif devicetype.find('mmc') != -1:
        name = _('SDCARD: ')
        if path.exists(
                resolveFilename(SCOPE_CURRENT_SKIN, "visioncore/dev_sd.png")):
            mypixmap = resolveFilename(SCOPE_CURRENT_SKIN,
                                       "visioncore/dev_sd.png")
        else:
            mypixmap = '/usr/lib/enigma2/python/Plugins/SystemPlugins/Vision/images/dev_sd.png'
    name += model
    description = ''
    mediamount = _("None")
    devicetype = _("unavailable")
    rw = _("None")

    with open('/proc/mounts', 'r') as f:
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                mediamount = parts[1]  # media mount e.g. /media/xxxxx
                devicetype = parts[2]  # device type e.g. ext4
                rw = parts[3]  # read/write
                break

    if mediamount == _("None") or mediamount == None:
        description = _("Size: ") + _("unavailable")
    else:
        stat = statvfs(mediamount)
        cap = int(stat.f_blocks * stat.f_bsize)
        size = cap / 1000 / 1000
        if ((float(size) / 1024) / 1024) >= 1:
            description = _("Size: ") + str(
                round(((float(size) / 1024) / 1024), 2)) + _("TB")
        elif (size / 1024) >= 1:
            description = _("Size: ") + str(round(
                (float(size) / 1024), 2)) + _("GB")
        elif size >= 1:
            description = _("Size: ") + str(size) + _("MB")
        else:
            description = _("Size: ") + _("unavailable")
    if description != '':
        if SystemInfo["MountManager"]:
            if rw.startswith('rw'):
                rw = ' R/W'
            elif rw.startswith('ro'):
                rw = ' R/O'
            else:
                rw = ""
            description += '\t' + _("Mount: ") + mediamount + '\n' + _(
                "Device: ") + '/dev/' + device + '\t' + _(
                    "Type: ") + devicetype + rw
            png = LoadPixmap(mypixmap)
            res = (name, description, png)
        else:
            Gmedia = [('/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')]
            item = NoSave(
                ConfigSelection(default='/media/' + device, choices=Gmedia))
            if devicetype == 'Linux':
                devicetype = 'ext4'
            else:
                devicetype = 'auto'
            item.value = mediamount.strip()
            text = name + ' ' + description + ' /dev/' + device
            res = getConfigListEntry(text, item, device, devicetype)
        List.append(res)
Ejemplo n.º 13
0
 def buildMy_rec(self, device):
     try:
         if device.find("1") > 1:
             device2 = device.replace("1", "")
     except:
         device2 = ""
     try:
         if device.find("2") > 1:
             device2 = device.replace("2", "")
     except:
         device2 = ""
     try:
         if device.find("3") > 1:
             device2 = device.replace("3", "")
     except:
         device2 = ""
     try:
         if device.find("4") > 1:
             device2 = device.replace("4", "")
     except:
         device2 = ""
     try:
         if device.find("5") > 1:
             device2 = device.replace("5", "")
     except:
         device2 = ""
     try:
         if device.find("6") > 1:
             device2 = device.replace("6", "")
     except:
         device2 = ""
     try:
         if device.find("7") > 1:
             device2 = device.replace("7", "")
     except:
         device2 = ""
     try:
         if device.find("8") > 1:
             device2 = device.replace("8", "")
     except:
         device2 = ""
     try:
         if device.find("p1") > 1:
             device2 = device.replace("p1", "")
     except:
         device2 = ""
     try:
         if device.find("p2") > 1:
             device2 = device.replace("p2", "")
     except:
         device2 = ""
     try:
         if device.find("p3") > 1:
             device2 = device.replace("p3", "")
     except:
         device2 = ""
     try:
         if device.find("p4") > 1:
             device2 = device.replace("p4", "")
     except:
         device2 = ""
     try:
         if device.find("p5") > 1:
             device2 = device.replace("p5", "")
     except:
         device2 = ""
     try:
         if device.find("p6") > 1:
             device2 = device.replace("p6", "")
     except:
         device2 = ""
     try:
         if device.find("p7") > 1:
             device2 = device.replace("p7", "")
     except:
         device2 = ""
     try:
         if device.find("p8") > 1:
             device2 = device.replace("p8", "")
     except:
         device2 = ""
     try:
         devicetype = path.realpath("/sys/block/" + device2 + "/device")
     except:
         devicetype = ""
     d2 = device
     model = "-?-"
     name = "USB: "
     mypixmap = "/usr/lib/enigma2/python/Plugins/Extensions/LDteam/images/icons/dev_usbstick.png"
     if "sdhci" in devicetype or device2.startswith("mmcblk"):
         name = "MMC: "
         try:
             model = file("/sys/block/" + device2 + "/device/name").read()
             model = str(model).replace("\n", "")
             mypixmap = "/usr/lib/enigma2/python/Plugins/Extensions/LDteam/images/icons/dev_mmc.png"
         except:
             pass
     else:
         try:
             model = file("/sys/block/" + device2 + "/device/model").read()
             model = str(model).replace("\n", "")
         except:
             pass
     des = ""
     print "test:"
     if (
         devicetype.find("/devices/pci") != -1
         or devicetype.find("ahci") != -1
         or devicetype.find("/devices/platform/strict-ahci") != -1
     ):
         name = _("HARD DISK: ")
         mypixmap = "/usr/lib/enigma2/python/Plugins/Extensions/LDteam/images/icons/dev_hdd.png"
     name = name + model
     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
             continue
         else:
             d1 = _("None")
             dtype = _("unavailable")
     f.close()
     f = open("/proc/partitions", "r")
     for line in f.readlines():
         if line.find(device) != -1:
             parts = line.strip().split()
             size = int(parts[2])
             if (((float(size) / 1024) / 1024) / 1024) > 1:
                 des = _("Size: ") + str(round((((float(size) / 1024) / 1024) / 1024), 2)) + _("TB")
             elif ((size / 1024) / 1024) > 1:
                 des = _("Size: ") + str((size / 1024) / 1024) + _("GB")
             else:
                 des = _("Size: ") + str(size / 1024) + _("MB")
         else:
             try:
                 size = file("/sys/block/" + device2 + "/" + device + "/size").read()
                 size = str(size).replace("\n", "")
                 size = int(size)
             except:
                 size = 0
             if ((((float(size) / 2) / 1024) / 1024) / 1024) > 1:
                 des = _("Size: ") + str(round(((((float(size) / 2) / 1024) / 1024) / 1024), 2)) + _("TB")
             elif (((size / 2) / 1024) / 1024) > 1:
                 des = _("Size: ") + str(((size / 2) / 1024) / 1024) + _("GB")
             else:
                 des = _("Size: ") + str((size / 2) / 1024) + _("MB")
     f.close()
     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/mmc", "/media/mmc"),
                 ("/media/mmc2", "/media/mmc2"),
                 ("/media/mmc3", "/media/mmc3"),
                 ("/media/cf", "/media/cf"),
                 ("/media/cf2", "/media/cf2"),
                 ("/media/cf3", "/media/cf3"),
                 ("/media/uSDextra", "/media/uSDextra"),
                 ("/media/net", "/media/net"),
                 ("/media/upnp", "/media/upnp"),
                 ("/media/downloads", "/media/downloads"),
                 ("/media/music", "/media/music"),
                 ("/media/personal", "/media/personal"),
                 ("/media/photo", "/media/photo"),
                 ("/media/video", "/media/video"),
                 ("/usr", "/usr"),
             ],
         )
     )
     if dtype == "Linux":
         dtype = "ext2" or "ext3" or "ext4"
     elif dtype == "vfat":
         dtype = "vfat" or "fat" or "fat16" or "fat32"
     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
Ejemplo n.º 14
0
	def buildMy_rec(self, device):
		try:
			if device.find('1') > 0:
				device2 = device.replace('1', '')
		except:
			device2 = ''
		try:
			if device.find('2') > 0:
				device2 = device.replace('2', '')
		except:
			device2 = ''
		try:
			if device.find('3') > 0:
				device2 = device.replace('3', '')
		except:
			device2 = ''
		try:
			if device.find('4') > 0:
				device2 = device.replace('4', '')
		except:
			device2 = ''
		devicetype = path.realpath('/sys/block/' + device2 + '/device')
		d2 = device
		name = 'USB: '
		mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/dev_usbstick.png'
		model = file('/sys/block/' + device2 + '/device/model').read()
		model = str(model).replace('\n', '')
		des = ''
		if devicetype.find('/devices/pci') != -1:
			name = _("HARD DISK: ")
			mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/dev_hdd.png'
		name = name + model
		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
				continue
			else:
				d1 = _("None")
				dtype = _("unavailable")
		f.close()
		f = open('/proc/partitions', 'r')
		for line in f.readlines():
			if line.find(device) != -1:
				parts = line.strip().split()
				size = int(parts[2])
				if (((float(size) / 1024) / 1024) / 1024) > 1:
					des = _("Size: ") + str(round((((float(size) / 1024) / 1024) / 1024),2)) + _("TB")
				elif ((size / 1024) / 1024) > 1:
					des = _("Size: ") + str((size / 1024) / 1024) + _("GB")
				else:
					des = _("Size: ") + str(size / 1024) + _("MB")
			else:
				try:
					size = file('/sys/block/' + device2 + '/' + device + '/size').read()
					size = str(size).replace('\n', '')
					size = int(size)
				except:
					size = 0
				if ((((float(size) / 2) / 1024) / 1024) / 1024) > 1:
					des = _("Size: ") + str(round(((((float(size) / 2) / 1024) / 1024) / 1024),2)) + _("TB")
				elif (((size / 2) / 1024) / 1024) > 1:
					des = _("Size: ") + str(((size / 2) / 1024) / 1024) + _("GB")
				else:
					des = _("Size: ") + str((size / 2) / 1024) + _("MB")
		f.close()
		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
Ejemplo n.º 15
0
	def buildMy_rec(self, device):
		global device2
		device2 = ''
		try:
			if device.find('1') > 0:
				device2 = device.replace('1', '')
		except:
			device2 = ''
		try:
			if device.find('2') > 0:
				device2 = device.replace('2', '')
		except:
			device2 = ''
		try:
			if device.find('3') > 0:
				device2 = device.replace('3', '')
		except:
			device2 = ''
		try:
			if device.find('4') > 0:
				device2 = device.replace('4', '')
		except:
			device2 = ''
		try:
			if device.find('5') > 0:
				device2 = device.replace('5', '')
		except:
			device2 = ''
		try:
			if device.find('6') > 0:
				device2 = device.replace('6', '')
		except:
			device2 = ''
		try:
			if device.find('7') > 0:
				device2 = device.replace('7', '')
		except:
			device2 = ''
		try:
			if device.find('8') > 0:
				device2 = device.replace('8', '')
		except:
			device2 = ''
		try:
			if device.find('9') > 0:
				device2 = device.replace('9', '')
		except:
			device2 = ''
		try:
			if device =='mmcblk0p1':
				device2 = 'mmcblk0'
		except:
			device2 = ''
		try:
			devicetype = path.realpath('/sys/block/' + device2 + '/device')
		except:
			devicetype = ''
		d2 = device
		model = '-?-'
		name = "USB: "
		if 'sdhci' in devicetype:
			name = "MMC: "
			try:
				model = file('/sys/block/' + device2 + '/device/name').read()
			except:
				pass
			model = str(model).replace('\n', '')
		else:
			try:
				model = file('/sys/block/' + device2 + '/device/model').read()
			except:
				pass
			model = str(model).replace('\n', '')
		des = ''
		if devicetype.find('/devices/pci') != -1 or devicetype.find('/devices/platform/strict-ahci') != -1:
			name = _("HARD DISK: ")
		name = name + model
		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
				continue
			else:
				d1 = _("None")
				dtype = _("unavailable")
		f.close()
		f = open('/proc/partitions', 'r')
		for line in f.readlines():
			if line.find(device) != -1:
				parts = line.strip().split()
				size = int(parts[2])
				if (((float(size) / 1024) / 1024) / 1024) > 1:
					des = _("Size: ") + str(round((((float(size) / 1024) / 1024) / 1024),2)) + " " + _("TB")
				elif ((size / 1024) / 1024) > 1:
					des = _("Size: ") + str((size / 1024) / 1024) + " " + _("GB")
				else:
					des = _("Size: ") + str(size / 1024) + " " + _("MB")
			else:
				try:
					size = file('/sys/block/' + device2 + '/' + device + '/size').read()
					size = str(size).replace('\n', '')
					size = int(size)
				except:
					size = 0
				if ((((float(size) / 2) / 1024) / 1024) / 1024) > 1:
					des = _("Size: ") + str(round(((((float(size) / 2) / 1024) / 1024) / 1024),2)) + " " + _("TB")
				elif (((size / 2) / 1024) / 1024) > 1:
					des = _("Size: ") + str(((size / 2) / 1024) / 1024) + " " + _("GB")
				else:
					des = _("Size: ") + str((size / 2) / 1024) + " " + _("MB")
		f.close()
		choices = [('/media/' + device, '/media/' + device), ('/media/hdd', '/media/hdd'), ('/media/hdd2', '/media/hdd2'), ('/media/hdd3', '/media/hdd3'), ('/media/usb_hdd', '/media/usb_hdd'), ('/media/usb', '/media/usb'), ('/media/usb2', '/media/usb2'), ('/media/usb3', '/media/usb3')]
		if 'MMC' in name:
			choices.append(('/media/mmc', '/media/mmc'))
		item = NoSave(ConfigSelection(default='/media/' + device, choices=choices))
		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
Ejemplo n.º 16
0
def runScreenTest():
	config.misc.startCounter.value += 1

	profile("readPluginList")
	plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))

	profile("Init:Session")
	nav = Navigation(config.misc.nextWakeup.value)
	#nav = Navigation(config.misc.isNextRecordTimerAfterEventActionAuto.value, config.misc.isNextPowerTimerAfterEventActionAuto.value)
	session = Session(desktop = enigma.getDesktop(0), summary_desktop = enigma.getDesktop(1), navigation = nav)

	CiHandler.setSession(session)

	profile("wizards")
	screensToRun = []
	RestoreSettings = None
	import hashlib
	import os
	from os import path
	from pathlib import Path
	import fileinput, sys	
	def md5_update_from_file(filename, hash):
		assert Path(filename).is_file()
		with open(str(filename), "rb") as f:
			for chunk in iter(lambda: f.read(4096), b""):
				hash.update(chunk)
		return hash


	def md5_file(filename):
		return md5_update_from_file(filename, hashlib.md5()).hexdigest()

	def md5_update_from_dir(directory, hash):
		assert Path(directory).is_dir()
		for path in sorted(Path(directory).iterdir()):
			hash.update(path.name.encode())
			if path.is_file():
				hash = md5_update_from_file(path, hash)
			elif path.is_dir():
				hash = md5_update_from_dir(path, hash)
		return hash


	def md5_dir(directory):
		return md5_update_from_dir(directory, hashlib.md5()).hexdigest()	
	
	
	sha256hash = ()
	myfilecheck = "/usr/lib/enigma2/python/Plugins/Extensions/Infopanel"
	sha256save = "/var/lib/opkg/info/enigma2-plugin-extensions-infopanel.sha256"
	if config.misc.firstrun.value == True:
		myfile = Path(sha256save)
		if os.path.isfile(sha256save):
			os.remove(sha256save)
		myfile.touch(exist_ok=True)
		sha256hash = md5_dir(myfilecheck)
		sha_f = open(sha256save, "a")
		sha_f.write(sha256hash)
		sha_f.close()
	else:
		if os.path.isfile(sha256save): 
			sha256hash = md5_dir(myfilecheck)
			try:
				sha256read = open(sha256save,'r')
				sha256hash1 = sha256read.read()
				print("sha256hash1:", sha256hash1)
				print("sha256hash:", sha256hash)				
				if sha256hash == sha256hash1:
					print("all ok with Infopanel")
				else:
					print("Sorry, but you change our Infopanel so we had to disable it!!")
					sub_menu_sort = NoSave(ConfigDictionarySet())
					sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue("mainmenu", "submenu")
					m_weight = sub_menu_sort.getConfigValue('Infopanel', "sort")
					m_weight1 = sub_menu_sort.getConfigValue('Infopanel', "hidden")
					sub_menu_sort.changeConfigValue('Infopanel', "hidden", "1")				
					config.usage.menu_sort_weight.save()
					configfile.save()			
				
				sha256read.close()
			
			except:
				print("Sorry, but you change our Infopanel so we had to disable it!!")
				sub_menu_sort = NoSave(ConfigDictionarySet())
				sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue("mainmenu", "submenu")
				m_weight = sub_menu_sort.getConfigValue('Infopanel', "sort")
				m_weight1 = sub_menu_sort.getConfigValue('Infopanel', "hidden")
				sub_menu_sort.changeConfigValue('Infopanel', "hidden", "1")				
				config.usage.menu_sort_weight.save()
				configfile.save()                                        
		else:
			print("Sorry, but you change our Infopanel so we had to disable it!!")
			sub_menu_sort = NoSave(ConfigDictionarySet())
			sub_menu_sort.value = config.usage.menu_sort_weight.getConfigValue("mainmenu", "submenu")
			m_weight = sub_menu_sort.getConfigValue('Infopanel', "sort")
			m_weight1 = sub_menu_sort.getConfigValue('Infopanel', "hidden")
			sub_menu_sort.changeConfigValue('Infopanel', "hidden", "1")				
			config.usage.menu_sort_weight.save()
			configfile.save()                                                  
                                                                            	
	if os.path.exists("/media/hdd/images/config/settings") and config.misc.firstrun.value:
		if autorestoreLoop():
			RestoreSettings = True
			from Plugins.SystemPlugins.SoftwareManager.BackupRestore import RestoreScreen
			os.system("rm /media/hdd/images/config/settings")
			session.open(RestoreScreen, runRestore = True)
		else:
			os.system("rm /media/hdd/images/config/settings")
			screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
			screensToRun += wizardManager.getWizards()
	else:
		if os.path.exists("/media/hdd/images/config/autorestore"):
			os.system('rm -f /media/hdd/images/config/autorestore')
		screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
		screensToRun += wizardManager.getWizards()
	
	screensToRun.append((100, InfoBar.InfoBar))
	screensToRun.sort()
	print(screensToRun)

	enigma.ePythonConfigQuery.setQueryFunc(configfile.getResolvedKey)

	def runNextScreen(session, screensToRun, *result):
		config.easysetup = ConfigSubsection()
		config.easysetup.restart = ConfigBoolean(default = False)
		if config.easysetup.restart.value == True:
			print("restart after Wizard2")
			config.easysetup.restart.setValue(False)
			config.easysetup.restart.save()
			enigma.quitMainloop(3)
		if result:
			print("[mytest.py] quitMainloop #3")
			enigma.quitMainloop(*result)
			return

		screen = screensToRun[0][1]
		args = screensToRun[0][2:]
		if screensToRun:
			session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args)
		else:
			session.open(screen, *args)

	if not RestoreSettings:
		runNextScreen(session, screensToRun)

	profile("Init:VolumeControl")
	vol = VolumeControl(session)
	profile("Init:PowerKey")
	power = PowerKey(session)
	power.timerstdby()        
	if boxtype in ('alien5', 'osninopro', 'osnino', 'osninoplus', 'alphatriple', 'spycat4kmini', 'tmtwin4k', 'mbmicrov2', 'revo4k', 'force3uhd', 'wetekplay', 'wetekplay2', 'wetekhub', 'dm7020hd', 'dm7020hdv2', 'osminiplus', 'osmega', 'sf3038', 'spycat', 'e4hd', 'e4hdhybrid', 'mbmicro', 'et7500', 'mixosf5', 'mixosf7', 'mixoslumi', 'gi9196m', 'maram9', 'ixussone', 'ixusszero', 'uniboxhd1', 'uniboxhd2', 'uniboxhd3', 'sezam5000hd', 'mbtwin', 'sezam1000hd', 'mbmini', 'atemio5x00', 'beyonwizt3', '9910lx', '9911lx', '9920lx') or getBrandOEM() in ('fulan') or getMachineBuild() in ('u41', 'dags7362', 'dags73625', 'dags5', 'ustym4kpro', 'beyonwizv2', 'viper4k', 'sf8008', 'sf8008m', 'cc1', 'gbmv200'):
		profile("VFDSYMBOLS")
	import Components.VfdSymbols
	Components.VfdSymbols.SymbolsCheck(session)
		
	# we need session.scart to access it from within menu.xml
	session.scart = AutoScartControl(session)

	profile("Init:Trashcan")
	import Tools.Trashcan
	Tools.Trashcan.init(session)

	profile("Init:AutoVideoMode")
	import Screens.VideoMode
	Screens.VideoMode.autostart(session)

	profile("RunReactor")
	profile_final()

	if boxtype in ('sf8', 'classm', 'axodin', 'axodinc', 'starsatlx', 'genius', 'evo'):
		f = open("/dev/dbox/oled0", "w")
		f.write('-E2-')
		f.close()

	print("lastshutdown=%s		(True = last shutdown was OK)" % config.usage.shutdownOK.value)
	print("NOK shutdown action=%s" % config.usage.shutdownNOK_action.value)
	print("bootup action=%s" % config.usage.boot_action.value)
	
	if not config.usage.shutdownOK.value and not config.usage.shutdownNOK_action.value == 'normal' or not config.usage.boot_action.value == 'normal':
		print("last shutdown = %s" % config.usage.shutdownOK.value)
		import Screens.PowerLost
		Screens.PowerLost.PowerLost(session)

	config.usage.shutdownOK.setValue(False)
	config.usage.shutdownOK.save()
	if not RestoreSettings:
		configfile.save()
	
	# kill showiframe if it is running (sh4 hack...)
	if getMachineBuild() in ('spark', 'spark7162'):
		os.system("killall -9 showiframe")
	
	runReactor()
	print("[mytest.py] normal shutdown")
	
	config.misc.startCounter.save()
	config.usage.shutdownOK.setValue(True)
	config.usage.shutdownOK.save()	

	profile("wakeup")
	#get currentTime
	nowTime = time()
	if not config.misc.SyncTimeUsing.value == "0" or getBoxType().startswith('gb') or getMachineProcModel().startswith('ini'):
		print("dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime)))
		setRTCtime(nowTime)
		
	wakeupList = [
		x for x in ((session.nav.RecordTimer.getNextRecordingTime(), 0, session.nav.RecordTimer.isNextRecordAfterEventActionAuto()),
					(session.nav.RecordTimer.getNextZapTime(), 1),
					(plugins.getNextWakeupTime(), 2),
					(session.nav.PowerTimer.getNextPowerManagerTime(), 3, session.nav.PowerTimer.isNextPowerManagerAfterEventActionAuto()))
		if x[0] != -1
	]
	wakeupList.sort()
	recordTimerWakeupAuto = False
	if wakeupList and wakeupList[0][1] != 3:
		startTime = wakeupList[0]
		if (startTime[0] - nowTime) < 270: # no time to switch box back on
			wptime = nowTime + 30  # so switch back on in 30 seconds
		else:
			if getBoxType().startswith("gb"):
				wptime = startTime[0] - 120 # Gigaboxes already starts 2 min. before wakeup time
			else:
				wptime = startTime[0] - 240
		if startTime[1] == 3:
			nextPluginName = " (%s)" % nextPluginName				
		#if not config.misc.SyncTimeUsing.value == "0" or getBoxType().startswith('gb'):
		#	print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
		#	setRTCtime(nowTime)
		print("set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime)))
		setFPWakeuptime(wptime)
		recordTimerWakeupAuto = startTime[1] == 0 and startTime[2]
		print('recordTimerWakeupAuto',recordTimerWakeupAuto)
	config.misc.isNextRecordTimerAfterEventActionAuto.value = recordTimerWakeupAuto
	config.misc.isNextRecordTimerAfterEventActionAuto.save()


	PowerTimerWakeupAuto = False
	if wakeupList and wakeupList[0][1] == 3:
		startTime = wakeupList[0]
		if (startTime[0] - nowTime) < 60: # no time to switch box back on
			wptime = nowTime + 30  # so switch back on in 30 seconds
		else:
			if getBoxType().startswith("gb"):
				wptime = startTime[0] + 120 # Gigaboxes already starts 2 min. before wakeup time
			else:
				wptime = startTime[0]
		#if not config.misc.SyncTimeUsing.value == "0" or getBoxType().startswith('gb'):
		#	print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
		#	setRTCtime(nowTime)
		print("set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime+60)))
		setFPWakeuptime(wptime)
		PowerTimerWakeupAuto = startTime[1] == 3 and startTime[2]
		print('PowerTimerWakeupAuto',PowerTimerWakeupAuto)
	config.misc.isNextPowerTimerAfterEventActionAuto.value = PowerTimerWakeupAuto
	config.misc.isNextPowerTimerAfterEventActionAuto.save()

	profile("stopService")
	session.nav.stopService()
	profile("nav shutdown")
	session.nav.shutdown()

	profile("configfile.save")
	configfile.save()
	from Screens import InfoBarGenerics
	InfoBarGenerics.saveResumePoints()

	return 0
Ejemplo n.º 17
0
    def buildMy_rec(self, device):
        device2 = ''
        try:
            if device.find('1') > 1:
                device2 = device.replace('1', '')
        except:
            device2 = ''

        try:
            if device.find('2') > 1:
                device2 = device.replace('2', '')
        except:
            device2 = ''

        try:
            if device.find('3') > 1:
                device2 = device.replace('3', '')
        except:
            device2 = ''

        try:
            if device.find('4') > 1:
                device2 = device.replace('4', '')
        except:
            device2 = ''

        try:
            if device.find('5') > 1:
                device2 = device.replace('5', '')
        except:
            device2 = ''

        try:
            if device.find('6') > 1:
                device2 = device.replace('6', '')
        except:
            device2 = ''

        try:
            if device.find('7') > 1:
                device2 = device.replace('7', '')
        except:
            device2 = ''

        try:
            if device.find('8') > 1:
                device2 = device.replace('8', '')
        except:
            device2 = ''

        try:
            if device.find('p1') > 1:
                device2 = device.replace('p1', '')
        except:
            device2 = ''

        try:
            if device.find('p2') > 1:
                device2 = device.replace('p2', '')
        except:
            device2 = ''

        try:
            if device.find('p3') > 1:
                device2 = device.replace('p3', '')
        except:
            device2 = ''

        try:
            if device.find('p4') > 1:
                device2 = device.replace('p4', '')
        except:
            device2 = ''

        try:
            if device.find('p5') > 1:
                device2 = device.replace('p5', '')
        except:
            device2 = ''

        try:
            if device.find('p6') > 1:
                device2 = device.replace('p6', '')
        except:
            device2 = ''

        try:
            if device.find('p7') > 1:
                device2 = device.replace('p7', '')
        except:
            device2 = ''

        try:
            if device.find('p8') > 1:
                device2 = device.replace('p8', '')
        except:
            device2 = ''

        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = 'USB: '
        mypixmap = '/usr/lib/enigma2/python/EGAMI/icons/devices/dev_usb.png'
        if device2.startswith('mmcblk'):
            if getBoxType() in ('wetekplay', 'wetekplayplus'
                                ) or getMachineBuild() in ('h3', 'h5'):
                model = file('/sys/block/mmcblk0/device/name').read()
            else:
                model = file('/sys/block/' + device2 + '/device/name').read()
            mypixmap = '/usr/lib/enigma2/python/EGAMI/icons/devices/dev_mmc.png'
            name = 'MMC: '
        else:
            model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('/devices/pci') != -1:
            name = _('HARD DISK: ')
            mypixmap = '/usr/lib/enigma2/python/EGAMI/icons/devices/dev_hdd.png'
        name = name + model
        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
                continue
            else:
                d1 = _('None')
                dtype = _('unavailable')

        f.close()
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                size = int(parts[2])
                if float(size) / 1024 / 1024 / 1024 > 1:
                    des = _('Size: ') + str(
                        round(float(size) / 1024 / 1024 / 1024, 2)) + _('TB')
                elif size / 1024 / 1024 > 1:
                    des = _('Size: ') + str(size / 1024 / 1024) + _('GB')
                else:
                    des = _('Size: ') + str(size / 1024) + _('MB')
            else:
                try:
                    size = file('/sys/block/' + device2 + '/' + device +
                                '/size').read()
                    size = str(size).replace('\n', '')
                    size = int(size)
                except:
                    size = 0

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

        f.close()
        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/mmc', '/media/mmc'),
                                     ('/media/mmc2', '/media/mmc2'),
                                     ('/media/mmc3', '/media/mmc3'),
                                     ('/usr', '/usr')]))
        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
Ejemplo n.º 18
0
def buildPartitionInfo(partition, bplist):
    if re.search("mmcblk[0-1]p[0-3]", partition):
        device = re.sub("p[0-9]", "", partition)
    else:
        device = re.sub("[0-9]", "", partition)
    physicalDevice = path.realpath(path.join("/sys/block", device, "device"))

    description = readFile(path.join(physicalDevice, "model"))
    if description is None:
        description = readFile(path.join(physicalDevice, "name"))
    if description is None:
        description = _("Device %s") % partition
    description = str(description).replace("\n", "")

    hotplugBuses = ("usb", "mmc", "ata")
    busTranslate = ("usb", "sd", "hdd")
    count = -1
    for bus in hotplugBuses:
        count += 1
        if "/%s" % bus in physicalDevice:
            break
    # print "[MountManager1]bus: %s count : %s" % (bus, count)
    pngType = busTranslate[count]
    name = _("%s: " % pngType.upper())
    name += description

    if path.exists(
            resolveFilename(SCOPE_CURRENT_SKIN,
                            "visioncore/dev_%s.png" % pngType)):
        mypixmap = resolveFilename(SCOPE_CURRENT_SKIN,
                                   "visioncore/dev_%s.png" % pngType)
    else:
        mypixmap = resolveFilename(
            SCOPE_PLUGINS, "SystemPlugins/Vision/images/dev_%s.png" % pngType)

    description = ""
    mediamount = _("None")
    format = _("unavailable")
    rw = _("None")

    with open("/proc/mounts", "r") as f:
        for line in f.readlines():
            if line.find(partition) != -1:
                parts = line.strip().split()
                mediamount = parts[1]  # media mount e.g. /media/xxxxx
                format = parts[2]  # format e.g. ext4
                rw = parts[3]  # read/write
                break

    if mediamount == _("None") or mediamount is None:
        description = _("Size: ") + _("unavailable")
    else:
        stat = statvfs(mediamount)
        cap = int(stat.f_blocks * stat.f_bsize)
        size = cap // 1000 // 1000
        if ((float(size) // 1024) // 1024) >= 1:
            description = _("Size: ") + str(
                round(((float(size) // 1024) // 1024), 2)) + _("TB")
        elif (size / 1024) >= 1:
            description = _("Size: ") + str(round(
                (float(size) // 1024), 2)) + _("GB")
        elif size >= 1:
            description = _("Size: ") + str(size) + _("MB")
        else:
            description = _("Size: ") + _("unavailable")
    if description != "":
        if SystemInfo["MountManager"]:
            if rw.startswith("rw"):
                rw = " R/W"
            elif rw.startswith("ro"):
                rw = " R/O"
            else:
                rw = ""
            description += "\t" + _("Mount: ") + mediamount + "\n" + _(
                "Device: ") + "/dev/" + partition + "\t" + _(
                    "Type: ") + format + rw
            png = LoadPixmap(mypixmap)
            partitionInfo = (name, description, png)
        else:
            Gmedia = [("/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")]
            item = NoSave(
                ConfigSelection(default="/media/%s" % partition,
                                choices=Gmedia))
            if format == "Linux":
                format = "ext4"
            else:
                format = "auto"
            item.value = mediamount.strip()
            text = name + " " + description + " /dev/" + partition
            partitionInfo = getConfigListEntry(text, item, partition, format)
        bplist.append(partitionInfo)
Ejemplo n.º 19
0
 def buildMy_rec(self, device):
     global device2
     device2 = ''
     try:
         if device.find('1') > 0:
             device2 = device.replace('1', '')
     except:
         device2 = ''
     try:
         if device.find('2') > 0:
             device2 = device.replace('2', '')
     except:
         device2 = ''
     try:
         if device.find('3') > 0:
             device2 = device.replace('3', '')
     except:
         device2 = ''
     try:
         if device.find('4') > 0:
             device2 = device.replace('4', '')
     except:
         device2 = ''
     try:
         if device.find('5') > 0:
             device2 = device.replace('5', '')
     except:
         device2 = ''
     try:
         if device.find('6') > 0:
             device2 = device.replace('6', '')
     except:
         device2 = ''
     try:
         if device.find('7') > 0:
             device2 = device.replace('7', '')
     except:
         device2 = ''
     try:
         if device.find('8') > 0:
             device2 = device.replace('8', '')
     except:
         device2 = ''
     try:
         if device.find('9') > 0:
             device2 = device.replace('9', '')
     except:
         device2 = ''
     try:
         if device == 'mmcblk0p1':
             device2 = 'mmcblk0'
     except:
         device2 = ''
     try:
         devicetype = path.realpath('/sys/block/' + device2 + '/device')
     except:
         devicetype = ''
     d2 = device
     model = '-?-'
     name = "USB: "
     if 'sdhci' in devicetype:
         name = "MMC: "
         try:
             model = file('/sys/block/' + device2 + '/device/name').read()
         except:
             pass
         model = str(model).replace('\n', '')
     else:
         try:
             model = file('/sys/block/' + device2 + '/device/model').read()
         except:
             pass
         model = str(model).replace('\n', '')
     des = ''
     if devicetype.find('/devices/pci') != -1 or devicetype.find(
             '/devices/platform/strict-ahci') != -1:
         name = _("HARD DISK: ")
     name = name + model
     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
             continue
         else:
             d1 = _("None")
             dtype = _("unavailable")
     f.close()
     f = open('/proc/partitions', 'r')
     for line in f.readlines():
         if line.find(device) != -1:
             parts = line.strip().split()
             size = int(parts[2])
             if (((float(size) / 1024) / 1024) / 1024) > 1:
                 des = _("Size: ") + str(
                     round((((float(size) / 1024) / 1024) / 1024),
                           2)) + " " + _("TB")
             elif ((size / 1024) / 1024) > 1:
                 des = _("Size: ") + str(
                     (size / 1024) / 1024) + " " + _("GB")
             else:
                 des = _("Size: ") + str(size / 1024) + " " + _("MB")
         else:
             try:
                 size = file('/sys/block/' + device2 + '/' + device +
                             '/size').read()
                 size = str(size).replace('\n', '')
                 size = int(size)
             except:
                 size = 0
             if ((((float(size) / 2) / 1024) / 1024) / 1024) > 1:
                 des = _("Size: ") + str(
                     round(((((float(size) / 2) / 1024) / 1024) / 1024),
                           2)) + " " + _("TB")
             elif (((size / 2) / 1024) / 1024) > 1:
                 des = _("Size: ") + str(
                     ((size / 2) / 1024) / 1024) + " " + _("GB")
             else:
                 des = _("Size: ") + str((size / 2) / 1024) + " " + _("MB")
     f.close()
     choices = [('/media/' + device, '/media/' + device),
                ('/media/hdd', '/media/hdd'),
                ('/media/hdd2', '/media/hdd2'),
                ('/media/hdd3', '/media/hdd3'),
                ('/media/usb_hdd', '/media/usb_hdd'),
                ('/media/usb', '/media/usb'),
                ('/media/usb2', '/media/usb2'),
                ('/media/usb3', '/media/usb3')]
     if 'MMC' in name:
         choices.append(('/media/mmc', '/media/mmc'))
     item = NoSave(
         ConfigSelection(default='/media/' + device, choices=choices))
     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
Ejemplo n.º 20
0
def buildPartitionInfo(partition, partitionList):
	if re.search("mmcblk[0-1]p[0-3]", partition):
		device = re.sub("p[0-9]", "", partition)
	else:
		device = re.sub("[0-9]", "", partition)
	physicalDevice = path.realpath(path.join("/sys/block", device, "device"))

	description = readFile(path.join(physicalDevice, "model"))
	if description is None:
		description = readFile(path.join(physicalDevice, "name"))
	if description is None:
		description = _("Device %s") % partition
	description = str(description).replace("\n", "")

	hotplugBuses = ("usb", "mmc", "ata")
	busTranslate = ("usb", "sd", "hdd")
	count = -1
	for bus in hotplugBuses:
		count += 1
		if "/%s" % bus in physicalDevice:
			break
	# print "[MountManager1]bus: %s count : %s" % (bus, count)
	pngType = busTranslate[count]
	name = _("%s: " % pngType.upper())
	name += description

	if path.exists(resolveFilename(SCOPE_CURRENT_SKIN, "visioncore/dev_%s.png" % pngType)):
		mypixmap = resolveFilename(SCOPE_CURRENT_SKIN, "visioncore/dev_%s.png" % pngType)
	else:
		mypixmap = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Vision/images/dev_%s.png" % pngType)

	description = ""
	mediamount = _("None")
	_format = _("unavailable")
	rw = _("None")

	with open("/proc/mounts", "r") as f:
		for line in f.readlines():
			if line.find(partition) != -1:
				parts = line.strip().split()
				mediamount = parts[1]		# media mount e.g. /media/xxxxx
				_format = parts[2]		# _format e.g. ext4
				rw = parts[3]			# read/write
				break

	if mediamount == _("None") or mediamount is None:
		description = _("Size: ") + _("unavailable")
	else:
		stat = statvfs(mediamount)
		# print("[MountManager1]mediamount: %s" % mediamount)
		size = (stat.f_blocks * stat.f_bsize) / (1000 * 1000) # get size in MB
		if size < 1: # is condition ever fulfilled?
			description = _("Size: unavailable")
		if size < 1000:
			description = _("Size: %sMB") % str(int(size))
		elif size < 1000 * 1000:
			description = _("Size: %sGB") % format(size / 1000, '.2f')
		else:
			description = _("Size: %sTB") % format(size / (1000 * 1000), '.2f')
	if description != "": # how will this ever return false?
		if BoxInfo.getItem("MountManager"): # called by VISIONDevicesPanel else DeviceMountSetup
			if rw.startswith("rw"):
				rw = " R/W"
			elif rw.startswith("ro"):
				rw = " R/O"
			else:
				rw = ""
			description += "\t" + _("Mount: ") + mediamount + "\n" + _("Device: ") + "/dev/" + partition + "\t" + _("Type: ") + _format + rw
			png = LoadPixmap(mypixmap)
			partitionInfo = (name, description, png)
		else:
			Gmedia = [
				("/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")
			]
			item = NoSave(ConfigSelection(default="/media/%s" % partition, choices=Gmedia))
			if _format == "Linux":
				_format = "ext4"
			else:
				_format = "auto"
			item.value = mediamount.strip()
			text = name + " " + description + " /dev/" + partition
			partitionInfo = getConfigListEntry(text, item, partition, _format)
		partitionList.append(partitionInfo)
Ejemplo n.º 21
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
Ejemplo n.º 22
0
    def buildMy_rec(self, device):
        try:
            if device.find('1') > 0:
                device2 = device.replace('1', '')
        except:
            device2 = ''

        try:
            if device.find('2') > 0:
                device2 = device.replace('2', '')
        except:
            device2 = ''

        try:
            if device.find('3') > 0:
                device2 = device.replace('3', '')
        except:
            device2 = ''

        try:
            if device.find('4') > 0:
                device2 = device.replace('4', '')
        except:
            device2 = ''

        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = 'USB: '
        mypixmap = '/usr/share/enigma2/sfpanel/dev_usbstick.png'
        model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        if devicetype.find('/devices/pci') != -1:
            name = _('HARD DISK: ')
            mypixmap = '/usr/share/enigma2/sfpanel/dev_hdd.png'
        name = name + model
        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
                continue
            else:
                d1 = _('None')
                dtype = _('unavailable')

        f.close()
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                size = int(parts[2])
                if float(size) / 1024 / 1024 / 1024 > 1:
                    des = _('Size: ') + str(
                        round(float(size) / 1024 / 1024 / 1024, 2)) + _('TB')
                elif size / 1024 / 1024 > 1:
                    des = _('Size: ') + str(size / 1024 / 1024) + _('GB')
                else:
                    des = _('Size: ') + str(size / 1024) + _('MB')
            else:
                try:
                    size = file('/sys/block/' + device2 + '/' + device +
                                '/size').read()
                    size = str(size).replace('\n', '')
                    size = int(size)
                except:
                    size = 0

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

        f.close()
        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'),
                                     ('/usr', '/usr')]))
        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
Ejemplo n.º 23
0
    def buildMy_rec(self, device):
        try:
            if device.find('1') > 1:
                device2 = device.replace('1', '')
        except:
            device2 = ''
        try:
            if device.find('2') > 1:
                device2 = device.replace('2', '')
        except:
            device2 = ''
        try:
            if device.find('3') > 1:
                device2 = device.replace('3', '')
        except:
            device2 = ''
        try:
            if device.find('4') > 1:
                device2 = device.replace('4', '')
        except:
            device2 = ''
        try:
            if device.find('5') > 1:
                device2 = device.replace('5', '')
        except:
            device2 = ''
        try:
            if device.find('6') > 1:
                device2 = device.replace('6', '')
        except:
            device2 = ''
        try:
            if device.find('7') > 1:
                device2 = device.replace('7', '')
        except:
            device2 = ''
        try:
            if device.find('8') > 1:
                device2 = device.replace('8', '')
        except:
            device2 = ''
        try:
            if device.find('p1') > 1:
                device2 = device.replace('p1', '')
        except:
            device2 = ''
        try:
            if device.find('p2') > 1:
                device2 = device.replace('p2', '')
        except:
            device2 = ''
        try:
            if device.find('p3') > 1:
                device2 = device.replace('p3', '')
        except:
            device2 = ''
        try:
            if device.find('p4') > 1:
                device2 = device.replace('p4', '')
        except:
            device2 = ''
        try:
            if device.find('p5') > 1:
                device2 = device.replace('p5', '')
        except:
            device2 = ''
        try:
            if device.find('p6') > 1:
                device2 = device.replace('p6', '')
        except:
            device2 = ''
        try:
            if device.find('p7') > 1:
                device2 = device.replace('p7', '')
        except:
            device2 = ''
        try:
            if device.find('p8') > 1:
                device2 = device.replace('p8', '')
        except:
            device2 = ''
        devicetype = path.realpath('/sys/block/' + device2 + '/device')
        d2 = device
        name = 'USB: '
        mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/dev_usbstick.png'
        if device2.startswith('mmcblk'):
            model = file('/sys/block/' + device2 + '/device/name').read()
            mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/dev_mmc.png'
            name = 'MMC: '
        else:
            model = file('/sys/block/' + device2 + '/device/model').read()
        model = str(model).replace('\n', '')
        des = ''
        print "test:"
        if devicetype.find('/devices/pci') != -1 or devicetype.find(
                'ahci') != -1:
            name = _("HARD DISK: ")
            mypixmap = '/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/dev_hdd.png'
        name = name + model
        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
                continue
            else:
                d1 = _("None")
                dtype = _("unavailable")
        f.close()
        f = open('/proc/partitions', 'r')
        for line in f.readlines():
            if line.find(device) != -1:
                parts = line.strip().split()
                size = int(parts[2])
                if (((float(size) / 1024) / 1024) / 1024) > 1:
                    des = _("Size: ") + str(
                        round(((
                            (float(size) / 1024) / 1024) / 1024), 2)) + _("TB")
                elif ((size / 1024) / 1024) > 1:
                    des = _("Size: ") + str((size / 1024) / 1024) + _("GB")
                else:
                    des = _("Size: ") + str(size / 1024) + _("MB")
            else:
                try:
                    size = file('/sys/block/' + device2 + '/' + device +
                                '/size').read()
                    size = str(size).replace('\n', '')
                    size = int(size)
                except:
                    size = 0
                if ((((float(size) / 2) / 1024) / 1024) / 1024) > 1:
                    des = _("Size: ") + str(
                        round(((((float(size) / 2) / 1024) / 1024) / 1024),
                              2)) + _("TB")
                elif (((size / 2) / 1024) / 1024) > 1:
                    des = _("Size: ") + str(
                        ((size / 2) / 1024) / 1024) + _("GB")
                else:
                    des = _("Size: ") + str((size / 2) / 1024) + _("MB")
        f.close()
        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/mmc', '/media/mmc'),
                                     ('/media/mmc2', '/media/mmc2'),
                                     ('/media/mmc3', '/media/mmc3'),
                                     ('/usr', '/usr')]))
        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
Ejemplo n.º 24
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