mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
change(tools): Unified outputs of various standalone scripts (esp-pylib)
This commit is contained in:
+12
-6
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Module was moved to the esptool in ESP-IDF v5.2 and relicensed under GPL v2.0 license.
|
||||
import argparse
|
||||
@@ -9,13 +9,18 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from esp_pylib.excepthook import install_exception_reporting
|
||||
from esp_pylib.logger import log
|
||||
from rich.markup import escape
|
||||
|
||||
|
||||
def main() -> None:
|
||||
install_exception_reporting()
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
def parse_chip_id(string: str) -> str:
|
||||
# compatibility layer with old script
|
||||
print("DEPRECATED option '--chip-id'. Please consider using '--chip' instead")
|
||||
log.warn("DEPRECATED option '--chip-id'. Please consider using '--chip' instead")
|
||||
# DO NOT add new IDs; they are now maintained in esptool.
|
||||
ids = {
|
||||
0x1C5F21B0: 'esp32',
|
||||
@@ -90,10 +95,11 @@ def main() -> None:
|
||||
bin_selection = [json_content[b] for b in args.bin]
|
||||
flash_dic = dict((x['offset'], x['file']) for x in bin_selection)
|
||||
except KeyError:
|
||||
print('Invalid binary was selected.')
|
||||
valid = [k if all(x in v for x in ('offset', 'file')) else None for k, v in json_content.items()]
|
||||
print('Valid ones:', ' '.join(x for x in valid if x))
|
||||
exit(1)
|
||||
# Keep pre-migration order and stdout stream.
|
||||
log.print('Invalid binary was selected.')
|
||||
log.print('Valid ones:', ' '.join(escape(x) for x in valid if x))
|
||||
sys.exit(1)
|
||||
else:
|
||||
flash_dic = json_content['flash_files']
|
||||
|
||||
@@ -124,7 +130,7 @@ def main() -> None:
|
||||
cmd.append('--md5-disable')
|
||||
|
||||
cmd_str = ' '.join(cmd + files_flatten)
|
||||
print(f'Executing: {cmd_str}')
|
||||
log.note(f'Executing: {escape(cmd_str)}')
|
||||
|
||||
sys.exit(subprocess.run(cmd + files_flatten).returncode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user