Skip to content

Commit

Permalink
Adapt rpc_server to rpc_client API contract
Browse files Browse the repository at this point in the history
  • Loading branch information
torchiaf committed Feb 2, 2025
1 parent df2680e commit afd6788
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions rpc_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*-venv
__pycache__
module.yaml
13 changes: 11 additions & 2 deletions rpc_server/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ def on_request(ch, method, props, body):

dict_str = body.decode("UTF-8")
params = ast.literal_eval(dict_str)
print(repr(params))

command = [
'./{}'.format(params["device"]),
params["action"]
]

for arg in params["args"]:
command.append(arg)

print(" [x] exec: {}, replyTo: {}".format(command, props.reply_to))

res = subprocess.run(['./{}'.format(params["device"])], stdout=subprocess.PIPE, text=True)
res = subprocess.run(command, stdout=subprocess.PIPE, text=True)
response = res.stdout

ch.basic_publish(
Expand Down

0 comments on commit afd6788

Please sign in to comment.