def follow_messages(so, stdout, stderr):
    try:
        resp = follow_events(so["basedir"], "messages", catchup=True)
        if resp.status != 200:
            print >>stderr, "Error:", resp.status, resp.reason
            return 1
        # httplib is not really built to read a stream of lines
        while True:
            fieldname, value = get_field(resp)
            if fieldname == "data":
                data = json.loads(value)
                if data["type"] == "inbound-messages":
                    stdout.write(render_message(data["new_value"]))
                    stdout.flush()
    except (__HOLE__, EOFError):
        return 0
dataset/ETHPy150Open warner/petmail/petmail/scripts/messages.py/follow_messages