39 lines
898 B
Python
39 lines
898 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import sys
|
||
|
import json
|
||
|
|
||
|
sys.stderr.write("(python) dummy starting")
|
||
|
sys.stderr.flush()
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
username = ""
|
||
|
while True:
|
||
|
line = sys.stdin.readline()
|
||
|
sys.stderr.write("(python) got: {}\n".format(line))
|
||
|
sys.stderr.flush()
|
||
|
|
||
|
cmd = json.loads(line)
|
||
|
|
||
|
reply = {
|
||
|
"_type": "rep_ok",
|
||
|
"_id": cmd["_id"],
|
||
|
}
|
||
|
|
||
|
if cmd["_type"] == "configure":
|
||
|
username = cmd["data"]["user"]
|
||
|
if cmd["_type"] == "get_user":
|
||
|
reply["user"] = username
|
||
|
|
||
|
repline = json.dumps(reply)
|
||
|
sys.stderr.write("(python) sending: {}\n".format(repline))
|
||
|
sys.stderr.flush()
|
||
|
sys.stdout.write(repline + "\n")
|
||
|
sys.stdout.flush()
|
||
|
|
||
|
if cmd["_type"] == "close":
|
||
|
break
|
||
|
|
||
|
sys.stderr.write("(python) dummy stopping")
|
||
|
sys.stderr.flush()
|