python类unpackb()的实例源码

banyan_base.py 文件源码 项目:python_banyan 作者: MrYsLab 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def receive_loop(self):
        """
        This is the receive loop for Banyan messages.

        This method may be overwritten to meet the needs
        of the application before handling received messages.

        """
        while True:
            try:
                data = self.subscriber.recv_multipart(zmq.NOBLOCK)
                if self.numpy:
                    payload = msgpack.unpackb(data[1], object_hook=m.decode)
                    self.incoming_message_processing(data[0].decode(), payload)
                else:
                    self.incoming_message_processing(data[0].decode(), umsgpack.unpackb(data[1]))
            # if no messages are available, zmq throws this exception
            except zmq.error.Again:
                try:
                    time.sleep(self.loop_time)
                except KeyboardInterrupt:
                    self.clean_up()
                    raise KeyboardInterrupt
utils.py 文件源码 项目:zatt 作者: simonacca 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def msgpack_appendable_unpack(path):
    # if not list?
    # return msgpack.unpackb(f.read())
    with open(path, 'rb') as f:
        packer = msgpack.Packer()
        unpacker = msgpack.Unpacker(f, encoding='utf-8')
        length = unpacker.read_array_header()

        header_lenght = len(packer.pack_array_header(length))
        unpacker.read_bytes(MAX_MSGPACK_ARRAY_HEADER_LEN - header_lenght)
        f.seek(MAX_MSGPACK_ARRAY_HEADER_LEN)

        return [unpacker.unpack() for _ in range(length)]
protocols.py 文件源码 项目:zatt 作者: simonacca 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def datagram_received(self, data, sender):
        message = msgpack.unpackb(data, encoding='utf-8')
        self.orchestrator.data_received_peer(sender, message)
protocols.py 文件源码 项目:zatt 作者: simonacca 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def data_received(self, data):
        message = msgpack.unpackb(data, encoding='utf-8')
        self.orchestrator.data_received_client(self, message)
serializer.py 文件源码 项目:lemongraph 作者: NationalSecurityAgency 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def msgpack_decode_hashable(x):
    return messagepack.unpackb(x, use_list=False)

# encode should support: arbitrary python object => bytes
# decode should support: python Buffer => object
# default for all encode/decode is 'str', except None maps to '' for encode
# for node/edge types/values as well as property keys, you should strive to make sure the encoder is deterministic
# if you plan to use complex values - if dicts are involved, msgpack is not so much.
serializer.py 文件源码 项目:lemongraph 作者: NationalSecurityAgency 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def msgpack(hashable=False):
        return Serializer(encode=msgpack_encode_hashable, decode=msgpack_decode_hashable) if hashable else Serializer(encode=messagepack.packb, decode=messagepack.unpackb)
vnrpc.py 文件源码 项目:InplusTrader_Linux 作者: zhengwsh 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __msgpackUnpack(self, data):
        """??msgpack??"""
        return unpackb(data)

    #----------------------------------------------------------------------
msfrpc.py 文件源码 项目:mitmfnz 作者: dropnz 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def decode(self, data):
        return msgpack.unpackb(data)
_component.py 文件源码 项目:bowtie 作者: jwkvam 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def unpack(x):
    """Decode ``x`` from msgpack into Python object."""
    return msgpack.unpackb(bytes(x['data']), encoding='utf8')
serialization.py 文件源码 项目:katana-sdk-python2 作者: kusanagi 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def unpack(stream):
    """Pack python data to a binary stream.

    :param stream: bytes.

    :rtype: The unpacked python object.

    """

    return msgpack.unpackb(stream, list_hook=decode, encoding='utf-8')
test_integration.py 文件源码 项目:dd-trace-py 作者: DataDog 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _decode(self, payload):
        """
        Helper function that decodes data based on the given Encoder.
        """
        if isinstance(self.api._encoder, JSONEncoder):
            return json.loads(payload)
        elif isinstance(self.api._encoder, MsgpackEncoder):
            return msgpack.unpackb(payload, encoding='utf-8')
msgpack_serializer.py 文件源码 项目:pysoa 作者: eventbrite 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def blob_to_dict(self, blob):
        try:
            return msgpack.unpackb(blob, encoding='utf-8', ext_hook=self.ext_hook)
        except (TypeError, msgpack.UnpackValueError, msgpack.ExtraData) as e:
            raise InvalidMessage(*e.args)
minimizer.py 文件源码 项目:distiller 作者: pyoor 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def process_results(self):
        print "[ +D+ ] - Begin processing minimization results"
        bs = beanstalkc.Connection(host='127.0.0.1', port=11300)
        bs.use('min-results')

        if self.get_job():
            seed = msgpack.unpackb(zlib.decompress(self.job.body))
            name = seed['seed_name']
            data = seed['data']

            filename = os.path.join(self.min_dir, name)
            with open(filename, 'wb') as f:
                f.write(data)
packer.py 文件源码 项目:distiller 作者: pyoor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def unpack(job):
    data = msgpack.unpackb(zlib.decompress(job))
    return data
msgpack.py 文件源码 项目:serialize 作者: hgrecco 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def loads(content):
    return msgpack.unpackb(content, object_hook=all.decode, encoding='utf-8')
cmq_rpc.py 文件源码 项目:pyktrader2 作者: harveywwu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __msgpack_unpack(self, data):
        return msgpack.unpackb(data)
msfrpc.py 文件源码 项目:piSociEty 作者: paranoidninja 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def decode(self, data):
        return msgpack.unpackb(data)
shellbot.py 文件源码 项目:shellbot 作者: Ne0nd0g 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def msf_rpc_get_temp_auth_token():
    """Get a temporary authentication token from the Metasploit RPC Server"""

    global msfRpcToken

    payload = msgpack.packb(["auth.login", msfRpcUser, msfRpcPass])
    response = msf_rpc_request(payload)

    if response is not None:
        if DEBUG:
            print debug + "MSF RPC auth.login response:\n\tHTTP Status Code: %s" % response.status_code
            if response.headers['Content-Type'] == "binary/message-pack":
                msf_rpc_message = msgpack.unpackb(response.content, use_list=False)
                print "\t" + debug + "MSF RPC Server Response: %s" % msf_rpc_message
                if 'error' in msf_rpc_message.keys():
                    print debug + "MSF RPC Error: %s" % msf_rpc_message['error_message']
            else:
                print "\t" + debug + "HTTP Server Response: %s" % response.content
        if response.status_code == 200:
            result = msgpack.unpackb(response.content, use_list=False)
            if 'error' in result.keys():
                print warn + "MSF RPC Error: %s" % result['error_message']
                print warn + "Quitting"
                sys.exit()
            elif 'token' in result.keys():
                msfRpcToken = result['token']
shellbot.py 文件源码 项目:shellbot 作者: Ne0nd0g 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def msf_rpc_get_session_list():
    """Get a list of Meterpreter sessions"""

    payload = msgpack.packb(["session.list", msfRpcToken])
    response = msf_rpc_request(payload)
    if response is not None:
        result = msgpack.unpackb(response.content, use_list=False)

        if response.status_code == 200:
            return result
        else:
            return None
    else:
        return None
__init__.py 文件源码 项目:frontera-google-docker 作者: casertap 项目源码 文件源码 阅读 48 收藏 0 点赞 0 评论 0
def __missing__(self, key):
        row = self.table.row(key)
        if not row:
            super(DomainCache, self).__missing__(key)
            raise KeyError
        value = {}
        for k, v in row.iteritems():
            cf, _, col = k.partition(':')
            value[col] = unpackb(v)
        self.__setitem__(key, value)
        return value


问题


面经


文章

微信
公众号

扫码关注公众号