-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute.py
111 lines (100 loc) · 3.27 KB
/
execute.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from entityClass import Entity, generate_classes_from_config
from time import sleep, time
import zerorpc
import sys
import threading
# __init__
# Data type = List
# Singular data type inside: Entity (from entityClass)
Entities = generate_classes_from_config()
current_debug_id = sys.argv[1]
client = zerorpc.Client()
if len(sys.argv) > 3:
current_remote_target = int(sys.argv[3])-1
else:
current_remote_target = 0
def main():
try:
while(True):
#choice = int(input("Choice: "))
#choice=9
choice=int(sys.argv[2])
if choice == 1:
debugging()
elif choice == 2:
Entities[current_remote_target].scream()
pass
elif choice == 3:
Entities[current_remote_target].suicide()
pass
elif choice == 4:
Entities[current_remote_target].revive()
pass
elif choice == 5:
pass
elif choice == 6:
pass
elif choice == 7:
client.connect(Entities[current_remote_target].clientString)
client.heartbeat()
elif choice == 8:
do_the_whole_thing()
elif choice == 9:
threads = []
for e in Entities:
# if (e.id == str(current_remote_target)):
# continue
print(e.id)
entityThread = threading.Thread(target=threading_kickstart, args=(e,), daemon=True)
threads.append(entityThread)
entityThread.start()
#do_the_whole_thing()
break
elif choice == 0:
break
break
except KeyboardInterrupt:
print("Program forcefully exited.")
def threading_kickstart(entity):
print(entity.id)
print(current_remote_target)
client.connect(entity.clientString)
print(entity.clientString)
a = client.heartbeat()
client.start_cycle()
#sleep(1)
def do_the_whole_thing():
# while(True):
# for e in Entities:
# if (e.id == current_debug_id):
# startServer(e)
# elif (current_debug_id == "0"):
# client.connect(e.clientString)
# a = client.heartbeat()
# #client.send_message("localhost", "4002", "vibe check")
# print(a)
# break
# sleep(2)
for e in Entities:
if (e.id == current_debug_id):
startServer(e)
elif (current_debug_id == "0") and (e.id == str(current_remote_target+1)):
print(e.id)
print(current_remote_target)
client.connect(e.clientString)
print(e.clientString)
#a = client.heartbeat()
client.start_cycle()
#sleep(1)
def startServer(entity):
server = zerorpc.Server(entity)
server.bind(entity.serverString)
print("Starting server with id of %s" % entity.id)
server.run()
def debugging():
for e in Entities:
for n in e.NetworkMembers:
print(""+e.id+""+n)
pass
if __name__ == "__main__":
main()