test_upnpclient.py 文件源码

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

项目:upnpclient 作者: flyte 项目源码 文件源码
def setUpClass(cls):
        """
        Set up an HTTP server to serve the XML files. Set the correct port in
        the IGD.xml URLBase element.
        """
        # Have to chdir here because the py2 SimpleHTTPServer doesn't allow us
        # to change its working directory like the py3 one does.
        os.chdir(path.join(path.dirname(path.realpath(__file__)), 'xml'))
        cls.httpd = sockserver.TCPServer(('127.0.0.1', 0), httpserver.SimpleHTTPRequestHandler)
        cls.httpd_thread = threading.Thread(target=cls.httpd.serve_forever)
        cls.httpd_thread.daemon = True
        cls.httpd_thread.start()
        cls.httpd_port = cls.httpd.server_address[1]

        with open('upnp/IGD.xml', 'w') as out_f:
            with open('upnp/IGD.xml.templ') as in_f:
                out_f.write(in_f.read().format(port=cls.httpd_port))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号