Re: траблы Asterisk::AGI
Не знаю, у меня в python таких проблем нет.
#### Dial trunk by trunk
c.execute("select trunks from routes where pattern = '%s'" % pattern)
trunks = c.fetchone()[0]
for trunk in trunks.split(':'):
c.execute("select tech,path from trunks where name='%s'" % trunk)
res = c.fetchone()
if not res:
## TODO
agi.verbose('No routes for trunk name %s ' % trunk[0])
tech,path = res
res = agi.appexec('Dial','%s/%s/%s|%s|HS(%s)' % tech,path,agi.env['agi_extension'],DIAL_TIMEOUT,maxseconds))
status = agi.get_variable('DIALSTATUS')
try:
answered_time = int(agi.get_variable('ANSWEREDTIME'))
except agilib.AGIException,ValueError:
answered_time = 0
if status == 'ANSWER':
if answered_time < 30: answered_time = 30
callcost = int(answered_time) * cost / 60
save_cdr(ip,agi.env['agi_extension'],trunk,status,answered_time,callcost)
update_account(ip,callcost)
elif status == 'BUSY':
agi.stream_file('astcc-isbusy')
save_cdr(ip,agi.env['agi_extension'],trunk,status,0,0)
elif status == 'CANCEL':
save_cdr(ip,agi.env['agi_extension'],trunk,status,0,0)
elif status == 'NOANSWER':
agi.stream_file('astcc-noanswer')
save_cdr(ip,agi.env['agi_extension'],trunk,status,0,0)
elif status in ['CONGESTION','CHANUNAVAIL']:
continue
|