Skip to content

Commit

Permalink
Update resource_mon.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sohwaje authored Jun 2, 2020
1 parent 55a747f commit 308a5c2
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions resource_mon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def tear_down():
curses.echo()
curses.endwin()


win = curses.initscr()
atexit.register(tear_down)
curses.endwin()
Expand All @@ -43,7 +42,6 @@ def print_line(line, highlight=False):

# --- /curses stuff


def poll(interval):
# sleep some time
time.sleep(interval)
Expand All @@ -60,7 +58,7 @@ def get_dashes(perc):
percs = psutil.cpu_percent(interval=0, percpu=True)
for cpu_num, perc in enumerate(percs):
dashes, empty_dashes = get_dashes(perc)
line= (" CPU%-2s [%s%s] %5s%%" % (cpu_num, dashes, empty_dashes,
line = (" CPU%-2s [%s%s] %5s%%" % (cpu_num, dashes, empty_dashes,
perc))
print_line(line)

Expand Down Expand Up @@ -88,17 +86,12 @@ def get_dashes(perc):

def refresh_window():
"""Print results on screen by using curses."""
global lineno
lineno = 0
curses.endwin()
win.erase()
print_header()

for p in range(1, 100):
try:
print_line("")
except curses.error:
break
win.refresh()

win.refresh()

def main():
try:
Expand All @@ -110,6 +103,5 @@ def main():
except (KeyboardInterrupt, SystemExit):
pass


if __name__ == '__main__':
main()

0 comments on commit 308a5c2

Please sign in to comment.