1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-11-15 01:57:18 +00:00

Fix pipe_io_auxlib

This commit is contained in:
R. Richard 2019-06-11 13:41:20 +02:00
parent 9faafa7f49
commit 6e8fc588f1
3 changed files with 13 additions and 19 deletions

View File

@ -30,7 +30,7 @@ class SignMessagePipeIOEventHandler(PipeIOEventHandlerBase):
message = loads(message_bytes) message = loads(message_bytes)
sign_message(self.auth_key, message) sign_message(self.auth_key, message)
if self.forwarding: if self.forwarding:
self.server_connector.send(message) self.server_connector.send_message(message)
self.pipe_io.send_message(dumps(message).encode()) self.pipe_io.send_message(dumps(message).encode())
@ -77,7 +77,7 @@ class BotPipeIOEventHandler(PipeIOEventHandlerBase):
def handle_pipe_event(self, message_bytes): def handle_pipe_event(self, message_bytes):
if message_bytes == b"": if message_bytes == b"":
if self.queue: if self.queue:
self.server_connector.send({ self.server_connector.send_message({
'key': 'queueMessages', 'key': 'queueMessages',
'data': { 'data': {
'messages': self.queue 'messages': self.queue
@ -137,9 +137,9 @@ class DeployPipeIOEventHandler(PipeIOEventHandlerBase):
self.expected = False self.expected = False
if message_bytes == b'true': if message_bytes == b'true':
self.server_connector.send(self.onsuccess) self.server_connector.send_message(self.onsuccess)
elif message_bytes == b'false': elif message_bytes == b'false':
self.server_connector.send(self.onerror) self.server_connector.send_message(self.onerror)
else: else:
raise ValueError( raise ValueError(
f'{self.pipe_io.in_pipe}: Expected "true" or "false".' f'{self.pipe_io.in_pipe}: Expected "true" or "false".'
@ -178,7 +178,7 @@ class IdePipeIOEventHandler(PipeIOEventHandlerBase):
def handle_pipe_event(self, message_bytes): def handle_pipe_event(self, message_bytes):
if not self.selected: if not self.selected:
self.server_connector.send({ self.server_connector.send_message({
'key': 'mirror', 'key': 'mirror',
'data': { 'data': {
'key': 'ide', 'key': 'ide',
@ -189,7 +189,7 @@ class IdePipeIOEventHandler(PipeIOEventHandlerBase):
} }
}) })
self.server_connector.send({ self.server_connector.send_message({
'key': 'mirror', 'key': 'mirror',
'data': { 'data': {
'key': 'ide', 'key': 'ide',
@ -199,7 +199,7 @@ class IdePipeIOEventHandler(PipeIOEventHandlerBase):
} }
} }
}) })
self.server_connector.send({ self.server_connector.send_message({
'key': 'mirror', 'key': 'mirror',
'data': { 'data': {
'key': 'ide', 'key': 'ide',
@ -229,7 +229,7 @@ class FSMPipeIOEventHandler(PipeIOEventHandlerBase):
self.pipe_io.send_message(message['data']['current_state'].encode()) self.pipe_io.send_message(message['data']['current_state'].encode())
def handle_pipe_event(self, message_bytes): def handle_pipe_event(self, message_bytes):
self.server_connector.send({ self.server_connector.send_message({
'key': '', 'key': '',
'trigger': message_bytes.decode() 'trigger': message_bytes.decode()
}) })

View File

@ -31,8 +31,7 @@ if __name__ == '__main__':
json_pipe = PipeIOEventHandler( json_pipe = PipeIOEventHandler(
'', '',
'/tmp/tfw_json_send', '/tmp/tfw_json_send',
'/tmp/tfw_json_recv', '/tmp/tfw_json_recv'
permissions=0o666
) )
sign_pipe = SignMessagePipeIOEventHandler( sign_pipe = SignMessagePipeIOEventHandler(
@ -48,7 +47,8 @@ if __name__ == '__main__':
bot_pipe = BotPipeIOEventHandler( bot_pipe = BotPipeIOEventHandler(
'/tmp/tfw_bot_send', '/tmp/tfw_bot_send',
'/tmp/tfw_bot_recv' '/tmp/tfw_bot_recv',
permissions=0o666
) )
deploy_pipe = DeployPipeIOEventHandler( deploy_pipe = DeployPipeIOEventHandler(

View File

@ -11,14 +11,8 @@ class UserOps:
self.username = username self.username = username
self.password = password self.password = password
self.db_session = db_session self.db_session = db_session
self.pipe = PipeWriter('/tmp/tfw_json_send') self.pipe = PipeWriter('/tmp/tfw_bot_send')
self.log = lambda message: self.pipe.send_message(dumps({ self.log = lambda message: self.pipe.send_message(message.encode()+b"\n")
'key': 'message',
'data': {
'originator': 'Authenticator',
'message': message
}
}).encode())
def authenticate(self): def authenticate(self):
""" """