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


Python buffer.Buffer类代码示例

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


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

示例1: client_connect_handler

        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,代码行数:34,代码来源:test_client.py

示例2: test_create

 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,代码行数:9,代码来源:test_client.py

示例3: __init__

    def __init__(self, buffer_id, url, arguments, fit_to_view, background_color):
        Buffer.__init__(self, buffer_id, url, arguments, fit_to_view, background_color)

        self.add_widget(BrowserView())

        self.buffer_widget.loadStarted.connect(self.start_progress)
        self.buffer_widget.loadProgress.connect(self.update_progress)
        self.buffer_widget.loadFinished.connect(self.stop_progress)

        self.buffer_widget.web_page.windowCloseRequested.connect(self.request_close_buffer)
开发者ID:mut0u,项目名称:emacs.d,代码行数:10,代码来源:browser_buffer.py

示例4: connect_handler

def connect_handler(socket):
    @socket.data_handler
    def data_handler(data):
        print "Echo client received %s"% data
    for i in range(10):
        print "Echo client sending %d"% i
        socket.write_buffer(Buffer.create_from_str("%d"% i))
开发者ID:EunsanKo,项目名称:vert.x,代码行数:7,代码来源:echo_client.py

示例5: test_set_buff_with_offset

 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,代码行数:7,代码来源:test_client.py

示例6: request_handler

    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,代码行数:32,代码来源:test_client.py

示例7: test_append_buff

 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,代码行数:7,代码来源:test_client.py

示例8: open_handler

 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,代码行数:32,代码来源:test_client.py

示例9: write_handler

                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,代码行数:25,代码来源:test_client.py

示例10: request_handler

    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,代码行数:30,代码来源:test_client.py

示例11: test_append_int

    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,代码行数:8,代码来源:test_client.py

示例12: test_copy

 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,代码行数:8,代码来源:test_client.py

示例13: test_length

 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,代码行数:8,代码来源:test_client.py

示例14: set_fixnum

 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,代码行数:8,代码来源:test_client.py

示例15: client_connect_handler

        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,代码行数:45,代码来源:test_client.py


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