本文整理汇总了Python中xmlrpc.client.ServerProxy.getBusInfo方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.getBusInfo方法的具体用法?Python ServerProxy.getBusInfo怎么用?Python ServerProxy.getBusInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpc.client.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.getBusInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subscribe_to_multiple_publishers
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import getBusInfo [as 别名]
def test_subscribe_to_multiple_publishers(self):
# wait so that all connections are established
time.sleep(1.0)
# ensure that publishers are publishing
for i in range(1, NUMBER_OF_TALKERS + 1):
self.assert_(rostest.is_publisher(
rospy.resolve_name(TOPIC),
rospy.resolve_name(TALKER_NODE % i)), 'talker node %d is not up' % i)
# ensure that subscriber is subscribed
self.assert_(rostest.is_subscriber(
rospy.resolve_name(TOPIC),
rospy.resolve_name(LISTENER_NODE)), 'listener node is not up')
# check number of connections from subscriber to the topic
connections = 0
master = rosgraph.Master(NAME)
node_api = master.lookupNode(LISTENER_NODE)
if not node_api:
self.assert_(False, 'cannot contact [%s]: unknown node' % LISTENER_NODE)
socket.setdefaulttimeout(5.0)
node = ServerProxy(node_api)
code, _, businfo = node.getBusInfo(NAME)
if code != 1:
self.assert_(False, 'cannot get node information')
if businfo:
for info in businfo:
topic = info[4]
if len(info) > 5:
connected = info[5]
else:
connected = True # backwards compatibility
if connected:
if topic == TOPIC:
connections += 1
self.assert_(connections == NUMBER_OF_TALKERS, 'Found only %d connections instead of %d' % (connections, NUMBER_OF_TALKERS))
示例2: run
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import getBusInfo [as 别名]
def run(self):
ctx = self.ctx
master = self.master
actual_edges = self.actual_edges
lock = self.lock
n = self.n
try:
socket.setdefaulttimeout(3.0)
with lock: #Apparently get_api_uri is not thread safe...
node_api = rosnode.get_api_uri(master, n)
if not node_api:
with lock:
ctx.errors.append(WtfError("Master does not have lookup information for node [%s]"%n))
return
node = ServerProxy(node_api)
start = time.time()
socket.setdefaulttimeout(3.0)
code, msg, bus_info = node.getBusInfo('/roswtf')
end = time.time()
with lock:
if (end-start) > 1.:
ctx.warnings.append(WtfWarning("Communication with node [%s] is very slow"%n))
if code != 1:
ctx.warnings.append(WtfWarning("Node [%s] would not return bus info"%n))
elif not bus_info:
if not n in ctx.service_providers:
ctx.warnings.append(WtfWarning("Node [%s] is not connected to anything"%n))
else:
edges = _businfo(ctx, n, bus_info)
actual_edges.extend(edges)
except socket.error:
pass #ignore as we have rules to catch this
except Exception as e:
ctx.errors.append(WtfError("Communication with [%s] raised an error: %s"%(n, str(e))))
finally:
self.done = True
示例3: get_node_connection_info_description
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import getBusInfo [as 别名]
def get_node_connection_info_description(node_api, master):
#turn down timeout on socket library
socket.setdefaulttimeout(5.0)
node = ServerProxy(node_api)
system_state = master.getSystemState()
try:
pid = _succeed(node.getPid(ID))
buff = "Pid: %s\n"%pid
#master_uri = _succeed(node.getMasterUri(ID))
businfo = _succeed(node.getBusInfo(ID))
if businfo:
buff += "Connections:\n"
for info in businfo:
dest_id = info[1]
direction = info[2]
transport = info[3]
topic = info[4]
if len(info) > 5:
connected = info[5]
else:
connected = True #backwards compatibility
if connected:
buff += " * topic: %s\n"%topic
# older ros publisher implementations don't report a URI
buff += " * to: %s\n"%lookup_uri(master, system_state, topic, dest_id)
if direction == 'i':
buff += " * direction: inbound\n"
elif direction == 'o':
buff += " * direction: outbound\n"
else:
buff += " * direction: unknown\n"
buff += " * transport: %s\n"%transport
return buff
except socket.error:
raise ROSNodeIOException("Communication with node[%s] failed!"%(node_api))
return buff
示例4: TestSlaveApi
# 需要导入模块: from xmlrpc.client import ServerProxy [as 别名]
# 或者: from xmlrpc.client.ServerProxy import getBusInfo [as 别名]
#.........这里部分代码省略.........
self.assertEquals(protocol_params[0], TCPROS)
def testRequestTopic(self):
node = self.node
protocols = [[TCPROS]]
publications = node.getPublications(self.caller_id)
topics = self.required_pubs.keys()
probe_topic = topics[0] if topics else None
fake_topic = rosgraph.names.ns_join(self.ns, 'fake_topic')
# currently only support TCPROS as we require all clients to support this
protocols = [[TCPROS]]
for topic in topics:
self.check_TCPROS(self.apiSuccess(node.requestTopic(self.caller_id, topic, protocols)))
protocols = [['FakeTransport', 1234, 5678], [TCPROS], ['AnotherFakeTransport']]
# try each one more time, this time with more protocol choices
for topic in topics:
self.check_TCPROS(self.apiSuccess(node.requestTopic(self.caller_id, topic, protocols)))
# test bad arity
if probe_topic:
try:
self.apiError(node.requestTopic(self.caller_id, probe_topic, protocols, 'extra stuff'))
except Fault:
pass
try:
self.apiError(node.requestTopic(self.caller_id, probe_topic))
except Fault:
pass
try:
self.apiError(node.requestTopic(self.caller_id))
except Fault:
pass
try:
self.apiError(node.requestTopic())
except Fault:
pass
# test bad args
try:
self.apiError(node.requestTopic(self.caller_id, 1, protocols))
except Fault:
pass
try:
self.apiError(node.requestTopic(self.caller_id, '', protocols))
except Fault:
pass
try:
self.apiError(node.requestTopic(self.caller_id, fake_topic, protocols))
except Fault:
pass
try:
self.apiError(node.requestTopic(self.caller_id, probe_topic, 'fake-protocols'))
except Fault:
pass
def test_getBusInfo(self):
#TODO: finish
# there should be a connection to rosout
# test bad arity
try:
self.apiError(self.node.getBusInfo(self.caller_id, 'bad'))
except Fault:
pass
try:
self.apiError(self.node.getBusInfo())
except Fault:
pass
## test the state of the master based on expected node registration
def test_registrations(self):
# setUp() ensures the node has registered with the master
# check actual URIs
node_name = self.test_node
pubs, subs, srvs = self.master.getSystemState()
pub_topics = [t for t, _ in pubs]
sub_topics = [t for t, _ in subs]
# make sure all required topics are registered
for t in self.required_pubs:
self.assert_(t in pub_topics, "node did not register publication %s on master"%(t))
for t in self.required_subs:
self.assert_(t in sub_topics, "node did not register subscription %s on master"%(t))
# check for node URI on master
for topic, node_list in pubs:
if topic in self.required_pubs:
self.assert_(node_name in node_list, "%s not in %s"%(self.node_api, node_list))
for topic, node_list in subs:
if topic in self.required_subs:
self.assert_(node_name in node_list, "%s not in %s"%(self.node_api, node_list))
for service, srv_list in srvs:
#TODO: no service tests yet
pass