config_tools: scenario setting UI with xsd schema config

render scenario setting UI with xsd schema config, validate scenario
setting with xsd validation.

Tracked-On: #5672

Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
Reviewed-by: Mao, Junjie <junjie.mao@intel.com>
Reviewed-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Shuang Zheng 2021-01-28 18:17:15 +08:00 committed by wenlingz
parent 94a980c923
commit bf88e24218
4 changed files with 222 additions and 46 deletions

View File

@ -6,7 +6,9 @@
"""
import os
import xml.etree.ElementTree as ElementTree
from xmlschema import XMLSchema11
from xmlschema.validators import Xsd11Element, XsdSimpleType, XsdAtomicBuiltin, Xsd11ComplexType, Xsd11Group, Xsd11Attribute
import lxml.etree as etree
class XmlConfig:
@ -29,7 +31,7 @@ class XmlConfig:
if os.path.splitext(xml_file)[1] != '.xml':
return xml_type
try:
tree = ElementTree.parse(xml_file)
tree = etree.parse(xml_file)
root = tree.getroot()
if 'uos_launcher' in root.attrib:
xml_type = 'uos_launcher'
@ -93,7 +95,7 @@ class XmlConfig:
if self._default \
else os.path.join(self._xml_path, 'user_defined', self._curr_xml + '.xml')
tree = ElementTree.parse(xml_path)
tree = etree.parse(xml_path)
self._curr_xml_tree = tree
except ValueError:
print('xml parse error: {}'.format(xml))
@ -170,7 +172,7 @@ class XmlConfig:
new_node_desc = node.attrib['desc']
dest_node.remove(node)
for value in values:
new_node = ElementTree.SubElement(dest_node, tag)
new_node = etree.SubElement(dest_node, tag)
new_node.text = value
if new_node_desc is not None:
new_node.attrib['desc'] = new_node_desc
@ -203,9 +205,9 @@ class XmlConfig:
dest_node = self._get_dest_node(*args)
if key in ['vm']:
ElementTree.SubElement(dest_node, key, attrib={'id': value, 'desc': desc})
etree.SubElement(dest_node, key, attrib={'id': value, 'desc': desc})
else:
new_node = ElementTree.SubElement(dest_node, key, attrib={'desc': desc})
new_node = etree.SubElement(dest_node, key, attrib={'desc': desc})
new_node.text = value
def get_curr_elem(self, *args):
@ -346,3 +348,169 @@ class XmlConfig:
else:
if depth and (not element.tail or not element.tail.strip()):
element.tail = i
def get_acrn_config_element(xsd_file):
"""
return the root element for the xsd file
:param xsd_file: the input xsd schema file
:return: the root element of the xsd file
"""
# schema = XMLSchema11(xsd_file)
xsd_doc = etree.parse(xsd_file)
xsd_doc.xinclude()
schema = XMLSchema11(etree.tostring(xsd_doc, encoding="unicode"))
xsd_element_root = schema.root_elements[0]
acrn_config_element_root = xsd_2_acrn_config_element(xsd_element_root)
# doc_dict = acrn_config_element_2_doc_dict(acrn_config_element_root, {})
# enum_dict = acrn_config_element_2_enum_dict(acrn_config_element_root, {})
# xpath_dict = acrn_config_element_2_xpath_dict(acrn_config_element_root, {})
# from pprint import pprint
# pprint(acrn_config_element_root)
# pprint(xpath_dict)
return acrn_config_element_root
def xsd_2_acrn_config_element(xsd_element, layer=0, index=0, path=''):
"""
translate XSD element to ACRN config element
:param xsd_element: the xsd element
:param layer: current layer
:param index: current index of current layer
:param path: path of current element
:return: ACRN config element
"""
acrn_config_element = {
'name': xsd_element.name,
'type': None,
'path': path+'/'+xsd_element.name,
'layer': layer,
'index': index,
'doc': None,
'configurable': 'y',
'readonly': 'n',
'multiselect': 'n',
'default': xsd_element.default,
'attributes': None,
# 'minOccurs': None,
# 'maxOccurs': None,
'enumeration': None,
'sub_elements': None
}
if isinstance(xsd_element.type, Xsd11ComplexType):
acrn_config_element['type'] = xsd_element.type.name
for xsd_component in xsd_element.type.iter_components():
if isinstance(xsd_component, Xsd11Group):
if acrn_config_element['sub_elements'] is None:
acrn_config_element['sub_elements'] = {'all':[], 'choice':[], 'sequence':[]}
index = 0
for sub_xsd_component in xsd_component.iter_components():
if isinstance(sub_xsd_component, Xsd11Element):
sub_acrn_config_element = xsd_2_acrn_config_element(sub_xsd_component, layer+1,
index, path+'/'+xsd_element.name)
acrn_config_element['sub_elements'][xsd_component.model].append(sub_acrn_config_element)
index += 1
else:
if isinstance(xsd_element.type, XsdAtomicBuiltin):
acrn_config_element['type'] = xsd_element.type.name
elif isinstance(xsd_element.type.base_type, XsdSimpleType):
acrn_config_element['type'] = xsd_element.type.base_type.name
else:
acrn_config_element['type'] = xsd_element.type.name
if xsd_element.type.enumeration:
acrn_config_element['enumeration'] = xsd_element.type.enumeration
annotation = None
if hasattr(xsd_element, 'annotation') and xsd_element.annotation:
annotation = xsd_element.annotation
elif hasattr(xsd_element.type, 'annotation') and xsd_element.type.annotation:
annotation = xsd_element.type.annotation
if annotation:
if annotation.documentation:
doc_list = [documentation.text for documentation in annotation.documentation]
acrn_config_element['doc'] = '\n'.join(doc_list)
for key in annotation.elem.keys():
if key.endswith('configurable'):
acrn_config_element['configurable'] = annotation.elem.get(key)
elif key.endswith('readonly'):
acrn_config_element['readonly'] = annotation.elem.get(key)
elif key.endswith('multiselect'):
acrn_config_element['multiselect'] = annotation.elem.get(key)
if xsd_element.attributes:
attrs = []
for attr in xsd_element.attributes.iter_components():
if isinstance(attr, Xsd11Attribute):
attrs.append({'name': attr.name, 'type': attr.type.name})
acrn_config_element['attributes'] = attrs
return acrn_config_element
def acrn_config_element_2_doc_dict(acrn_config_element, doc_dict):
"""
get the dictionary for documentation of all configurable elements by ACRN config element.
:param acrn_config_element: the ACRN config element
:param doc_dict: the dictionary to save documentation of all configurable elements
:return: the dictionary to save documentation of all configurable elements
"""
if 'doc' in acrn_config_element and 'path' in acrn_config_element \
and acrn_config_element['path'] not in doc_dict:
if acrn_config_element['doc']:
doc_dict[acrn_config_element['path']] = acrn_config_element['doc']
else:
doc_dict[acrn_config_element['path']] = acrn_config_element['name']
if 'sub_elements' in acrn_config_element and acrn_config_element['sub_elements']:
for order_type in acrn_config_element['sub_elements']:
for element in acrn_config_element['sub_elements'][order_type]:
doc_dict = acrn_config_element_2_doc_dict(element, doc_dict)
return doc_dict
def acrn_config_element_2_enum_dict(acrn_config_element, enum_dict):
"""
get the dictionary for enumeration of all configurable elements by ACRN config element.
:param acrn_config_element: the ACRN config element
:param enum_dict: the dictionary to save enumeration of all configurable elements
:return: the dictionary to save enumeration of all configurable elements
"""
if 'enumeration' in acrn_config_element and 'path' in acrn_config_element \
and acrn_config_element['path'] not in enum_dict \
and acrn_config_element['enumeration']:
enum_dict[acrn_config_element['path']] = acrn_config_element['enumeration']
if 'sub_elements' in acrn_config_element and acrn_config_element['sub_elements']:
for order_type in acrn_config_element['sub_elements']:
for element in acrn_config_element['sub_elements'][order_type]:
enum_dict = acrn_config_element_2_enum_dict(element, enum_dict)
return enum_dict
def acrn_config_element_2_xpath_dict(acrn_config_element, xpath_dict):
"""
get the dictionary for xpath of all configurable elements by ACRN config element.
:param acrn_config_element: the ACRN config element
:param xpath_dict: the dictionary to save xpath of all configurable elements
:return: the dictionary to save xpath of all configurable elements
"""
if acrn_config_element['path'] not in xpath_dict.keys():
xpath_dict[acrn_config_element['path']] = {
'name': acrn_config_element['name'],
'type': acrn_config_element['type'],
'layer': acrn_config_element['layer'],
'index': acrn_config_element['index'],
'doc': acrn_config_element['doc'] if acrn_config_element['doc'] else acrn_config_element['name'],
'configurable': acrn_config_element['configurable'],
'readonly': acrn_config_element['readonly'],
'multiselect': acrn_config_element['multiselect'],
'default': acrn_config_element['default'],
'attributes': acrn_config_element['attributes'],
# 'minOccurs': None,
# 'maxOccurs': None,
'enumeration': acrn_config_element['enumeration']
}
if 'sub_elements' in acrn_config_element and acrn_config_element['sub_elements']:
for order_type in acrn_config_element['sub_elements']:
for element in acrn_config_element['sub_elements'][order_type]:
enum_dict = acrn_config_element_2_xpath_dict(element, xpath_dict)
return xpath_dict

View File

@ -1,3 +1,4 @@
Flask==1.1.1
flask_bootstrap==3.3.7.1
xmlschema==1.4.1
lxml==4.6.2

View File

@ -121,7 +121,8 @@ the source files will be generated into default path and overwirte the previous
{% do vm_kata.append(1) %}
{% endif %}
{% set first_multi_child = {'IVSHMEM_REGION': 0, 'communication_vuart': 1} %}
{% if 'configurable' not in vm.attrib or vm.attrib['configurable'] != '0'%}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag])]['configurable'] == 'y' or
vm.xpath(xpath_dict['/'.join(['/acrn-config', vm.tag])]['configurable'])%}
<tr>
<td>
{% if vm.tag != 'vm' %}
@ -157,16 +158,16 @@ the source files will be generated into default path and overwirte the previous
<td>
{% for elem in vm|list %}
{% set elem_text = elem.text if elem.text != None else '' %}
{% if elem|list == [] and ('configurable' not in elem.attrib or elem.attrib['configurable']
!= '0')%}
{% if elem|list == [] and (xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['configurable']
== 'y' or elem.xpath(xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['configurable']))%}
<div class="form-group">
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">{{elem.tag}}</label>
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['doc']}}">{{elem.tag}}</label>
<label class="col-sm-2 control-label"></label>
{% if ','.join([vm.tag, elem.tag]) not in scenario_item_values %}
<div class="col-sm-6">
{% if 'readonly' in elem.attrib and elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['readonly'] == 'y' %}
<input type="text" class="form-control" id="{{vm_type+','+elem.tag}}"
value="{{elem_text}}" readonly>
{% else %}
@ -176,7 +177,7 @@ the source files will be generated into default path and overwirte the previous
</div>
{% else %}
<div class="dropdown col-sm-6">
{% if 'readonly' in elem.attrib and elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['readonly'] == 'y' %}
<select class="selectpicker" data-width="auto"
id="{{vm_type+','+elem.tag}}" disabled>
{% else %}
@ -196,9 +197,9 @@ the source files will be generated into default path and overwirte the previous
{% endif %}
<p id="{{vm_type+','+elem.tag}}_err" class="col-sm-3"></p>
</div>
{% elif elem|list != [] and ('configurable' not in elem.attrib or elem.attrib['configurable']
!= '0')%}
{% if 'multiselect' not in elem.attrib or elem.attrib['multiselect'] != 'true' %}
{% elif elem|list != [] and (xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['configurable']
== 'y' or elem.xpath(xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['configurable']))%}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['multiselect'] != 'y' %}
{% set first_child = [] %}
{% for sub_elem in elem|list %}
{% set sub_elem_text = sub_elem.text if sub_elem.text != None else '' %}
@ -209,13 +210,13 @@ the source files will be generated into default path and overwirte the previous
{% if ','.join([vm.tag, elem.tag, sub_elem.tag, sub_elem_2.tag]) in scenario_item_values %}
<div class="form-group">
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['doc']}}">
</label>
<label class="col-sm-2 control-label" data-toggle="tooltip"
title="{{sub_elem_2.attrib['desc'] if 'desc' in sub_elem_2.attrib else sub_elem.attrib['desc']}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag, sub_elem_2.tag])]['doc']}}">
{{sub_elem.tag}}&nbsp;&nbsp;&nbsp;&nbsp;{{sub_elem_2.tag}}</label>
<div class="dropdown col-sm-6">
{% if 'readonly' in sub_elem_2.attrib and sub_elem_2.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag, sub_elem_2.tag])]['readonly'] == 'y' %}
<select class="selectpicker" data-width="auto"
id="{{vm_type+','+elem.tag+','+sub_elem.tag+','+sub_elem_2.tag}}" disabled>
{% else %}
@ -237,17 +238,17 @@ the source files will be generated into default path and overwirte the previous
{% else %}
<div class="form-group">
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['doc']}}">
</label>
<label class="col-sm-2 control-label" data-toggle="tooltip"
title="{{sub_elem_2.attrib['desc'] if 'desc' in sub_elem_2.attrib else sub_elem.attrib['desc']}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag, sub_elem_2.tag])]['doc']}}">
{{sub_elem.tag}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{sub_elem_2.tag}}</label>
{% if sub_elem_2.tag in ['IVSHMEM_REGION'] %}
<div class="col-sm-5">
{% else %}
<div class="col-sm-6">
{% endif %}
{% if 'readonly' in sub_elem_2.attrib and sub_elem_2.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag, sub_elem_2.tag])]['readonly'] == 'y' %}
<input type="text" class="form-control"
id="{{vm_type+','+elem.tag+','+sub_elem.tag+','+sub_elem_2.tag}}"
readonly vaule="{{sub_elem_2_text}}"></input>
@ -278,28 +279,28 @@ the source files will be generated into default path and overwirte the previous
{% else %}
{% if 'configurable' not in sub_elem.attrib or sub_elem.attrib['configurable'] != '0' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['configurable'] == 'y' or
sub_elem.xpath(xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['configurable'])%}
<div class="form-group">
{% if 'id' not in elem.attrib %}
{% if not first_child %}
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['doc']}}">
{{elem.tag}}</label>
{% else %}
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">
<label class="col-sm-1 control-label" data-toggle="tooltip">
</label>
{% endif %}
<label class="col-sm-2 control-label" data-toggle="tooltip"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['doc']}}">
{{sub_elem.tag}}</label>
{% if ','.join([vm.tag, elem.tag, sub_elem.tag]) not in scenario_item_values
and elem.tag != 'cpu_affinity' and elem.tag != 'pci_devs' %}
{% if sub_elem.tag in ['bootargs', 'kern_args'] %}
<div class="col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['readonly'] == 'y' %}
<textarea type="text" class="form-control" style="height:120px"
id="{{vm_type+','+elem.tag+','+sub_elem.tag}}"
readonly>{{sub_elem_text}}</textarea>
@ -310,7 +311,7 @@ the source files will be generated into default path and overwirte the previous
</div>
{% else %}
<div class="col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['readonly'] == 'y' %}
<input type="text" class="form-control"
id="{{vm_type+','+elem.tag+','+sub_elem.tag}}"
value="{{sub_elem_text}}" readonly>
@ -326,7 +327,7 @@ the source files will be generated into default path and overwirte the previous
{% set item_key = ','.join([vm.tag, elem.tag, sub_elem.tag]) if elem.tag != 'cpu_affinity'
and elem.tag != 'pci_devs' else ','.join([vm.tag, elem.tag]) %}
<div class="dropdown col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['readonly'] == 'y' %}
<select class="selectpicker" data-width="auto"
id="{{vm_type+','+elem.tag+','+sub_elem.tag}}" disabled>
{% else %}
@ -368,24 +369,23 @@ the source files will be generated into default path and overwirte the previous
{% do first_child.append(1) %}
<label class="col-sm-1 control-label" data-toggle="tooltip"
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}_label1"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['doc']}}">
{{elem.tag+' '+elem.attrib['id']}}</label>
{% else %}
<label class="col-sm-1 control-label" data-toggle="tooltip"
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}_label1"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}_label1">
</label>
{% endif %}
<label class="col-sm-2 control-label" data-toggle="tooltip"
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}_label2"
title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}">
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['doc']}}">
{{sub_elem.tag}}</label>
{% if (','.join([vm.tag, elem.tag, sub_elem.tag]) not in scenario_item_values) and
((elem.tag!='vuart' and elem.tag!='legacy_vuart') or sub_elem.tag!='base') %}
<div class="col-sm-6"
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}_config">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['readonly'] == 'y' %}
<input type="text" class="form-control"
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}"
value="{{sub_elem_text}}" readonly>
@ -399,7 +399,7 @@ the source files will be generated into default path and overwirte the previous
<div class="dropdown col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag, sub_elem.tag])]['readonly'] == 'y' %}
<select class="selectpicker" data-width="auto" disabled
id="{{vm_type+','+elem.tag+':id='+elem.attrib['id']+','+sub_elem.tag}}">
{% else %}
@ -436,14 +436,14 @@ the source files will be generated into default path and overwirte the previous
{% endif %}
{% endif %}
{% endfor %}
{% elif 'configurable' not in elem.attrib or elem.attrib['configurable'] != '0' %}
{% elif xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['configurable'] == 'y' or
elem.xpath(xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['configurable'])%}
<div class="form-group">
<label class="col-sm-1 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}">{{elem.tag}}</label>
<label class="col-sm-2 control-label" data-toggle="tooltip"
title="{{elem.attrib['desc'] if 'desc' in elem.attrib else elem.tag}}"></label>
title="{{xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['doc']}}">{{elem.tag}}</label>
<label class="col-sm-2 control-label" data-toggle="tooltip"></label>
<div class="dropdown col-sm-6">
{% if 'readonly' in elem.attrib and elem.attrib['readonly'] == 'true' %}
{% if xpath_dict['/'.join(['/acrn-config', vm.tag, elem.tag])]['readonly'] == 'y' %}
<select class="selectpicker" data-width="auto" disabled
id="{{vm_type+','+elem.tag+','+elem.tag[:-1]}}"
multiple>

View File

@ -19,7 +19,7 @@ from flask import request, render_template, Blueprint, redirect, url_for, curren
# Refer to https://github.com/pallets/werkzeug/blob/master/LICENSE.rst for the permission notice.
from werkzeug.utils import secure_filename
from controller import XmlConfig
from controller import *
from scenario_config.scenario_cfg_gen import get_scenario_item_values
from scenario_config.scenario_cfg_gen import validate_scenario_setting
from launch_config.launch_cfg_gen import get_launch_item_values
@ -66,6 +66,9 @@ def scenario(scenario_name):
board_info, board_type, scenario_config, launch_config = get_xml_configs()
(bios_info, base_board_info) = get_board_info(board_info)
acrn_config_element_root = get_acrn_config_element(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'schema', 'config.xsd'))
xpath_dict = acrn_config_element_2_xpath_dict(acrn_config_element_root, {})
current_app.config.update(SCENARIO=scenario_name)
@ -79,6 +82,9 @@ def scenario(scenario_name):
scenario_item_values = get_scenario_item_values(
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', board_info+'.xml'),
scenario_file_path)
for xpath in xpath_dict:
if xpath_dict[xpath]['enumeration'] and len(xpath.split('/')) > 2:
scenario_item_values[','.join(xpath.split('/')[2:])] = xpath_dict[xpath]['enumeration']
return render_template('scenario.html', board_info_list=get_board_list(),
board_info=board_info, board_type=board_type,
@ -86,7 +92,8 @@ def scenario(scenario_name):
scenarios=scenario_config.list_all(xml_type='scenario'),
launches=launch_config.list_all(xml_type='uos_launcher'),
scenario=scenario_name, root=scenario_config.get_curr_root(),
scenario_item_values=scenario_item_values)
scenario_item_values=scenario_item_values,
xpath_dict=xpath_dict)
@CONFIG_APP.route('/launch', methods=['GET'])
@ -1009,7 +1016,7 @@ def get_board_type(board_info):
board_type = None
if board_config is not None:
board_info_root = board_config.get_curr_root()
if board_info_root and 'board' in board_info_root.attrib:
if board_info_root is not None and 'board' in board_info_root.attrib:
board_type = board_info_root.attrib['board']
return board_type
@ -1026,7 +1033,7 @@ def get_board_info(board_info):
base_board_info = None
if board_config is not None:
board_info_root = board_config.get_curr_root()
if board_info_root:
if board_info_root is not None:
for item in list(board_info_root):
if item.tag == 'BIOS_INFO':
for line in item.text.split('\n'):
@ -1096,7 +1103,7 @@ def get_board_rdt_res_clos_max(board_file_name):
if board_config is not None:
board_info_root = board_config.get_curr_root()
if board_info_root:
if board_info_root is not None:
for item in list(board_info_root):
if item.tag == 'CLOS_INFO':
for line in item.text.split('\n'):