Anonymous
public text v1 · immutable res = self.sendcommand("Action: IAXpeers\nActionID: check_ami")
peercounter = 0
iaxpeers = []
iaxpeer = []
for line in res.split("\n"):
line = line.strip()
if line:
lastpeer = peercounter
if line == "Response: Goodbye":
break;
if line == "Event: PeerEntry":
#peer entry follows
peercounter+=1
if peercounter and lastpeer == peercounter:
(field, value) = line.split(": ")
if field == "Status":
print "status is: %s" % value
iaxpeer.append((field, value))
elif peercounter:
if len(iaxpeer):
iaxpeers.append(iaxpeer)
iaxpeer = []