How to use the msgpack.unpack function in msgpack

To help you get started, we’ve selected a few msgpack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sbl-sdsc / mmtf-pyspark / mmtfPyspark / io / _MmtfReader.py View on Github external
def call_mmtf(f):
    '''
    Call function for mmtf files
    '''

    if ".mmtf.gz" in f:
        name = f.split('/')[-1].split('.')[0].upper()

        data = gzip.open(f,'rb')
        unpack = msgpack.unpack(data)
        decoder = mmtfStructure(unpack)
        return (name, decoder)

    elif ".mmtf" in f:
        name = f.split('/')[-1].split('.')[0].upper()

        unpack = msgpack.unpack(open(f,"rb"))
        decoder = mmtfStructure(unpack)
        return (name, decoder)
github sbl-sdsc / mmtf-pyspark / mmtfPyspark / io / _MmtfReader.py View on Github external
'''
    Call function for mmtf files
    '''

    if ".mmtf.gz" in f:
        name = f.split('/')[-1].split('.')[0].upper()

        data = gzip.open(f,'rb')
        unpack = msgpack.unpack(data)
        decoder = mmtfStructure(unpack)
        return (name, decoder)

    elif ".mmtf" in f:
        name = f.split('/')[-1].split('.')[0].upper()

        unpack = msgpack.unpack(open(f,"rb"))
        decoder = mmtfStructure(unpack)
        return (name, decoder)
github bwesterb / pol / src / safe.py View on Github external
def load_from_stream(stream, nworkers, use_threads):
        """ Loads a Safe form a `stream'.

            If you load from a file, use `open' for that function also
            handles locking. """
        start_time = time.time()
        l.debug('Unpacking ...')
        magic = stream.read(len(SAFE_MAGIC))
        if magic != SAFE_MAGIC:
            raise WrongMagicError
        data = msgpack.unpack(stream, use_list=True)
        l.debug(' unpacked in %.2fs', time.time() - start_time)
        if ('type' not in data or not isinstance(data['type'], basestring)
                or data['type'] not in TYPE_MAP):
            raise SafeFormatError("Invalid `type' attribute")
        return TYPE_MAP[data['type']](data, nworkers, use_threads)
github krixano / ZeroNet-Windows-Exe-Installer / ZeroBundle / ZeroNet / plugins / Bigfile / Test / TestBigfile.py View on Github external
def testPiecemapCreate(self, site):
        inner_path = self.createBigfile(site)
        content = site.storage.loadJson("content.json")
        assert "data/optional.any.iso" in content["files_optional"]
        file_node = content["files_optional"][inner_path]
        assert file_node["size"] == 10 * 1000 * 1000
        assert file_node["sha512"] == "47a72cde3be80b4a829e7674f72b7c6878cf6a70b0c58c6aa6c17d7e9948daf6"
        assert file_node["piecemap"] == inner_path + ".piecemap.msgpack"

        piecemap = msgpack.unpack(site.storage.open(file_node["piecemap"], "rb"))["optional.any.iso"]
        assert len(piecemap["sha512_pieces"]) == 10
        assert piecemap["sha512_pieces"][0] != piecemap["sha512_pieces"][1]
        assert piecemap["sha512_pieces"][0].encode("hex") == "a73abad9992b3d0b672d0c2a292046695d31bebdcb1e150c8410bbe7c972eff3"
github emptycodes / AllegroRSS / app.py View on Github external
if not "access_token" in secrets["secrets"]:
            return redirect("/", code=302)

    life_time = secrets["secrets"]["updated"] + secrets["secrets"]["expires_in"]
    if life_time <= time.time():
        auth_host = request.host
        secrets = refresh_access_token(auth_host)

    auth = secrets["secrets"]["access_token"]

    if settings["search"]["cache_file"]:
        if not os.path.isfile("secrets/known_searches.msgp"):
            open("secrets/known_searches.msgp", "a").close()
        try:
            with open("secrets/known_searches.msgp", "rb") as f:
                known_searches = msgpack.unpack(f, raw=False)
        except ValueError:
            known_searches = {}
    
    if not uri in known_searches:
        filters = loop.run_until_complete(
            search.adjust_api_and_web_filters("https://allegro.pl" + uri, auth)
        )

        known_searches[uri] = filters

        if settings["search"]["cache_file"]:
            with open("secrets/known_searches.msgp", "wb") as f:
                msgpack.pack(known_searches, f)

    result = loop.run_until_complete(
                search.search(known_searches[uri]["api"], auth,
github jeffmacinnes / mobileGazeMapping / preprocessing / pl_preprocessing.py View on Github external
def formatGazeData(inputDir):
	"""
	- load the pupil_data and timestamps
	- get the "gaze" fields from pupil data (i.e. the gaze lcoation w/r/t world camera)
	- sync gaze data with the world_timestamps array
	"""

	# load pupil data
	pupil_data_path = join(inputDir, 'pupil_data')
	with open(pupil_data_path, 'rb') as fh:
		try:
			gc.disable()
			pupil_data = msgpack.unpack(fh, encoding='utf-8')
		except Exception as e:
			print(e)
		finally:
			gc.enable()
	gaze_list = pupil_data['gaze_positions']   # gaze posiiton (world camera)

	# load timestamps
	timestamps_path = join(inputDir, 'world_timestamps.npy')
	frame_timestamps = np.load(timestamps_path)

	# align gaze with world camera timestamps
	gaze_by_frame = correlate_data(gaze_list, frame_timestamps)

	# make frame_timestamps relative to the first data timestamp
	start_timeStamp = gaze_by_frame[0][0]['timestamp']
	frame_timestamps = (frame_timestamps - start_timeStamp) * 1000 # convert to ms
github namuyan / p2p-python / p2p_python / serializer.py View on Github external
def load(fp, object_hook=None):
    return msgpack.unpack(fp, object_hook=object_hook, encoding='utf8')
github krixano / ZeroNet-Windows-Exe-Installer / ZeroBundle / ZeroNet / plugins / Bigfile / BigfilePlugin.py View on Github external
def getPiecemap(self, inner_path):
        file_info = self.site.content_manager.getFileInfo(inner_path)
        piecemap_inner_path = helper.getDirname(file_info["content_inner_path"]) + file_info["piecemap"]
        self.site.needFile(piecemap_inner_path, priority=20)
        piecemap = msgpack.unpack(self.site.storage.open(piecemap_inner_path))[helper.getFilename(inner_path)]
        piecemap["piece_size"] = file_info["piece_size"]
        return piecemap