Repository navigation
Expand file tree
/
Copy pathutil.py
More file actions
80 lines (57 loc) · 1.58 KB
/
Copy pathutil.py
File metadata and controls
80 lines (57 loc) · 1.58 KB
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
import requests
from Simulator import *
def url_check(url):
if "http" not in url:
url = "http://" + url
return url
def connect(url):
url = url_check(url)
get = requests.get(url + '/check/')
return get.status_code
def signup(url, username, password):
dict = {"username": username, "password": password}
response = requests.get(url + '/SignUp/', dict)
return response.status_code
def login(url, username, password):
dict = {"username": username, "password": password}
response = requests.get(url + '/LogIn/', dict)
print(response.text)
return response.status_code
def send_speed(url, user, location, velocity):
dict = {"User": user, "Location": location, "Velocity": velocity}
response = requests.get(url + '/demo_predict/', dict)
return response
def receive(response):
text = response.text
return text
def msg_parser(text):
list = text.split(',', 1)
return list
def hlt():
print('hlt')
if __name__ == '__main__':
run_state = 0
hlt = 0
# url = input()
url = '192.168.0.106:5000'
url = url_check(url)
try:
connect(url)
except:
print("connection error")
username = 'lyc'
password = '666'
login(url, username, password)
run_state = 1
dict = get_data()
for key in dict.keys():
print(key, dict[key])
response = send_speed(url, key, dict[key])
text = receive(response)
print(text)
list = msg_parser(text)
print(list)
error = list[0]
hlt = list[1]
if hlt == 1:
hlt()