[Asterisk-Users] AGI Python Clear or Channel Failure?

Martyn Russell martyn.russell at bt.com
Fri Sep 17 07:01:59 MST 2004


Hi All,

When I call the stream_file function all goes well if the user doesn't
clear the call.  But if I do clear the call (on the handset for
example), I get the following exception:

            -- Channel 0/31, span 1 got hangup
            RESULT_LINE: 200 result=-1 endpos=28000
          == Spawn extension (default, 600006, 1) exited non-zero on
        'Zap/31-1'
            RESULT_DICT: {'result': ('-1', ''), 'endpos': ('28000', '')}
        Traceback (most recent call last):
          File "/var/lib/asterisk/agi-bin/clickdial.py", line 450, in ?
            d = agi.stream_file("bt_clickdial_welcome", "0123456789");
          File "/var/lib/asterisk/agi-bin/clickdial.py", line 179, in
        stream_file
            -- Hungup 'Zap/31-1'
            raise AGIException('Channel falure on channel %s' %
        self.env.get('agi_channel','UNKNOWN'))
        __main__.AGIException: Channel falure on channel Zap/31-1


This is easily managed by using exception handling, AND I can look for
the return code (which for all the functions I am using returns) -1 to
know if it was a channel failure or hang up. From the output (above),
Asterisk knows the call has hung up, I assume it does anyway because of
the line:

	    -- Hungup 'Zap/31-1'
        
Is there any way to know if the return code (-1) is a clear or channel
failure?

Thanks,

-- 
Regards,
Martyn



More information about the asterisk-users mailing list