Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add data send protocol #55

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control_dev",
version="0.0.38",
version="0.0.39",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto testing",
Expand Down
12 changes: 10 additions & 2 deletions je_auto_control/utils/socket_server/auto_control_socket_server.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import argparse
import json
import socketserver
import sys
import threading

from je_auto_control import execute_action
from je_auto_control.utils.executor.action_executor import execute_action


class TCPServerHandler(socketserver.BaseRequestHandler):

def handle(self):
command_string = str(self.request.recv(8192).strip(), encoding="utf-8")
socket = self.request
print("command is: " + command_string, flush=True)
if command_string == "quit_server":
self.server.shutdown()
Expand All @@ -17,7 +20,11 @@ def handle(self):
else:
try:
execute_str = json.loads(command_string)
execute_action(execute_str)
for execute_function, execute_return in execute_action(execute_str).items():
socket.sendto(str(execute_return).encode("utf-8"), self.client_address)
socket.sendto("\n".encode("utf-8"), self.client_address)
socket.sendto("Return_Data_Over_JE".encode("utf-8"), self.client_address)
socket.sendto("\n".encode("utf-8"), self.client_address)
except Exception as error:
print(repr(error))

Expand All @@ -36,3 +43,4 @@ def start_autocontrol_socket_server(host: str = "localhost", port: int = 9938):
server_thread.start()
return server


2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="je_auto_control",
version="0.0.104",
version="0.0.105",
author="JE-Chen",
author_email="zenmailman@gmail.com",
description="auto testing",
Expand Down