本文整理汇总了Python中xmlrpclib.ServerProxy.sample方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.sample方法的具体用法?Python ServerProxy.sample怎么用?Python ServerProxy.sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.sample方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_listen_port
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import sample [as 别名]
def test_listen_port(self):
"""
The test case to test the server
created by NodeSamplerServer class.
:return:
"""
def start_server():
self.node_sampler_server.start()
server_thread = Thread(target=start_server)
server_thread.setDaemon(True)
server_thread.start()
proxy = ServerProxy("http://localhost:8000")
service_a = Service(name="$$service_a$$",
check_methods=TEST_METHOD,
ip=TEST_IP)
service_b = Service(name="$$service_b$$",
check_methods=TEST_METHOD,
ip=TEST_IP)
service_c = Service(name="$$service_c$$",
check_methods=TEST_METHOD,
ip=TEST_IP)
fake_services = [service_a, service_b, service_c]
self.assertEquals(
proxy.sample(fake_services), 1,
"NodeSamplerServer cannot create object.")
示例2: connect
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import sample [as 别名]
def connect(self, ip, group, port, node_services):
log = LOG()
log_root = log.root()
url = "http://" + ip + ":" + port
log_root.debug(
"Sent from Master-node_services: %s -url: %s -group: %s " %
(node_services, url, group))
proxy = ServerProxy(url)
raw_node_result = proxy.sample(node_services)
log_root.info(
"Raw Info received from Sampler: %s" % raw_node_result)
return raw_node_result
示例3: test_sample_server
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import sample [as 别名]
def test_sample_server(self):
"""
This test case to test sampler response.
:return:
"""
fake_uri = "http://localhost:8000/"
proxy = ServerProxy(fake_uri)
dict_service_a = {"name": "$$test_service_a$$",
"ip": TEST_IP,
"check_methods": TEST_METHOD}
dict_service_b = {"name": "$$test_service_b$$",
"ip": TEST_IP,
"check_methods": TEST_METHOD}
fake_services = [dict_service_a, dict_service_b]
self.assertEquals(proxy.sample(fake_services), 1,
"Failed to return result from sampler.")