-
Notifications
You must be signed in to change notification settings - Fork 0
/
Run.py
49 lines (48 loc) · 1.26 KB
/
Run.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
import string
from Read import getUser, getMessage
from Socket import openSocket, sendMessage
from Init import joinRoom
import stepper as stepper
s = openSocket()
joinRoom(s)
readbuffer = ""
stepper.setup()
try:
while True:
readbuffer = readbuffer + s.recv(1024)
temp = string.split(readbuffer, "\n")
readbuffer = temp.pop()
# TODO: look into storing the commands in a multi deminsion array[[username],[command]]. this will allow pausing of the motors and displaying username with what command was performed.
for line in temp:
print(line)
if "PING" in line:
print("sending pong back")
s.send(line.replace("PING", "PONG"))
break
user = getUser(line)
message = getMessage(line)
print user + " typed :" + message
if "You Suck" in message:
sendMessage(s, "No, you suck!")
break
if "left\r" == message:
print("MOOOOVE left")
stepper.moveLeft()
break
if "right\r" == message:
print("MOOOOOVE right")
stepper.moveRight()
break
if "up\r" == message:
print("MOOOOVE up")
stepper.moveUp()
break
print(message)
if "down\r" == message:
print("MOOOOOVE down")
stepper.moveDown()
break
except KeyboardInterrupt: # Press ctrl-c to end the program.
print ('exiting...')
finally:
stepper.destroy()