当前位置: 首页>>代码示例>>Python>>正文


Python pyamf.decode函数代码示例

本文整理汇总了Python中pyamf.decode函数的典型用法代码示例。如果您正苦于以下问题:Python decode函数的具体用法?Python decode怎么用?Python decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了decode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: decode

    def decode(self, bytes, encoding=pyamf.AMF3):
        decoded = list(pyamf.decode(bytes, encoding=encoding))

        if len(decoded) == 1:
            return decoded[0]

        return decoded
开发者ID:0xmilk,项目名称:appscale,代码行数:7,代码来源:test_google.py

示例2: test_decode

    def test_decode(self):
        expected = [u'connect', 1.0]
        bytes = '\x06\x0fconnect\x05?\xf0\x00\x00\x00\x00\x00\x00'

        returned = [x for x in pyamf.decode(bytes)]

        self.assertEqual(expected, returned)
开发者ID:0xmilk,项目名称:appscale,代码行数:7,代码来源:test_basic.py

示例3: test_decode

    def test_decode(self):
        expected = [u"connect", 1.0]
        bytes = "\x06\x0fconnect\x05?\xf0\x00\x00\x00\x00\x00\x00"

        returned = [x for x in pyamf.decode(bytes)]

        self.assertEquals(expected, returned)
开发者ID:cardmagic,项目名称:PyAMF,代码行数:7,代码来源:test_basic.py

示例4: test_source_attr

    def test_source_attr(self):
        s = ('\n\x07Cflex.messaging.io.ArrayCollection\n\x0b\x01\rsource'
            '\t\x05\x01\x06\x07foo\x06\x07bar\x01')

        x = pyamf.decode(s, encoding=pyamf.AMF3).next()

        self.assertTrue(isinstance(x, flex.ArrayCollection))
        self.assertEqual(x, ['foo', 'bar'])
开发者ID:notnola,项目名称:pinychat,代码行数:8,代码来源:test_flex.py

示例5: unpack

    def unpack(self, size, data):

        if not size:
            raise PackerDecodeError('size not found')
        elif size != len(data):
            raise PackerDecodeError('size:%s != data length:%s' % (size,
                                                                   len(data)))

        return pyamf.decode(data).readElement()
开发者ID:kashirov,项目名称:socket_server2,代码行数:9,代码来源:packer.py

示例6: test_no_pk

    def test_no_pk(self):
        """
        Ensure that Models without a primary key are correctly serialized.
        See #691.
        """
        instances = [models.NotSaved(name="a"), models.NotSaved(name="b")]
        encoded = pyamf.encode(instances, encoding=pyamf.AMF3).getvalue()

        decoded = pyamf.decode(encoded, encoding=pyamf.AMF3).next()
        self.assertEqual(decoded[0]['name'], 'a')
        self.assertEqual(decoded[1]['name'], 'b')
开发者ID:LiiiQin,项目名称:test,代码行数:11,代码来源:test_django.py

示例7: assertDecodes

    def assertDecodes(self, bytes, cb, encoding=pyamf.AMF3, raw=False):
        if not isinstance(bytes, basestring):
            bytes = _join(bytes)

        ret = list(pyamf.decode(bytes, encoding=encoding))

        if not raw and len(ret) == 1:
            ret = ret[0]

        if callable(cb):
            cb(ret)
        else:
            self.assertEqual(ret, cb)
开发者ID:meemeer,项目名称:kayframework-pyamf,代码行数:13,代码来源:util.py

示例8: test_numerical_keys_mixed_array

    def test_numerical_keys_mixed_array(self):
        """
        Numerical keys in L{pyamf.MixedArray} must not cause a KeyError on
        decode.

        @see: #843
        """
        x = pyamf.MixedArray({'10': u'foobar'})

        bytes = pyamf.encode(x, encoding=pyamf.AMF0)

        d = list(pyamf.decode(bytes, encoding=pyamf.AMF0))

        self.assertEqual(d, [{10: u'foobar'}])
开发者ID:LiiiQin,项目名称:test,代码行数:14,代码来源:test_amf0.py

示例9: read

    def read(self, header, buf):
        """
        Read (decode) packet from stream.

        @param header: packet header
        @type header: L{RTMPHeader}
        @param buf: buffer holding packet data
        @type buf: C{BufferedByteStream}
        """
        amf = pyamf.decode(buf, encoding=pyamf.AMF0)
        name = amf.next()
        id = amf.next()
        argv = tuple(amf)
        return Invoke(name, argv, id, header)
开发者ID:smira,项目名称:fmspy,代码行数:14,代码来源:packets.py

示例10: __init__

	def __init__(self, xml, bootstrapInfos):
		self.bitrate = int(xml.attributes['bitrate'].nodeValue)
		#self.width = int(xml.attributes['width'].nodeValue)
		#self.height = int(xml.attributes['height'].nodeValue)
		self.url = str(xml.attributes['url'].nodeValue)
		bootstrapId = xml.attributes['bootstrapInfoId'].nodeValue
		if bootstrapId.startswith('bootstrap_'):
			self.index = int(bootstrapId[len('bootstrap_'):])
		else:
			self.index = int(bootstrapId[len('bootstrap'):])
		self.bootstrapInfo = bootstrapInfos[bootstrapId]
		
		metadata = str(xml.getElementsByTagName('metadata')[0].firstChild.nodeValue)
		decoder = pyamf.decode(base64.b64decode(metadata), encoding=pyamf.AMF0)
		if str(decoder.next()) == 'onMetaData':
			self.metadata = decoder.next()
开发者ID:Bairavan,项目名称:nginx-vod-module,代码行数:16,代码来源:hds_compare.py

示例11: test_amf3

    def test_amf3(self):
        data = (
            b'\nk\x11pyamf.SM\t_key\x17age_in_2000\x15birth_date\rheight\x19me'
            b'asurements\tname\x01\x04\x1a\x08\x01B9\x15\xda$\x00\x00\x00\x05?'
            b'\xfc=p\xa3\xd7\n=\t\x07\x01\x04\x01\x04\x02\x04\x03\x06\x15Heidi'
            b' Klum\x01'
        )

        decoder = pyamf.decode(data, encoding=pyamf.AMF3)

        heidi = decoder.next()

        self.assertEqual(heidi, models.SuperModel(
            birth_date=datetime.date(1973, 6, 1),
            name='Heidi Klum',
            measurements=[1, 2, 3],
            height=1.765
        ))
开发者ID:nervatura,项目名称:nerva2py,代码行数:18,代码来源:test_ndb.py

示例12: test_amf0

    def test_amf0(self):
        data = (
            b'\x10\x00\x08pyamf.SM\x00\x04_key\x05\x00\x0bage_in_2000\[email protected]:'
            b'\x00\x00\x00\x00\x00\x00\x00\nbirth_date\x0bB9\x15\xda$\x00\x00'
            b'\x00\x00\x00\x00\x06height\x00?\xfc=p\xa3\xd7\n=\x00\x0cmeasurem'
            b'ents\n\x00\x00\x00\x03\x00?\xf0\x00\x00\x00\x00\x00\x00\[email protected]\x00'
            '\x00\x00\x00\x00\x00\x00\[email protected]\x08\x00\x00\x00\x00\x00\x00\x00\x04'
            'name\x02\x00\nHeidi Klum\x00\x00\t'
        )

        decoder = pyamf.decode(data, encoding=pyamf.AMF0)

        heidi = decoder.next()

        self.assertEqual(heidi, models.SuperModel(
            birth_date=datetime.date(1973, 6, 1),
            name='Heidi Klum',
            measurements=[1, 2, 3],
            height=1.765
        ))
开发者ID:nervatura,项目名称:nerva2py,代码行数:20,代码来源:test_ndb.py

示例13: test_amf3

    def test_amf3(self):
        """
        Test encoding in AMF3.
        """
        import pyamf

        ref_dict = {
            'level': 'alevel',
            'code': 'Some.Code.Here',
            'description': 'Look mom, no hands!'
        }

        s = status.Status(
            ref_dict['level'],
            ref_dict['code'],
            ref_dict['description'])

        blob = pyamf.encode(s, encoding=pyamf.AMF3)

        decoded_status = pyamf.decode(blob, encoding=pyamf.AMF3).next()

        self.assertEqual(decoded_status, s)
开发者ID:Arlex,项目名称:rtmpy,代码行数:22,代码来源:test_status.py

示例14: Exception

        print "send request: start"
        try:
            self.sock.send('start')
        except socket.error, e:
            raise Exception("Can't connect: %s" % e[1])

        while len(msg) < 1024:
            # read from server
            amf = self.sock.recv(1024)

            if amf == '':
                print "Connection closed."

            msg = msg + amf

            for obj in pyamf.decode(amf):
                print obj

        return msg

    def stop(self):
        print "send request: stop"
        self.sock.send('stop')


if __name__ == '__main__':
    from optparse import OptionParser

    parser = OptionParser()
    parser.add_option("-p", "--port", default=appPort,
        dest="port", help="port number [default: %default]")
开发者ID:84322146,项目名称:pyamf,代码行数:31,代码来源:client.py

示例15: loads

 def loads(data):
     """returns a list of messages"""
     stream = BufferedByteStream(data)
     result = list(pyamf.decode(stream=stream, encoding=3))
     stream.close()
     return result
开发者ID:clickstan,项目名称:goplay,代码行数:6,代码来源:__init__.py


注:本文中的pyamf.decode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。