-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_server_cont.py
89 lines (70 loc) · 1.92 KB
/
read_server_cont.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import time
import datetime
from urllib.request import urlopen
t0 = time.time()
f_name = "000000startup_test"
f = open("DATA/"+f_name+".csv", "w")
f.write(f_name)
print(f_name)
f.write("\ntimestamp,index,AccelX,AccelY,AccelZ,GyroX,GyroY,GyroZ\n")
for x in range(500):
now = datetime.datetime.now()
url = "http://140.102.1.33"
page = urlopen(url)
html_bytes = page.read()
html = html_bytes.decode("utf-8")
f.write(str(now).replace(" ", "_"))
f.write(",")
a = html.find("<p>") + 3
b = html.find("</p>")
f.write(html[a:b])
f.write("\n")
t = time.time()
print(t)
freq = (x+1) / (t-t0)
print(freq)
f.close()
t0 = time.time()
x = 0
f_name = str(datetime.datetime.now()).replace(" ", "_").replace(":", "").replace(".", "")
f = open("DATA/"+f_name+".csv", "w")
f.write(f_name)
print(f_name)
f.write("\ntimestamp,index,AccelX,AccelY,AccelZ,GyroX,GyroY,GyroZ\n")
now = datetime.datetime.now()
print(str(now))
if(now.minute >= 30):
after30 = 1
else:
after30 = 0
while(1):
now = datetime.datetime.now()
if((now.minute == 0 and after30) or (now.minute == 30 and not after30)):
f.close()
f_name = str(now).replace(" ", "_").replace(":", "").replace(".", "")
f = open("DATA/"+f_name+".csv", "w")
f.write(f_name)
print(f_name)
f.write("\ntimestamp,index,AccelX,AccelY,AccelZ,GyroX,GyroY,GyroZ\n")
now = datetime.datetime.now()
print(str(now))
if(now.minute >= 30):
after30 = 1
else:
after30 = 0
url = "http://140.102.1.33"
page = urlopen(url)
html_bytes = page.read()
html = html_bytes.decode("utf-8")
f.write(str(now).replace(" ", "_"))
f.write(",")
a = html.find("<p>") + 3
b = html.find("</p>")
f.write(html[a:b])
f.write("\n")
t = time.time()
print(t)
x += 1
freq = x / (t-t0)
print(freq)
f.close()