-
Notifications
You must be signed in to change notification settings - Fork 0
/
PLTW_EDD_Data_Collection.py
53 lines (47 loc) · 1.37 KB
/
PLTW_EDD_Data_Collection.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
import Netster
import time
import datetime
import sys
import threading
import processor
import GUI
import multiprocessing
run = True
n = Netster.Netster()
def console():
global run
while True:
userInput = input(">:")
if (userInput == "quit"):
run = False
print("Bye!")
break
elif (userInput == "pr"):
multiprocessing.Process(target=processor.main).start()
print("Processed log")
elif (userInput == "gui"):
multiprocessing.Process(target=GUI.main).start()
else:
print("Unknown command!")
def log(msg):
f = open("log.txt", "a")
dt = datetime.datetime.now()
f.write(str(dt.month) + "." + str(dt.day) + "." + str(dt.year) + "_" + str(dt.hour) + ":" + str(dt.minute) + ":" + str(dt.second) + " - " + msg + "\n")
f.close()
def main(args):
del args[0]
n._pingAddresses.extend(args)
while ((datetime.datetime.now().second % 10) != 0):
pass
while (run):
dt = datetime.datetime.now()
if ((dt.hour == 3) and (dt.minute < 1)):
log(str(n.speedtest()))
else:
past = time.time()
log(str(n.ping()))
time.sleep(10 - (time.time() - past) - 0.009)
if (__name__ == "__main__"):
threading.Thread(target=main, args=(sys.argv,)).start()
console()
quit()