mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 06:51:49 +00:00
misc: configurator: bugfix: incorrect path split
Board files with multiple dots in their name may be splitted incorrectly, and os.path.basename assumes os.name == posix in pyodide environment. This workaround partially fixes this problem whenever the the board filename does not contain '\' character. Tracked-On: #7582 Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
This commit is contained in:
parent
63ff99a8da
commit
2edd704a3b
@ -4,6 +4,7 @@ __package__ = 'configurator.pyodide'
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
import elementpath
|
import elementpath
|
||||||
@ -114,15 +115,20 @@ def get_cat_info(soup):
|
|||||||
|
|
||||||
def get_board_info(board, path):
|
def get_board_info(board, path):
|
||||||
soup = BeautifulSoup(board, 'xml')
|
soup = BeautifulSoup(board, 'xml')
|
||||||
|
# Workaround: The pyodide thinks it runs under os.name == posix.
|
||||||
|
# So os.path.basename will not work on windows.
|
||||||
|
# Here we replace all '\' with '/' to make it work (most of the time).
|
||||||
try:
|
try:
|
||||||
board_name = re.split('[\\\\/.]', path)[-2]
|
path = path.replace('\\', '/')
|
||||||
if board_name == 'board':
|
fname = os.path.basename(path)
|
||||||
board_name = re.split('[\\\\/.]', path)[-3]
|
basename, _ = os.path.splitext(fname)
|
||||||
except IndexError as e:
|
board_name = basename + '.xml' if basename.endswith('.board') \
|
||||||
|
else basename + '.board.xml'
|
||||||
|
except Exception as e:
|
||||||
logging.warning(e)
|
logging.warning(e)
|
||||||
board_name = 'default'
|
board_name = 'default'
|
||||||
result = {
|
result = {
|
||||||
'name': board_name + '.board.xml',
|
'name': board_name,
|
||||||
'content': board,
|
'content': board,
|
||||||
'CAT_INFO': get_cat_info(soup),
|
'CAT_INFO': get_cat_info(soup),
|
||||||
'BIOS_INFO': soup.select_one('BIOS_INFO').text,
|
'BIOS_INFO': soup.select_one('BIOS_INFO').text,
|
||||||
|
Loading…
Reference in New Issue
Block a user