def main(): args = parser.parse_args() msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: print(json.dumps(msg))
def test_messages_custom_key(): _, fname = tempfile.mkstemp() register_cleanup(fname) with open(fname, "w") as f: f.writelines(["foo\n", "bar\n", "baz\n"]) with open(fname) as f: res = io.messages(f, key="msg") assert_equal(next(res), {"msg": "foo"}) assert_equal(next(res), {"msg": "bar"}) assert_equal(next(res), {"msg": "baz"})
def main(): args = parser.parse_args() shpr = shipper.get_shipper(args.shipper)(args) msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: payload = json.dumps(msg) if args.bulk: command = json.dumps({"index": {"_index": args.bulk_index, "_type": args.bulk_type}}) payload = "{0}\n{1}\n".format(command, payload) shpr.ship(payload)
def main(): args = parser.parse_args() shpr = shipper.get_shipper(args.shipper)(args) msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) if args.fields: msgs = fields(msgs, args.fields) for msg in msgs: payload = json.dumps(msg) if args.bulk: command = json.dumps({'index': {'_index': args.bulk_index, '_type': args.bulk_type}}) payload = '{0}\n{1}\n'.format(command, payload) shpr.ship(payload)