-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patht2IP.py
executable file
·48 lines (41 loc) · 1.23 KB
/
t2IP.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
#!/usr/bin/python
from discoveryServer import discoveryServer
from rtspServer import rtspServer
from scanning import scanning
import threading
def main():
# Make sure that t2IP.log file is clean
fLog = open('logs/t2IP.log', 'w')
# Thread 1 discoveryServer
t1 = threading.Thread(target=discoveryServer)
t1.daemon = True
t1.start()
fLog.write('Info: discoveryServer started\n')
fLog.close()
# Thread 2 rtspServer
fLog = open('logs/t2IP.log', 'a')
t2 = threading.Thread(target=rtspServer)
t2.daemon = True
t2.start()
fLog.write('Info: rtspServer started\n')
fLog.close()
# Thread 3 scanning (w_scan)
fLog = open('logs/t2IP.log', 'a')
# Default period for new scan is 3600 seconds.
periodNewScan = 1
scanningFlag = 0
t3 = threading.Thread(target=scanning, args=[periodNewScan, scanningFlag])
t3.daemon = True
t3.start()
fLog.write('Info: scanning started\n')
fLog.write('Info: period for new scan is ' + str(periodNewScan) + ' and scanningFlag is ' + str(scanningFlag))
fLog.close()
# Keep threads alive until KeyboardInterrupt
try:
while t1.is_alive() and t2.is_alive():
t1.join(timeout=1.0)
t2.join(timeout=1.0)
except (KeyboardInterrupt, SystemExit):
print "Info: t2IP server stoped"
if __name__ == '__main__':
main()