aboutsummaryrefslogtreecommitdiff
path: root/external/dummy.py
diff options
context:
space:
mode:
Diffstat (limited to 'external/dummy.py')
-rwxr-xr-xexternal/dummy.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/external/dummy.py b/external/dummy.py
new file mode 100755
index 0000000..2dc47ba
--- /dev/null
+++ b/external/dummy.py
@@ -0,0 +1,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()