intake/tests/demo_basic_callback/increment.py

25 lines
503 B
Python
Executable File

#!/usr/bin/env python3
import argparse, json, sys
parser = argparse.ArgumentParser()
parser.add_argument("action")
args = parser.parse_args()
print("args:", args, file=sys.stderr, flush=True)
if args.action == "fetch":
print(json.dumps({
"id": "updateme",
"action": {
"increment": 1
}
}))
if args.action == "increment":
item = sys.stdin.readline()
item = json.loads(item)
item["action"]["increment"] += 1
print(json.dumps(item))
pass