def inspect(connect, slot=None, verbose=False, asjson=False, **kwargs):
n = parse_slot(slot)
engine = connect.lookup('engine')
if slot == None:
if asjson:
doc = map(lambda x: x.to_dict(), engine.active_streams.values())
print json.dumps(doc, indent=2)
else:
t = [ [x.slot,x.name,transport(x.descriptor),str(x.eof)]
for x in engine.active_streams.values() ]
print tabulate(t, headers=["Slot","Name","Transport","EOF"])
elif n in engine.active_streams:
info = engine.active_streams[n]
if asjson:
print json.dumps(info.to_dict(), indent=2)
else:
t = [[info.slot,info.name,transport(info.descriptor),str(info.eof)]]
print tabulate(t, headers=["Slot","Name","Transport","EOF"])
else:
if asjson:
print "null"
else:
print "No stream attached to slot %s" % slot
评论列表
文章目录