예제 #1
0
 def test_build_bw_image(self):
     image = build_bw_image(self._white_pixels, self._width, self._height)
     pixels = image.load()
     print_debug('Computed pixels: {}'.format(image))
     for i in range(self._width):
         for j in range(self._height):
             self.assertEqual(pixels[i, j], self._expected_pixels[i][j])
예제 #2
0
 def test_build_bw_image(self):
     image  = build_bw_image(self._white_pixels, self._width, self._height)
     pixels = image.load()
     print_debug('Computed pixels: {}'.format(image))
     for i in range(self._width):
         for j in range(self._height):
             self.assertEqual(pixels[i, j], self._expected_pixels[i][j])
예제 #3
0
파일: irc.py 프로젝트: alem0lars/ctfs
    def connection_made(self, transport):
        print_debug('Made a new connection')

        self._transport = transport
        self._send_cmd(self.CMD_NICK.format(nick_name=self._nick_name))
        self._send_cmd(self.CMD_USER.format(
            user_name=self._user_name, real_name=self._real_name,
            server_name=self._server_name, host_name=self._host_name))
예제 #4
0
파일: irc.py 프로젝트: alem0lars/ctfs
 def connect(cls, host='127.0.0.1', port=6667, wait=True, **kwargs):
     print_debug('Connecting to the IRC server {host}:{port}'.format(
         host=host, port=port))
     loop = get_event_loop()
     def handler():
         return cls(loop, **kwargs)
     connection  = loop.create_connection(handler, host, port)
     _, protocol = loop.run_until_complete(connection)
     if wait:
         loop.run_forever()
         loop.close()
     return protocol
예제 #5
0
 def _inner():
     print_debug('Waiting {} second(s) before disconnect'.format(delay))
     sleep(delay)
     print_debug('Sending disconnect')
     client.disconnect()
예제 #6
0
 def _inner():
     print_debug('Waiting {} second(s) before disconnect'.format(delay))
     sleep(delay)
     print_debug('Sending disconnect')
     client.disconnect()
예제 #7
0
파일: irc.py 프로젝트: alem0lars/ctfs
 def _send_cmd(self, msg):
     data = '{}\r\n'.format(msg).encode()
     print_debug('Sending data: {!r}'.format(data.decode()))
     self._transport.write(data)
예제 #8
0
파일: irc.py 프로젝트: alem0lars/ctfs
 def connection_lost(self, exc):
     print_debug('Connection closed')
     self._loop.stop()
     self._disconnect_future.set_result(True)
예제 #9
0
파일: irc.py 프로젝트: alem0lars/ctfs
 def data_received(self, data):
     print_debug('Received new data:  {}'.format(data.decode()))
     if self._rcv_handler:
         self._rcv_handler(self)
예제 #10
0
파일: irc.py 프로젝트: alem0lars/ctfs
 def disconnect(self):
     print_debug('Disconnecting')
     self._transport.close()