def hydrate_object(protobuf): # Test if it's strongly typed first _type = type_of(protobuf) if _type == TYPE_ROOT: return RootObject.from_object(protobuf) elif _type == TYPE_UPDATE: return UpdateObject.from_object(protobuf) elif _type == TYPE_UNSET: # Use existing heuristic obj = RootObject.from_object(protobuf) if not obj.protocol: obj = UpdateObject.from_object(protobuf) return obj else: raise Exception("Unknown type; %s" % (str(_type)))
def main(): myself = Node() station = Station.from_env(myself) for obj in station.objects(): try: data = station[obj] o = UpdateObject.from_object(data.read_raw()) filename, body = o.data.split(chr(0x00), 1) log("%s: %s" % (obj, filename)) print(bz2.decompress(body)) except Exception as e: log("Failed to decode %s: %s" % map(repr, (obj, e)))
def main(): myself = Node() station = Station.from_env(myself) for obj in station.objects(): try: data = station[obj] o = UpdateObject.from_object(data.read_raw()) filename, body = o.data.split(chr(0x00), 1) log("%s: %s" % (obj, filename)) print(bz2.decompress(body)) except Exception as e: log("Failed to decode %s: %s" % map(repr, (obj, e)))
def hydrate_object(protobuf): obj = RootObject.from_object(protobuf) if not obj.protocol: obj = UpdateObject.from_object(protobuf) return obj