forked from espressif/esp-idf
Merge branch 'fix/flash_progression_processing' into 'master'
tools: process progression for flash action output See merge request espressif/esp-idf!23911
This commit is contained in:
@@ -184,7 +184,7 @@ def action_extensions(base_actions: Dict, project_path: str) -> Dict:
|
|||||||
if extra_args:
|
if extra_args:
|
||||||
extra += shlex.split(extra_args)
|
extra += shlex.split(extra_args)
|
||||||
env = {'ESPBAUD': str(args.baud), 'ESPPORT': args.port, 'SERIAL_TOOL_EXTRA_ARGS': ';'.join(extra)}
|
env = {'ESPBAUD': str(args.baud), 'ESPPORT': args.port, 'SERIAL_TOOL_EXTRA_ARGS': ';'.join(extra)}
|
||||||
run_target(action, args, env)
|
run_target(action, args, env, force_progression=True)
|
||||||
|
|
||||||
def erase_flash(action: str, ctx: click.core.Context, args: PropertyDict) -> None:
|
def erase_flash(action: str, ctx: click.core.Context, args: PropertyDict) -> None:
|
||||||
ensure_build_directory(args, ctx.info_name)
|
ensure_build_directory(args, ctx.info_name)
|
||||||
|
@@ -293,6 +293,12 @@ class RunTool:
|
|||||||
print('\r' + fit_text_in_terminal(output.strip('\n\r')) + '\x1b[K', end='', file=output_stream)
|
print('\r' + fit_text_in_terminal(output.strip('\n\r')) + '\x1b[K', end='', file=output_stream)
|
||||||
output_stream.flush()
|
output_stream.flush()
|
||||||
|
|
||||||
|
def is_progression(output: str) -> bool:
|
||||||
|
# try to find possible progression by a pattern match
|
||||||
|
if re.match(r'^\[\d+/\d+\]|.*\(\d+ \%\)$', output):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
async def read_stream() -> Optional[str]:
|
async def read_stream() -> Optional[str]:
|
||||||
try:
|
try:
|
||||||
output_b = await input_stream.readline()
|
output_b = await input_stream.readline()
|
||||||
@@ -324,6 +330,8 @@ class RunTool:
|
|||||||
# used in interactive mode to print hints after matched line
|
# used in interactive mode to print hints after matched line
|
||||||
hints = load_hints()
|
hints = load_hints()
|
||||||
last_line = ''
|
last_line = ''
|
||||||
|
is_progression_last_line = False
|
||||||
|
is_progression_processing_enabled = self.force_progression and output_stream.isatty() and '-v' not in self.args
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(output_filename, 'w', encoding='utf8') as output_file:
|
with open(output_filename, 'w', encoding='utf8') as output_file:
|
||||||
@@ -344,10 +352,13 @@ class RunTool:
|
|||||||
if not output_stream.isatty():
|
if not output_stream.isatty():
|
||||||
output = output_noescape
|
output = output_noescape
|
||||||
|
|
||||||
if self.force_progression and output[0] == '[' and '-v' not in self.args and output_stream.isatty():
|
if is_progression_processing_enabled and is_progression(output):
|
||||||
# print output in progression way but only the progression related (that started with '[') and if verbose flag is not set
|
|
||||||
print_progression(output)
|
print_progression(output)
|
||||||
|
is_progression_last_line = True
|
||||||
else:
|
else:
|
||||||
|
if is_progression_last_line:
|
||||||
|
output_converter.write(os.linesep)
|
||||||
|
is_progression_last_line = False
|
||||||
output_converter.write(output)
|
output_converter.write(output)
|
||||||
output_converter.flush()
|
output_converter.flush()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user