commit
						432104417d
					
				@ -319,6 +319,7 @@ class Manager(object):
 | 
			
		||||
                        status = True
 | 
			
		||||
                        wait_for_marker = True
 | 
			
		||||
                    lines.append(line)
 | 
			
		||||
 | 
			
		||||
                    # line not ending in \r\n or without ':' isn't a
 | 
			
		||||
                    # valid header and starts multiline response
 | 
			
		||||
                    if not line.endswith('\r\n') or ':' not in line:
 | 
			
		||||
@ -612,6 +613,7 @@ class Manager(object):
 | 
			
		||||
 | 
			
		||||
    def playdtmf(self, channel, digit):
 | 
			
		||||
        """Plays a dtmf digit on the specified channel"""
 | 
			
		||||
        
 | 
			
		||||
        cdict = {'Action': 'PlayDTMF'}
 | 
			
		||||
        cdict['Channel'] = channel
 | 
			
		||||
        cdict['Digit'] = digit
 | 
			
		||||
@ -626,14 +628,12 @@ class Manager(object):
 | 
			
		||||
        cdict['Channel'] = channel
 | 
			
		||||
        cdict['Timeout'] = timeout
 | 
			
		||||
        response = self.send_action(cdict)
 | 
			
		||||
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
    def mailbox_count(self, mailbox):
 | 
			
		||||
        cdict = {'Action': 'MailboxCount'}
 | 
			
		||||
        cdict['Mailbox'] = mailbox
 | 
			
		||||
        response = self.send_action(cdict)
 | 
			
		||||
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
    def sippeers(self):
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										36
									
								
								examples/show_channels.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								examples/show_channels.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,36 @@
 | 
			
		||||
"""
 | 
			
		||||
Example to get list of active channels
 | 
			
		||||
"""
 | 
			
		||||
import asterisk.manager
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
manager = asterisk.manager.Manager()
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    # connect to the manager
 | 
			
		||||
    try:
 | 
			
		||||
        manager.connect('localhost')
 | 
			
		||||
        manager.login('user', 'secret')
 | 
			
		||||
 | 
			
		||||
        # get a status report
 | 
			
		||||
        response = manager.status()
 | 
			
		||||
        print response
 | 
			
		||||
        
 | 
			
		||||
        response = manager.command('core show channels concise')
 | 
			
		||||
        print response.data
 | 
			
		||||
 | 
			
		||||
        manager.logoff()
 | 
			
		||||
    except asterisk.manager.ManagerSocketException, (errno, reason):
 | 
			
		||||
        print "Error connecting to the manager: %s" % reason
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    except asterisk.manager.ManagerAuthException, reason:
 | 
			
		||||
        print "Error logging in to the manager: %s" % reason
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    except asterisk.manager.ManagerException, reason:
 | 
			
		||||
        print "Error: %s" % reason
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
finally:
 | 
			
		||||
    # remember to clean up
 | 
			
		||||
    manager.close()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user