mirror of
https://github.com/XuehaiPan/nvitop.git
synced 2026-05-21 06:45:24 -06:00
feat: add more colors
This commit is contained in:
parent
dd15d568ec
commit
0ae0b55d6b
2 changed files with 11 additions and 2 deletions
10
nvhtop.py
10
nvhtop.py
|
|
@ -36,6 +36,7 @@ import time
|
|||
|
||||
import psutil
|
||||
from cachetools import cached, TTLCache
|
||||
from termcolor import colored
|
||||
|
||||
import pynvml as nvml
|
||||
|
||||
|
|
@ -246,7 +247,13 @@ class Top(object):
|
|||
curses.endwin()
|
||||
for row in self.rows:
|
||||
if not isinstance(row, str):
|
||||
row = row[0]
|
||||
row, attr = row
|
||||
color = {
|
||||
curses.color_pair(1): 'green',
|
||||
curses.color_pair(2): 'yellow',
|
||||
curses.color_pair(3): 'red',
|
||||
}.get(attr)
|
||||
row = colored(row, color)
|
||||
print(row)
|
||||
|
||||
def init_curses(self):
|
||||
|
|
@ -456,6 +463,7 @@ class Top(object):
|
|||
break
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
time.sleep(0.5)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
nvidia-ml-py
|
||||
psutil
|
||||
cachetools
|
||||
nvidia-ml-py
|
||||
termcolor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue