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


Python Buffer.create方法代码示例

本文整理汇总了Python中core.buffer.Buffer.create方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.create方法的具体用法?Python Buffer.create怎么用?Python Buffer.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.buffer.Buffer的用法示例。


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

示例1: client_connect_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
        def client_connect_handler(socket):
            tu.check_context()
            sends = 10
            size = 100

            sent = Buffer.create()
            received = Buffer.create()

            @socket.data_handler
            def data_handler(data):
                tu.check_context()
                received.append_buffer(data)
                if received.length == sends * size:
                    tu.azzert(TestUtils.buffers_equal(sent, received))
                    tu.test_complete()
            @socket.drain_handler
            def drain_handler(stream):
                tu.check_context()
                #print "drained\n"

            @socket.end_handler
            def end_handler(stream):
                tu.check_context()
                #print "end\n"

            socket.pause()
            socket.resume()
            socket.write_queue_full
            socket.write_queue_max_size = 100000

            for i in range(0, sends):
                data = TestUtils.gen_buffer(size)
                sent.append_buffer(data)
                socket.write_buffer(data)
开发者ID:Findekano,项目名称:vert.x,代码行数:36,代码来源:test_client.py

示例2: test_create

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def test_create(self):
     buff1 = Buffer.create()
     tu.azzert(0 == buff1.length)
     buff2 = Buffer.create(100)
     tu.azzert(0 == buff1.length)
     str = "oqkdioqjwdijqwed"
     buff3 = Buffer.create_from_str(str)
     tu.azzert(str == buff3.to_string())
     tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:11,代码来源:test_client.py

示例3: test_append_buff

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def test_append_buff(self):
     buff_len = 100
     buff1 = self.create_buffer(buff_len)
     buff2 = Buffer.create()
     buff2.append_buffer(buff1)
     tu.azzert(buff_len == buff2.length, 'Invalid length')
     tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:9,代码来源:test_client.py

示例4: open_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def open_handler(err, file):
     tu.check_context()
     tu.azzert(err == None)
     num_chunks = 100;
     chunk_size = 1000;
     tot_buff = Buffer.create()
     self.written = 0
     for i in range(0, num_chunks):
         buff = TestUtils.gen_buffer(chunk_size)
         tot_buff.append_buffer(buff)
         def write_handler(err, res):
             tu.check_context()
             self.written += 1
             if self.written == num_chunks:
               # all written
               tot_read = Buffer.create()
               self.read = 0
               for j in range(0, num_chunks):
                 pos = j * chunk_size
                 def read_handler(err, buff):
                     tu.check_context
                     tu.azzert(err == None)
                     self.read += 1
                     if self.read == num_chunks:
                         # all read
                         tu.azzert(TestUtils.buffers_equal(tot_buff, tot_read))
                         def close_handler(err, res):
                             tu.check_context()
                             tu.test_complete()
                         file.close(close_handler)
                 file.read(tot_read, pos, pos, chunk_size, read_handler)
         file.write(buff, i * chunk_size, write_handler)
开发者ID:aaronwalker,项目名称:vert.x,代码行数:34,代码来源:test_client.py

示例5: request_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
    def request_handler(req):
        tu.check_context()
        tu.azzert(req.uri == uri)
        tu.azzert(req.method == method)
        tu.azzert(req.path == path)
        tu.azzert(req.query == query)
        tu.azzert(req.headers["header1"] == "vheader1")
        tu.azzert(req.headers["header2"] == "vheader2")
        tu.azzert(req.params["param1"] == "vparam1")
        tu.azzert(req.params["param2"] == "vparam2")
        req.response.put_header("rheader1", "vrheader1")
        req.response.put_header("rheader2", "vrheader2")
        body = Buffer.create()

        @req.data_handler
        def data_handler(data):
            tu.check_context()
            body.append_buffer(data)

        req.response.chunked = chunked

        @req.end_handler
        def end_handler(stream):
            tu.check_context()
            if method != "HEAD" and method != "CONNECT":
                if not chunked:
                    req.response.put_header("Content-Length", body.length)
                req.response.write_buffer(body)
                if chunked:
                    req.response.put_trailer("trailer1", "vtrailer1")
                    req.response.put_trailer("trailer2", "vtrailer2")
            req.response.end()
开发者ID:jdonnerstag,项目名称:vert.x,代码行数:34,代码来源:test_client.py

示例6: write_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
                def write_handler(err, res):
                    tu.check_thread()
                    self.written += 1
                    if self.written == num_chunks:
                        # all written
                        tot_read = Buffer.create()
                        self.read = 0
                        for j in range(0, num_chunks):
                            pos = j * chunk_size

                            def read_handler(err, buff):
                                tu.check_thread
                                tu.azzert(err == None)
                                self.read += 1
                                if self.read == num_chunks:
                                    # all read
                                    tu.azzert(TestUtils.buffers_equal(tot_buff, tot_read))

                                    def close_handler(err, res):
                                        tu.check_thread()
                                        tu.test_complete()

                                    file.close(close_handler)

                            file.read_at_pos(tot_read, pos, pos, chunk_size, read_handler)
开发者ID:rdolgushin,项目名称:mod-lang-jython,代码行数:27,代码来源:test_client.py

示例7: request_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
    def request_handler(req):
        tu.check_context()
        tu.azzert(req.uri == uri)
        tu.azzert(req.method == method)
        tu.azzert(req.path == path)
        tu.azzert(req.query == query)
        tu.azzert(req.headers['header1'] == 'vheader1')
        tu.azzert(req.headers['header2'] == 'vheader2')
        tu.azzert(req.params['param1'] == 'vparam1')
        tu.azzert(req.params['param2'] == 'vparam2')
        req.response.put_header('rheader1', 'vrheader1')
        req.response.put_header('rheader2', 'vrheader2')
        body = Buffer.create()

        @req.data_handler
        def data_handler(data):
            tu.check_context()
            body.append_buffer(data)
        req.response.chunked = chunked

        @req.end_handler
        def end_handler(stream):
            tu.check_context()
            if not chunked:
                req.response.put_header('Content-Length', body.length)
            req.response.write_buffer(body)
            if chunked:
                req.response.put_trailer('trailer1', 'vtrailer1')
                req.response.put_trailer('trailer2', 'vtrailer2')
            req.response.end()
开发者ID:Findekano,项目名称:vert.x,代码行数:32,代码来源:test_client.py

示例8: test_set_buff_with_offset

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def test_set_buff_with_offset(self):
     buff_len = 100
     buff1 = self.create_buffer(buff_len)
     buff2 = Buffer.create()
     buff2.set_buffer(0, buff1, 50, 50)
     tu.azzert(50 == buff2.length, 'Invalid length')
     tu.test_complete()
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:9,代码来源:test_client.py

示例9: test_append_int

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
    def test_append_int(self):
        buff1 = Buffer.create()
        for i in range(100):
          buff1.append_int(i)

        for i in range(100):
          val = buff1.get_int(i)
          tu.azzert(val == i)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:10,代码来源:test_client.py

示例10: test_copy

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def test_copy(self):
     str = "iajdoiqwjdiqwdioqwdjiqwd"
     buff1 = Buffer.create(str)
     buff2 = buff1.copy()
     tu.azzert(buff1.length == buff2.length)
     for i in range(0,buff1.length):
         tu.azzert(buff1.get_byte(i) == buff2.get_byte(i))
     tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:10,代码来源:test_client.py

示例11: test_length

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def test_length(self):
     buff1 = Buffer.create()
     tu.azzert(buff1.length == 0)
     num = 50
     for i in range(0,num):
         buff1.append_fixnum(i, 1)
     tu.azzert(buff1.length == num, "Received %d expected %d"% (buff1.length, num))
     tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:10,代码来源:test_client.py

示例12: set_fixnum

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
 def set_fixnum(self, num_bytes):
     buff1 = Buffer.create()
     for i in range(-128,128):
         buff1.set_fixnum((i + 128) * num_bytes, i << ((num_bytes -1) * 8), num_bytes)
     for i in range(-128,128):
         val = buff1.get_fixnum((i + 128) * num_bytes, num_bytes)
         tu.azzert(val == i << ((num_bytes -1)* 8))
     tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:10,代码来源:test_client.py

示例13: client_connect_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
        def client_connect_handler(err, socket):
            tu.azzert(err == None)
            tu.check_thread()
            tu.azzert(socket.local_address[0] is not None)
            tu.azzert(socket.local_address[1] > -1)
            tu.azzert(socket.remote_address[0] is not None)
            tu.azzert(socket.remote_address[1] > -1)

            sends = 10
            size = 100

            sent = Buffer.create()
            received = Buffer.create()

            @socket.data_handler
            def data_handler(data):
                tu.check_thread()
                received.append_buffer(data)

                if received.length == sends * size:
                    tu.azzert(TestUtils.buffers_equal(sent, received))
                    tu.test_complete()

            #Just call the methods. Real testing is done in java tests
            @socket.drain_handler
            def drain_handler():
                tu.check_thread()

            @socket.end_handler
            def end_handler():
                tu.check_thread()

            @socket.close_handler
            def close_handler():
                tu.check_thread()

            socket.pause()
            socket.resume()
            socket.write_queue_full
            socket.write_queue_max_size = 100000

            for i in range(0, sends):
                data = TestUtils.gen_buffer(size)
                sent.append_buffer(data)
                socket.write(data)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:47,代码来源:test_client.py

示例14: append_float

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
    def append_float(self, num_bytes):
        buff1 = Buffer.create()
        for i in range(0,100):
            buff1.append_float(i, num_bytes)

        for i in range(0,100):
            val = buff1.get_float(i * num_bytes, num_bytes)
            tu.azzert(val == i)
        tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:11,代码来源:test_client.py

示例15: connect_handler

# 需要导入模块: from core.buffer import Buffer [as 别名]
# 或者: from core.buffer.Buffer import create [as 别名]
        def connect_handler(ws):
            tu.check_context()
            received = Buffer.create()

            @ws.data_handler
            def data_handler(buff):
                tu.check_context()
                received.append_buffer(buff)
                if received.length == buff.length:
                    tu.azzert(TestUtils.buffers_equal(buff, received))
                    tu.test_complete()
        
            if binary:
                ws.write_binary_frame(self.buff)
            else:
                ws.write_text_frame(self.str_)
开发者ID:Findekano,项目名称:vert.x,代码行数:18,代码来源:test_client.py


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