blob: 2dc47ba95a8d1920b7492ad904a6b66a9eae7120 (
plain) (
blame)
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
|
#!/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()
|