예제 #1
0
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))
예제 #2
0
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"})
예제 #3
0
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)
예제 #4
0
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)