test_xwrappers.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:raspbian-qemu 作者: meadowface 项目源码 文件源码
def assertXServer(self):
        """Assert that we can connect to an X-Server that is listening
        on the display set in the DISPLAY environment variable."""
        display = Display.get()
        try:
            with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
                sock.settimeout(1)
                sock.connect("/tmp/.X11-unix/X%d" % (int(display)))
                sock.sendall(b"l\0\x0b\0\0\0\0\0\0\0\0\0")
                #              ^-- little-endian
                #                 ^^^^--- protocol version (11)
                response = sock.recv(8, socket.MSG_WAITALL)
                self.assertEqual(len(response), 8)
                self.assertNotEqual(response[0], 0)  # 0 = Failure
        except Exception as e:
            raise AssertionError("No X-Server") from e
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号