def serialize_cache_file(cache_file_path):
    """
    Given a cache file, open it and determine whether it's something we can
    upload. If it is, serialize it to JSON, then return the serialized JSON.

    :param str cache_file_path: The full path to a cache file to read and
        potentially serialize.
    :rtype: str or None
    :returns: If the cache file contains something we can upload, return a
        JSON string that will be uploaded to EMDR. Otherwise, return None.
    """

    # Catching missing files between passes, eve can delete cache file
    # before we can read it.
    try:
        fobj = open(cache_file_path, 'rb')
    except (IOError, __HOLE__):
        print "Cache file removed before we got to it"
        return None
    # Parse with either reverence or despair.
    try:
        key, obj = blue.marshal.Load(fobj.read())
    except marshal.UnmarshalError:
        # The file probably wasn't finished writing when EMDU tried to read it.
        return None

    if key[1] == 'GetOrders':
        json_str = serialize_orders(obj, key)
        fobj.close()
        return json_str
    if key[1] == 'GetOldPriceHistory':
        json_str = serialize_history(obj, key)
        fobj.close()
        return json_str

    # This isn't a cache file we can do anything with. Oh bother.
    return None
dataset/ETHPy150Open gtaylor/EVE-Market-Data-Uploader/emdu/cachefile_serializer.py/serialize_cache_file