def get_cpu_xml(device_xml, ccs_path): """Returns the full path to cpu xml specified in given device xml Args: device_xml (str): full path to device xml to parse Returns: str: full path to cpu xml """ cpu_xml = None root = __get_device_root(device_xml) cpu_element = root.find(".//cpu") p_cpu_element = root.find(".//cpu/..") if cpu_element is None or p_cpu_element is None: raise DeviceError("Error parsing cpu from device xml: %s" % device_xml) instance_element = xmlhelper.get_sibling(cpu_element, p_cpu_element, -1) if instance_element is None: raise DeviceError("Error parsing instance-cpu from device xml: %s" % device_xml) xml_name = xmlhelper.get_attrib_value(instance_element.attrib, ["xml"]) cpu_xml = get_cpus_directory(ccs_path) + '/' + xml_name cpu_xml = os.path.normpath(cpu_xml) return cpu_xml
def get_default_connection_xml(device_xml, ccs_path): """Returns the default connection xml from the device xml file Args: device_xml (str): full path to device xml file Returns: str: default connection xml set in device xml file Raises: DeviceError: raised if device xml does not contain 'default connection' """ connection_xml = None root = __get_device_root(device_xml) conn_element = root.find(".//property[@id='DefaultConnection']") if conn_element is None: raise DeviceError("Device XML: %s does not contain a Default " "Connection type." % device_xml) xml_name = xmlhelper.get_attrib_value(conn_element.attrib, ["Value"]) connection_xml = get_connections_directory(ccs_path) + '/' + xml_name connection_xml = os.path.normpath(connection_xml) return connection_xml
def get_cpu(device_xml): """Returns the cpu name from device xml file. Args: device_xml (str): full path to the device xml file to parse Returns: str: cpu name """ cpu = None root = __get_device_root(device_xml) cpu_element = root.find(".//cpu") if cpu_element is None: raise DeviceError("Error parsing cpu from device xml: %s" % device_xml) cpu = xmlhelper.get_attrib_value(cpu_element.attrib, ["desc", "id"]) return cpu
def get_devicetype(device_xml): """Returns the devicetype from the device xml file Args: device_xml (str): full path to device xml file Returns: str: devicetype set in device xml file """ devicetype = None root = __get_device_root(device_xml) if root.tag != "device": raise DeviceError("Error parsing devicetype from device xml: %s" % device_xml) devicetype = xmlhelper.get_attrib_value(root.attrib, ["desc", "partnum", "id"]) return devicetype
def get_connection(ccxml_path): """Returns the connection from the ccxml file Args: ccxml_path (str): full path to ccxml file to parse Returns: str: connection set in ccxml file """ connection = None root = __get_ccxml_root(ccxml_path) instance = root.find("configuration/connection") if instance is None: raise CCXMLError("Error parsing connection from ccxml.") connection = xmlhelper.get_attrib_value(instance.attrib, ["id"]) return connection
def get_devicetype(ccxml_path): """Returns the devicetype from the ccxml file Args: ccxml_path (str): full path to ccxml file to parse Returns: str: devicetype set in ccxml file """ devicetype = None root = __get_ccxml_root(ccxml_path) instance = root.find("configuration/connection/platform/instance") if instance is None: raise CCXMLError("Error parsing devicetype from ccxml.") devicetype = xmlhelper.get_attrib_value(instance.attrib, ["desc", "id"]) return devicetype
def get_connection_name(conn_xml): """ Returns full connection name (as specified in connectionxml) Opens connection xml file and reads 'desc' of connection tag. Args: conn_xml (str): full path to connection xml file to parse Returns: str: connection name Raises: ConnectionsError: raises exception xml is unable to be parsed """ root = __get_connection_root(conn_xml) if root.tag != "connection": raise ConnectionsError("Error parsing connection xml: %s" % conn_xml) connection_name = xmlhelper.get_attrib_value(root.attrib, ["desc", "id"]) return connection_name
def get_serno(ccxml_path): """Returns the serno from the ccxml file Args: ccxml_path (str): full path to ccxml file to parse Returns: str: serial number set in ccxml file """ serno = None root = __get_ccxml_root(ccxml_path) instance = root.find("configuration/connection/" "property[@id='Debug Probe Selection']/" "choice[@Name='Select by serial number']/property") if instance is None: raise CCXMLError("%s does not support Debug Probe Selection" % ccxml_path) serno = xmlhelper.get_attrib_value(instance.attrib, ["Value"]) return serno
def get_cpu_name(xml_file): """ Returns full cpu name (as specified in cpuxml) Opens cpu xml file and reads 'id' of cpu tag. Args: xml_file (str): full path to cpu xml file to parse Returns: str: cpu name Raises: CPUError: raises exception xml is unable to be parsed """ root = __get_cpu_root(xml_file) if root.tag != "cpu": raise CPUError("Error parsing cpu xml: %s" % cpu_xml) cpu_name = xmlhelper.get_attrib_value(root.attrib, ["desc", "id"]) return cpu_name