8 import roslib; roslib.load_manifest(PKG)
10 from roslib
import scriptutil
11 from roslib.names
import make_caller_id
16 raise Exception(
"remote call failed: %s"%msg)
21 caller_api = _caller_apis.get(caller_id,
None)
24 code, msg, caller_api = master.lookupNode(caller_id, node_name)
28 _caller_apis[caller_id] = caller_api
30 raise Exception(
"Unable to communicate with master!")
35 caller_id = make_caller_id(
'nodeutil-%s'%os.getpid())
37 master = scriptutil.get_master()
43 raise Exception(
"Unable to communicate with master!")
45 pubs = [t
for t, l
in state[0]
if node_name
in l]
46 subs = [t
for t, l
in state[1]
if node_name
in l]
47 srvs = [t
for t, l
in state[2]
if node_name
in l]
51 "subscriptions": subs,
54 node_api =
get_api_uri(master, node_name, caller_id)
56 results[
"error"] =
"cannot contact [%s]: unknown node"%node_name
61 caller_id = make_caller_id(
'nodeutil-%s'%os.getpid())
62 master = scriptutil.get_master()
68 raise IOException(
"Unable to communicate with master!")
71 publists = [publist
for t, publist
in pubs
if t == topic]
72 sublists = [sublist
for t, sublist
in subs
if t == topic]
78 "error":
"This topic does not appear to be published yet." 82 "publishers": publists[0],
87 "publishers": publists[0],
88 "subscribers": sublists[0]
97 if __name__ ==
"__main__":
def get_api_uri(master, node_name, caller_id)