Пример #1
0
	def get_ESI_devices(self):
		ret = list()
		#devices
		if self.xml_esi!= None:
			YoUtil.debug_print('read devices of esi=',self.esi_path)
			xml_list_device = self.xml_esi.findall('Descriptions/Devices/Device')
			YoUtil.debug_print('num of devices in esi=',len(xml_list_device))
			for xml_device in xml_list_device:
				pc = None
				rev=None
				name=None
				xml_type = xml_device.find('Type')
				if xml_type != None:
					msg1 = ''
					if 'ProductCode' in xml_type.attrib.keys():
						pc = YoUtil.get_int(xml_type.attrib['ProductCode'])
						msg1 = msg1+'ProductCode='+hex(pc)
					if 'RevisionNo' in xml_type.attrib.keys():
						rev = YoUtil.get_int(xml_type.attrib['RevisionNo'])
						msg1= msg1+' RevisionNo:'+hex(rev)
					
					if len(msg1)>0:
						YoUtil.debug_print(msg1,'')
				if pc != None:
					ret.append((pc,rev,name))
		return ret
Пример #2
0
	def __init__(self, xml_device):
		self.xml_node = xml_device
		self.product_code = None
		self.revision = None
		self.name = None
		
		xml_type = xml_device.find('Type')
		if xml_type!= None:
			if 'ProductCode' in xml_type.attrib.keys():
				self.product_code  = YoUtil.get_int(xml_type.attrib['ProductCode'])
			if 'RevisionNo' in xml_type.attrib.keys():
				self.revision = YoUtil.get_int(xml_type.attrib['RevisionNo'])
		xml_name = xml_device.find('Name')
		if xml_name!=None:
			self.name = xml_name.text
Пример #3
0
def find_esi(vendor, product):
    '''
		finds ESI files can fileter by [vendor] and [product]
	'''
    pr1 = pr()
    esi = EsiUtil()
    vendor_id = None
    productCode = None
    if vendor != None:
        vendor_id = YoUtil.get_int(vendor)
    if product != None:
        productCode = YoUtil.get_int(product)
    files = esi.get_ESI_files(vendor_id, productCode)
    if files != None and len(files) > 0:
        YoUtil.print_list(files, 1)
    else:
        pr1.print('ESI not found !')
Пример #4
0
    def __init__(self, xml_initCmd):
        self.Transition = list()
        self.Comment = None
        self.Cmd = None
        self.Adp = None
        self.Ado = None
        self.Index = None
        self.SubIndex = None
        self.Data = None
        self.Cnt = None
        self.CompleteAccess = None

        xml_transitions = xml_initCmd.findall('Transition')
        for xml_transition in xml_transitions:
            self.Transition.append(xml_transition.text)

        xml_comment = xml_initCmd.find('Comment')
        if xml_comment != None:
            self.Comment = xml_comment.text
        xml_ado = xml_initCmd.find('Ado')
        if xml_ado != None:
            self.Ado = YoUtil.get_int(xml_ado.text)
        xml_adp = xml_initCmd.find('Adp')
        if xml_adp != None:
            self.Adp = YoUtil.get_int(xml_adp.text)
        xml_Index = xml_initCmd.find('Index')
        if xml_Index != None:
            self.Index = YoUtil.get_int(xml_Index.text)
        xml_SubIndex = xml_initCmd.find('SubIndex')
        if xml_SubIndex != None:
            self.SubIndex = YoUtil.get_int(xml_SubIndex.text)

        xml_Data = xml_initCmd.find('Data')
        if xml_Data != None:
            self.Data = xml_Data.text

        xml_Cmd = xml_initCmd.find('Cmd')
        if xml_Cmd != None:
            self.Cmd = xml_Cmd.text

        xml_Cnt = xml_initCmd.find('Cnt')
        if xml_Cnt != None:
            self.Cnt = xml_Cnt.text

        if 'CompleteAccess' in xml_initCmd.attrib:
            self.CompleteAccess = xml_initCmd.attrib['CompleteAccess']
Пример #5
0
	def load_vendor(self):
		xml_esi = self.tree.getroot()
		if xml_esi!= None:
			xml_vendor = xml_esi.find('Vendor')
			if xml_vendor!= None:
				xml_id = xml_vendor.find('Id')
				if xml_id != None:
					self.id = YoUtil.get_int(xml_id.text)
				else:
					self.id=None
				xml_name = xml_vendor.find('Name')
				if xml_name != None:
					self.vendor_name = xml_name.text
Пример #6
0
	def get_ESI_files_by_vendor(self, vendor_id):
		files = self.get_ESI_files()
		ret = list()
		for pair in files:
			file_path = pair[1]
			xml_esi = self.load_esi(file_path)
			if xml_esi!= None:
				xml_vendor = xml_esi.find('Vendor')
				if xml_vendor!= None:
					xml_id = xml_vendor.find('Id')
					if xml_id != None:
						id = YoUtil.get_int(xml_id.text)
						if id == vendor_id:
							ret.append(file_path)
		return ret
Пример #7
0
def cmd_find(esi):			
	cmd = sys.argv[2].lower()
	if cmd == 'esi':
		files = esi.get_ESI_files()
		YoUtil.print_list(files,1)
	elif cmd == 'vendor':
		vendor_id = YoUtil.get_int(sys.argv[3])
		files = esi.get_ESI_files_by_vendor(vendor_id)
		YoUtil.print_list(files,1)
	elif cmd == 'createdb':
		if esi.create_esi_db('esi.db') == True:
			print('ESI DB created successfully')
		else:
			print('failed to create ESI DB ')
	elif cmd == 'device_esi':
		vendor_id = YoUtil.get_int(sys.argv[3])
		productCode = YoUtil.get_int(sys.argv[4])
		revisionNumber = None
		if len(sys.argv) > 5:
			revisionNumber = YoUtil.get_int(sys.argv[5])
		files = esi.get_devices(vendor_id,productCode,revisionNumber)
		YoUtil.print_list(files,1)
	else:
		print_usage('find')
Пример #8
0
	def get_devices(self, vendor_id,productCode,revisionNumber):
		ret = list()
		files = self.get_ESI_files_by_vendor(vendor_id)
		YoUtil.debug_print('num of files=',len(files))
		for file_path in files:
			xml_esi = self.load_esi(file_path)
			if xml_esi!= None:
				xml_list_device = xml_esi.findall('Descriptions/Devices/Device')
				YoUtil.debug_print('num of devices=',len(xml_list_device))
				for xml_device in xml_list_device:
					xml_type = xml_device.find('Type')
					if xml_type != None:
						pc = YoUtil.get_int(xml_type.attrib['ProductCode'])
						YoUtil.debug_print('ProductCode=',pc)
						if pc == productCode:
							ret.append(file_path)
		return ret
Пример #9
0
	def get_ESI_info(self,esi_path):
		esi = EsiFile(esi_path)
		vendor_id = 0
		vendor_name  = None
		self.esi_path = esi_path
		self.xml_esi = self.load_esi(esi_path)
		if self.xml_esi!= None:
			xml_vendor = self.xml_esi.find('Vendor')
			if xml_vendor!= None:
				xml_id = xml_vendor.find('Id')
				if xml_id != None:
					vendor_id = YoUtil.get_int(xml_id.text)
				xml_name = xml_vendor.find('Name')
				if xml_name != None:
					vendor_name = xml_name.text
						
		return vendor_id,vendor_name