Merge branch 'feat/add_activate_debug_information_v5.4' into 'release/v5.4'

feat(tools): Imporve activate.py debug information (v5.4)

See merge request espressif/esp-idf!35170
This commit is contained in:
Roland Dobai
2024-11-25 17:41:59 +08:00
2 changed files with 16 additions and 5 deletions

View File

@ -14,7 +14,7 @@ from subprocess import SubprocessError
def die(msg: str) -> None:
sys.exit(f'error: {msg}')
sys.exit(f'\nERROR: {msg}')
idf_tools_path = os.path.realpath(os.path.dirname(__file__))
@ -37,7 +37,11 @@ os.environ['IDF_PATH'] = idf_path
os.environ['IDF_PYTHON_ENV_PATH'] = idf_python_env_path
os.environ['ESP_IDF_VERSION'] = idf_version
if not os.path.exists(virtualenv_python):
die(f'ESP-IDF Python virtual environment not found. Please run the install script to set it up before proceeding.')
try:
run([virtualenv_python, os.path.join(idf_path, 'tools', 'export_utils', 'activate_venv.py')] + sys.argv[1:], check=True)
except (OSError, SubprocessError):
die(f'Activation script failed')
die('\n'.join(['Activation script failed',
'To view detailed debug information, set ESP_IDF_EXPORT_DEBUG=1 and run the export script again.']))

View File

@ -87,9 +87,16 @@ def get_idf_env() -> Dict[str,str]:
'IDF_PYTHON_ENV_PATH': os.environ['IDF_PYTHON_ENV_PATH'],
}
for line in stdout.splitlines():
var, val = line.split('=')
idf_env[var] = val
try:
for line in stdout.splitlines():
var, val = line.split('=')
idf_env[var] = val
except ValueError as e:
debug('\n'.join(['Output from `./tools/idf_tools.py export --format key-value`:',
f'{stdout}']))
raise ValueError('\n'.join(['Please ensure your ESP-IDF installation is clean, especially file `./tools/idf_tools.py`.',
'The command `./tools/idf_tools.py export` appears to be returning unexpected values.',
f'Details: {e}']))
if 'PATH' in idf_env:
idf_env['PATH'] = os.pathsep.join([extra_paths, idf_env['PATH']])