-
Notifications
You must be signed in to change notification settings - Fork 0
/
BandwidthMonitor.py
65 lines (50 loc) · 1.38 KB
/
BandwidthMonitor.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import time
import sys
from threading import Thread, Lock
import string
#---------------------------------------
class BandwidthMonitor(object):
#=======================================
def __init__(self, options = None):
self.netdecoder = None
self.localdecoder = None
self.processor = None
self.ui = None
self.net = None
self.localHosts = {}
self.netHosts = {}
self.lock = Lock()
self.options = options
self.exit = False
#Save this object so other modules can use it.
BandwidthMonitor.obj = self
#=======================================
def run(self):
#Personal packages
import Ui
import Local
import Net
import Processor
self.net = Net.Net()
self.ui = Ui.CursesUi()
self.netdecoder = Net.NetDecoderThread()
self.netdecoder.setDaemon(True)
self.netdecoder.start()
self.localdecoder = Local.LocalDecoderThread()
self.localdecoder.setDaemon(True)
self.localdecoder.start()
self.processor = Processor.ProcessorThread()
self.processor.setDaemon(True)
self.processor.start()
self.ui.run()
try:
while not self.exit:
time.sleep(0.1)
except KeyboardInterrupt, e:
pass
self.ui.stop()
sys.exit()
#=======================================
def exit(self):
self.exit = True