-
Notifications
You must be signed in to change notification settings - Fork 0
/
unity_body.py
41 lines (32 loc) · 1.12 KB
/
unity_body.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
import logging
from bml import to_xml_clean
from tcp_sender import TCPSender
logger = logging.getLogger(__name__)
class UnityBody:
def __init__(self, character_name='ChrBrad'):
self._conn = None
self._character_name = character_name
def __enter__(self):
self._conn = TCPSender()
self._conn.init_network()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self._conn.finit_network()
def execute(self, bml_list):
logger.debug('Executing BML commands:\n%s', bml_list)
xml = to_xml_clean(bml_list)
print(xml)
return self._conn.send_msg(xml) # tcp only, does not include sending files
def check_done(self, id):
done = False
while done == False:
try:
if self._stomp.check_msg_done(id):
done = True
except Exception:
done = True
except:
pass
def execute_and_check(self, bml_list):
#return self.check_done(self.execute(bml_list))
return self.execute(bml_list)