mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 05:02:24 +00:00
config-tools: add progress bar and timeout mechanism for board_inspector
Added progress bar for board_inspector.py in all extractors and some detailed step. Added timeout mechanism for update-pciids command. Tracked-On: #7973 Reviewed-by: Junjie Mao <junjie.mao@intel.com> Signed-off-by: Ziheng Li <ziheng.li@intel.com>
This commit is contained in:
parent
b16fcda6b5
commit
c24aa87a65
@ -12,6 +12,7 @@ import tempfile
|
|||||||
import subprocess # nosec
|
import subprocess # nosec
|
||||||
import lxml.etree
|
import lxml.etree
|
||||||
import argparse
|
import argparse
|
||||||
|
from tqdm import tqdm
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ def check_deps():
|
|||||||
try:
|
try:
|
||||||
logger.info("Updating pci.ids for latest PCI device descriptions.")
|
logger.info("Updating pci.ids for latest PCI device descriptions.")
|
||||||
res = subprocess.Popen(["update-pciids", "-q"], stderr=subprocess.DEVNULL)
|
res = subprocess.Popen(["update-pciids", "-q"], stderr=subprocess.DEVNULL)
|
||||||
if res.wait() != 0:
|
if res.wait(timeout=40) != 0:
|
||||||
logger.warning(f"Failed to invoke update-pciids. No functional impact is foreseen, but descriptions of PCI devices may be inaccurate.")
|
logger.warning(f"Failed to invoke update-pciids. No functional impact is foreseen, but descriptions of PCI devices may be inaccurate.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to invoke update-pciids: {e}. No functional impact is foreseen, but descriptions of PCI devices may be unavailable.")
|
logger.warning(f"Failed to invoke update-pciids: {e}. No functional impact is foreseen, but descriptions of PCI devices may be unavailable.")
|
||||||
@ -146,8 +147,10 @@ def summary_loginfo(board_xml):
|
|||||||
def main(board_name, board_xml, args):
|
def main(board_name, board_xml, args):
|
||||||
print(f"Generating board XML {board_name}. This may take a few minutes...")
|
print(f"Generating board XML {board_name}. This may take a few minutes...")
|
||||||
|
|
||||||
|
with tqdm(total=100) as pbar:
|
||||||
# Check that the dependencies are met
|
# Check that the dependencies are met
|
||||||
check_deps()
|
check_deps()
|
||||||
|
pbar.update(10)
|
||||||
|
|
||||||
# Check if this is native os
|
# Check if this is native os
|
||||||
native_check()
|
native_check()
|
||||||
@ -163,7 +166,6 @@ def main(board_name, board_xml, args):
|
|||||||
legacy_parser = os.path.join(script_dir, "legacy", "board_parser.py")
|
legacy_parser = os.path.join(script_dir, "legacy", "board_parser.py")
|
||||||
env = { "PYTHONPATH": script_dir, "PATH": os.environ["PATH"] }
|
env = { "PYTHONPATH": script_dir, "PATH": os.environ["PATH"] }
|
||||||
subprocess.run([sys.executable, legacy_parser, args.board_name, "--out", board_xml], check=True, env=env)
|
subprocess.run([sys.executable, legacy_parser, args.board_name, "--out", board_xml], check=True, env=env)
|
||||||
|
|
||||||
# ... then load the created board XML and append it with additional data by invoking the extractors.
|
# ... then load the created board XML and append it with additional data by invoking the extractors.
|
||||||
board_etree = lxml.etree.parse(board_xml)
|
board_etree = lxml.etree.parse(board_xml)
|
||||||
root_node = board_etree.getroot()
|
root_node = board_etree.getroot()
|
||||||
@ -173,6 +175,7 @@ def main(board_name, board_xml, args):
|
|||||||
for elem in root_node:
|
for elem in root_node:
|
||||||
elem.tail = None
|
elem.tail = None
|
||||||
|
|
||||||
|
|
||||||
# Create nodes for each kind of resource
|
# Create nodes for each kind of resource
|
||||||
root_node.append(lxml.etree.Element("processors"))
|
root_node.append(lxml.etree.Element("processors"))
|
||||||
root_node.append(lxml.etree.Element("caches"))
|
root_node.append(lxml.etree.Element("caches"))
|
||||||
@ -180,6 +183,7 @@ def main(board_name, board_xml, args):
|
|||||||
root_node.append(lxml.etree.Element("ioapics"))
|
root_node.append(lxml.etree.Element("ioapics"))
|
||||||
root_node.append(lxml.etree.Element("devices"))
|
root_node.append(lxml.etree.Element("devices"))
|
||||||
root_node.append(lxml.etree.Element("device-classes"))
|
root_node.append(lxml.etree.Element("device-classes"))
|
||||||
|
pbar.update(10)
|
||||||
|
|
||||||
extractors_path = os.path.join(script_dir, "extractors")
|
extractors_path = os.path.join(script_dir, "extractors")
|
||||||
extractors = [f for f in os.listdir(extractors_path) if f[:2].isdigit()]
|
extractors = [f for f in os.listdir(extractors_path) if f[:2].isdigit()]
|
||||||
@ -189,18 +193,23 @@ def main(board_name, board_xml, args):
|
|||||||
if args.basic and getattr(module, "advanced", False):
|
if args.basic and getattr(module, "advanced", False):
|
||||||
continue
|
continue
|
||||||
module.extract(args, board_etree)
|
module.extract(args, board_etree)
|
||||||
|
if "50-acpi-namespace.py" in module_name:
|
||||||
|
pbar.update(30)
|
||||||
|
else:
|
||||||
|
pbar.update(10)
|
||||||
|
|
||||||
# Validate the XML against XSD assertions
|
# Validate the XML against XSD assertions
|
||||||
count = validator.validate_board(os.path.join(script_dir, 'schema', 'boardchecks.xsd'), board_etree)
|
count = validator.validate_board(os.path.join(script_dir, 'schema', 'boardchecks.xsd'), board_etree)
|
||||||
if count == 0:
|
if count == 0:
|
||||||
logger.info("All board checks passed.")
|
logger.info("All board checks passed.")
|
||||||
|
|
||||||
#Format and out put the log info
|
|
||||||
summary_loginfo(board_xml)
|
|
||||||
|
|
||||||
# Finally overwrite the output with the updated XML
|
# Finally overwrite the output with the updated XML
|
||||||
board_etree.write(board_xml, pretty_print=True)
|
board_etree.write(board_xml, pretty_print=True)
|
||||||
|
|
||||||
|
#Format and out put the log info
|
||||||
|
summary_loginfo(board_xml)
|
||||||
|
pbar.update(10)
|
||||||
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user