-
Notifications
You must be signed in to change notification settings - Fork 0
/
pytop.py
executable file
·39 lines (31 loc) · 987 Bytes
/
pytop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import curses
import sys
from threading import Thread
from threading import Semaphore
from processes_module import ProcessesModule
from clock_module import ClockModule
painting_semaphore = Semaphore(value=1)
def main(argv=None):
if argv is None:
argv = sys.argv
try:
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(1)
proc_mod = ProcessesModule(semaphore=painting_semaphore)
clock_mod = ClockModule(semaphore=painting_semaphore, method_list=(proc_mod.refresh_processes,))
proc_mod_process = Thread(target = proc_mod.run)
clock_mod_process = Thread(target = clock_mod.run)
proc_mod_process.start()
clock_mod_process.start()
proc_mod_process.join()
finally:
curses.nocbreak()
curses.echo()
stdscr.keypad(0)
curses.endwin()
if __name__ == "__main__":
sys.exit(main())