From e9b30b738c4a846ca18cad05737090b2cc54bae8 Mon Sep 17 00:00:00 2001 From: lxbhahaha <1580622474@qq.com> Date: Tue, 26 Mar 2024 17:59:48 +0800 Subject: [PATCH] update --- check.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/check.py b/check.py index c5aafde..f0e16d8 100644 --- a/check.py +++ b/check.py @@ -140,9 +140,14 @@ def get_bar(bar_ratio, max_len, color=False): assert 0 <= bar_ratio <= 1 res = [] used_len = int(bar_ratio * max_len) - res.append('|' * used_len) - res.append(' ' * (max_len-used_len)) + res.extend(['|'] * used_len) + res.extend([' '] * (max_len-used_len)) + if color: + res.insert(int(max_len*0.4), COLOR_YELLOW) + res.insert(int(max_len*0.8)+1, f'{END_COLOR}{COLOR_RED}') + res.append(END_COLOR) + return ''.join(res) def print_table_res(data_list): @@ -253,11 +258,11 @@ def print_table_res(data_list): str_list.append(table_icon['vline']) # 显存进度条 - str_list.append(get_bar(used_mem/total_mem, cell_width_list[2])) + str_list.append(get_bar(used_mem/total_mem, cell_width_list[2], True)) str_list.append(table_icon['vline']) # 利用率进度条 - str_list.append(get_bar(util_gpu/100, cell_width_list[3])) + str_list.append(get_bar(util_gpu/100, cell_width_list[3], True)) str_list.append(table_icon['vline']) print(''.join(str_list))