All pastes #907312 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-02-17 14:20 UTC
rendered paste body
                        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 = []