def genSipconf(co, lo, srv): import sipPhone, fax conf = "; Automatisch generiert von asterisk4UCS\n" conf += "\n" conf += "[general]\n" conf += "allowsubscribe = yes\n" conf += "notifyringing = yes\n" conf += "notifyhold = yes\n" conf += "limitonpeers = yes\n" conf += "\n" conf += "\n\n; ===== Phones =====\n\n" for phone in sipPhone.lookup(co, lo, False): conf += "; dn: %s\n" % (phone.dn) try: conf += genSipconfEntry(co, lo, phone) except: conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1] ) conf += "\n" conf += "\n\n; ===== Faxes =====\n\n" for phone in fax.lookup(co, lo, False): conf += "; dn: %s\n" % (phone.dn) try: conf += genSipconfFaxEntry(co, lo, phone) except: conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1] ) conf += "\n" return conf
def genExtensionsconf(co, lo, srv): import sipPhone, conferenceRoom, waitingLoop # AGI-Script lookup and sorting agis = [] for agi in agiscript.lookup(co, lo, False): agis.append(( int(agi["priority"]), "AGI(ast4ucs-%s)" % agi["name"] )) sortkey = lambda x: x[0] agis.sort(key=sortkey, reverse=True) agis = [x[1] for x in agis] conf = "; Automatisch generiert von Asterisk4UCS\n" conf += "\n[default]\n" conf += "\n\n; ===== Telefone =====\n\n" for phone in sipPhone.lookup(co, lo, False): conf += "; dn: %s\n" % (phone.dn) try: conf += genExtSIPPhoneEntry(co, lo, agis, phone) except: conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1] ) conf += "\n" conf += "\n\n; ===== Konferenzräume =====\n\n" for room in conferenceRoom.lookup(co, lo, False): conf += "; dn: %s\n" % (room.dn) try: conf += genExtRoomEntry(co, lo, agis, room) except: conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1] ) conf += "\n" conf += "\n\n; ===== Warteschleifen =====\n\n" for queue in waitingLoop.lookup(co, lo, False): conf += "; dn: %s\n" % (queue.dn) try: conf += genExtQueueEntry(co, lo, agis, queue) except: conf += re.sub("(?m)^", ";", traceback.format_exc()[:-1] ) conf += "\n" conf += "\n\n; ===== Blockierte Vorwahlen =====\n\n" for areaCode in srv.info.get("blockedAreaCodes", []): conf += "exten => _%s.,1,Hangup()\n" % (areaCode) conf += "\n\n; ===== Faxe =====\n\n" for phone in fax.lookup(co, lo, False): for i, agi in enumerate(agis): conf += "exten => %s,%i,%s" % ( phone["extension"], i + 1, agi ) conf += "exten => %s,%i,Dial(SIP/%s)\n" % ( phone.info["extension"], len(agis) + 1, phone.info["extension"]) conf += "\n[extern-incoming]\n" conf += "\n\n; ===== Nummernkreise =====\n\n" for extnum in llist(srv.info.get("extnums", [])): conf += "exten => _%s,1,Goto(default,%s,1)\n" % ( extnum, srv.info.get("defaultext", "fubar")) conf += "exten => _%s.,1,Goto(default,${EXTEN:%i},1)\n" % ( extnum, len(extnum)) return conf