Increased Process Name width to support long names.
This commit is contained in:
1 parent
d029ead761
commit
e12e3ed614
1 file changed
+4
-4
+4
-4
@@ -48,14 +48,14 @@ def get_top_processes(limit):
|
|||||||
return processes[:limit]
|
return processes[:limit]
|
||||||
|
|
||||||
def colorize(cpu, name, user, use_color):
|
def colorize(cpu, name, user, use_color):
|
||||||
limit = 25
|
limit = 35
|
||||||
if len(name) > limit:
|
if len(name) > limit:
|
||||||
display_name = name[:limit - 3] + "..."
|
display_name = name[:limit - 3] + "..."
|
||||||
else:
|
else:
|
||||||
display_name = name
|
display_name = name
|
||||||
|
|
||||||
if cpu <= 25 or not use_color:
|
if cpu <= 25 or not use_color:
|
||||||
return f"{cpu:6.2f}% {display_name:<25} {user[:15]:<15}"
|
return f"{cpu:6.2f}% {display_name:<35} {user[:15]:<15}"
|
||||||
else:
|
else:
|
||||||
YELLOW = "\033[33m"
|
YELLOW = "\033[33m"
|
||||||
ORANGE = "\033[38;5;214m"
|
ORANGE = "\033[38;5;214m"
|
||||||
@@ -63,7 +63,7 @@ def colorize(cpu, name, user, use_color):
|
|||||||
RESET_TO_GREEN = "\033[32m"
|
RESET_TO_GREEN = "\033[32m"
|
||||||
color = YELLOW if cpu <= 50 else ORANGE if cpu <= 75 else RED
|
color = YELLOW if cpu <= 50 else ORANGE if cpu <= 75 else RED
|
||||||
cpu_str = f"{cpu:6.2f}%"
|
cpu_str = f"{cpu:6.2f}%"
|
||||||
return f"{color}{cpu_str} {display_name:<25} {user[:15]:<15}{RESET_TO_GREEN}"
|
return f"{color}{cpu_str} {display_name:<35} {user[:15]:<15}{RESET_TO_GREEN}"
|
||||||
|
|
||||||
def print_processes(limit, show_quit_hint=True, use_color=True):
|
def print_processes(limit, show_quit_hint=True, use_color=True):
|
||||||
clear_screen()
|
clear_screen()
|
||||||
@@ -75,7 +75,7 @@ def print_processes(limit, show_quit_hint=True, use_color=True):
|
|||||||
print(GREEN, end='')
|
print(GREEN, end='')
|
||||||
|
|
||||||
print(" CPU Process User")
|
print(" CPU Process User")
|
||||||
print("----------------------------------------------")
|
print("----------------------------------------------------------")
|
||||||
|
|
||||||
for (cpu, name, user) in top_processes:
|
for (cpu, name, user) in top_processes:
|
||||||
print(colorize(cpu, name, user, use_color))
|
print(colorize(cpu, name, user, use_color))
|
||||||
|
|||||||
Reference in new issue
Block a user