#!/usr/bin/env python
import sys
import json

def print_error(error_str='',include_newline=True):
    output_str = '\033[91m' + error_str + '\x1B[m'
    print_info(output_str)

def print_info(info_str='',include_newline=True):
    if include_newline:
        print >> sys.stderr, (info_str)
    else:
        sys.stderr.write(info_str)

try:
    import msgpack
except ImportError:
    print_error('msgpack not installed.  Run "sudo pip install msgpack-python"')
    sys.exit(1)

msgpack_data = sys.stdin.read()

#for debugging
#sys.stdin = open('/dev/tty', 'r')

data = msgpack.unpackb(msgpack_data)
json_data = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '), encoding='latin1')
print json_data
