Asterisk.Manager
index
/usr/src/ks-voip/py-asterisk/Asterisk/Manager.py

Asterisk Manager and Channel objects.

 
Modules
       
Asterisk
errno
logging
os
socket
time

 
Classes
       
Asterisk.BaseException(exceptions.Exception)
BaseException
ActionFailed
AuthenticationFailure
CommunicationError
GoneAwayError
InternalError
PermissionDenied
Asterisk.Logging.InstanceLogger(__builtin__.object)
BaseChannel
ZapChannel
BaseManager
CoreManager(BaseManager, CoreActions, ZapataActions)
Manager(BaseManager, CoreActions, ZapataActions)
__builtin__.object
CoreActions
ZapataActions

 
class ActionFailed(BaseException)
    This exception is raised when a PBX action fails.
 
 
Method resolution order:
ActionFailed
BaseException
Asterisk.BaseException
exceptions.Exception

Methods inherited from Asterisk.BaseException:
__init__(self, error)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class AuthenticationFailure(BaseException)
    This exception is raised when authentication to the PBX instance fails.
 
 
Method resolution order:
AuthenticationFailure
BaseException
Asterisk.BaseException
exceptions.Exception

Methods inherited from Asterisk.BaseException:
__init__(self, error)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class BaseChannel(Asterisk.Logging.InstanceLogger)
    Represents a living Asterisk channel, with shortcut methods for operating
on it. The object acts as a mapping, ie. you may get and set items of it.
This translates to Getvar and Setvar actions on the channel.
 
 
Method resolution order:
BaseChannel
Asterisk.Logging.InstanceLogger
__builtin__.object

Methods defined here:
AbsoluteTimeout(self, timeout)
Set the absolute timeout of this channel to <timeout>.
ChangeMonitor(self, pathname)
Change the monitor filename of this channel to <pathname>.
Getvar(self, variable, default=<Asterisk.Util.Unspecified>)
Return the value of this channel's <variable>, or <default> if variable
is not set.
Hangup(self)
Hangup this channel.
Monitor(self, pathname, format, mix)
Begin monitoring of this channel into <pathname> using <format>.
Redirect(self, context, extension='s', priority=1, channel2=None)
Redirect this channel to <priority> of <extension> in <context>,
optionally bridging with <channel2>.
SetCDRUserField(self, data, append=False)
Append or replace this channel's CDR user field with <data>.
Setvar(self, variable, value)
Set the <variable> in this channel to <value>.
Status(self)
Return the Status() dict for this channel (wasteful!).
StopMonitor(self)
Stop monitoring of this channel.
__eq__(self, other)
Return truth if <other> is equal to this object.
__getitem__(self, key)
Fetch <key> as a variable from this channel.
__hash__(self)
Return the hash value of this channel.
__init__(self, manager, id)
Initialise a new Channel object belonging to <id> reachable via
BaseManager <manager>.
__repr__(self)
__setitem__(self, key, value)
Set <key> as a variable on this channel.
__str__(self)

Methods inherited from Asterisk.Logging.InstanceLogger:
getLogger(self)
Return the Logger instance which receives debug messages for this class
instance.
getLoggerName(self)
Return the name where log messages for this instance is sent.

Data and other attributes inherited from Asterisk.Logging.InstanceLogger:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'InstanceLogger' objects>
list of weak references to the object (if defined)

 
class BaseException(Asterisk.BaseException)
    Base class for all Asterisk Manager API exceptions.
 
 
Method resolution order:
BaseException
Asterisk.BaseException
exceptions.Exception

Methods inherited from Asterisk.BaseException:
__init__(self, error)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class BaseManager(Asterisk.Logging.InstanceLogger)
    Base protocol implementation for the Asterisk Manager API.
 
 
Method resolution order:
BaseManager
Asterisk.Logging.InstanceLogger
__builtin__.object

Methods defined here:
__init__(self, address, username, secret, listen_events=True)
Provide communication methods for the PBX instance running at
<address>. Authenticate using <username> and <secret>. Receive event
information from the Manager API if <listen_events> is True.
__repr__(self)
Return a string representation of this object.
close(self)
Log off and close the connection to the PBX.
get_channel(self, channel_id)
Return a channel object for the given <channel_id>.
on_Event(self, event)
Triggered when an event is received from the Manager.
read(self)
Called by the parent code when activity is detected on our fd.
read_response(self, id)
Return the response packet found for the given action <id>.
responses_waiting(self)
Return truth if there are unprocessed buffered responses.
serve_forever(self)
Handle one event at a time until doomsday.
strip_evinfo(self, event)
Given an event, remove it's ActionID and Event members.

Methods inherited from Asterisk.Logging.InstanceLogger:
getLogger(self)
Return the Logger instance which receives debug messages for this class
instance.
getLoggerName(self)
Return the name where log messages for this instance is sent.

Data and other attributes inherited from Asterisk.Logging.InstanceLogger:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'InstanceLogger' objects>
list of weak references to the object (if defined)

 
class CommunicationError(BaseException)
    This exception is raised when the PBX responds in an unexpected manner.
 
 
Method resolution order:
CommunicationError
BaseException
Asterisk.BaseException
exceptions.Exception

Methods defined here:
__init__(self, packet, msg=None)

Methods inherited from Asterisk.BaseException:
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class CoreActions(__builtin__.object)
    Provide methods for Manager API actions exposed by the core Asterisk
engine.
 
  Methods defined here:
AbsoluteTimeout(self, channel, timeout)
Set the absolute timeout of <channel> to <timeout>.
ChangeMonitor(self, channel, pathname)
Change the monitor filename of <channel> to <pathname>.
Command(self, command)
Execute console command <command> and return its output lines.
Events(self, categories)
Filter received events to only those in the list <categories>.
ExtensionState(self, context, extension)
Return the state of <extension> in <context>.
Getvar(self, channel, variable, default=<Asterisk.Util.Unspecified>)
Return the value of <channel>'s <variable>, or <default> if <variable>
is not set.
Hangup(self, channel)
Hangup <channel>.
ListCommands(self)
Return a dict of all available <action> => <desc> items.
Logoff(self)
Close the connection to the PBX.
MailboxCount(self, mailbox)
Return a (<new_msgs>, <old_msgs>) tuple for the given <mailbox>.
MailboxStatus(self, mailbox)
Return the number of messages in <mailbox>.
Monitor(self, channel, pathname, format, mix)
Begin monitoring of <channel> into <pathname> using <format>.
Originate(self, channel, context=None, extension=None, priority=None, application=None, data=None, timeout=None, caller_id=None, variable=None, account=None, async=None)
Originate(channel, context = .., extension = .., priority = ..[, ...])
Originate(channel, application = ..[, data = ..[, ...]])
 
Originate a call on <channel>, bridging it to the specified dialplan
extension (format 1) or application (format 2).
 
    <context>       Dialplan context to bridge with.
    <extension>     Context extension to bridge with.
    <priority>      Context priority to bridge with.
 
    <application>   Application to bridge with.
    <data>          Application parameters.
 
    <timeout>       Answer timeout for <channel> in milliseconds.
    <caller_id>     Outgoing channel Caller ID.
    <variable>      channel variable to set (K=V[|K2=V2[|..]]).
    <account>       CDR account code.
    <async>         Return successfully immediately.
Originate2(self, channel, parameters)
Originate a call, using parameters in the mapping <parameters>.
Provided for compatibility with RPC bridges that do not support keyword
arguments.
ParkedCalls(self)
Return a nested dict describing currently parked calls.
Ping(self)
No-op to ensure the PBX is still there and keep the connection alive.
QueueAdd(self, queue, interface, penalty=0)
Add <interface> to <queue> with optional <penalty>.
QueueRemove(self, queue, interface)
Remove <interface> from <queue>.
QueueStatus(self)
Return a complex nested dict describing queue statii.
Queues = QueueStatus(self)
Redirect(self, channel, context, extension='s', priority=1, channel2=None)
Redirect <channel> to <priority> of <extension> in <context>,
optionally bridging with <channel2>
SetCDRUserField(self, channel, data, append=False)
Append or replace <channel>'s CDR user field with <data>'.
Setvar(self, channel, variable, value)
Set <variable> of <channel> to <value>.
Status(self)
Return a nested dict of channel statii.
StopMonitor(self, channel)
Stop monitoring of <channel>.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'CoreActions' objects>
list of weak references to the object (if defined)

 
class CoreManager(BaseManager, CoreActions, ZapataActions)
    Asterisk Manager API protocol implementation and core actions, but without
event handlers.
 
 
Method resolution order:
CoreManager
BaseManager
Asterisk.Logging.InstanceLogger
CoreActions
ZapataActions
__builtin__.object

Methods inherited from BaseManager:
__init__(self, address, username, secret, listen_events=True)
Provide communication methods for the PBX instance running at
<address>. Authenticate using <username> and <secret>. Receive event
information from the Manager API if <listen_events> is True.
__repr__(self)
Return a string representation of this object.
close(self)
Log off and close the connection to the PBX.
get_channel(self, channel_id)
Return a channel object for the given <channel_id>.
on_Event(self, event)
Triggered when an event is received from the Manager.
read(self)
Called by the parent code when activity is detected on our fd.
read_response(self, id)
Return the response packet found for the given action <id>.
responses_waiting(self)
Return truth if there are unprocessed buffered responses.
serve_forever(self)
Handle one event at a time until doomsday.
strip_evinfo(self, event)
Given an event, remove it's ActionID and Event members.

Methods inherited from Asterisk.Logging.InstanceLogger:
getLogger(self)
Return the Logger instance which receives debug messages for this class
instance.
getLoggerName(self)
Return the name where log messages for this instance is sent.

Data and other attributes inherited from Asterisk.Logging.InstanceLogger:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'InstanceLogger' objects>
list of weak references to the object (if defined)

Methods inherited from CoreActions:
AbsoluteTimeout(self, channel, timeout)
Set the absolute timeout of <channel> to <timeout>.
ChangeMonitor(self, channel, pathname)
Change the monitor filename of <channel> to <pathname>.
Command(self, command)
Execute console command <command> and return its output lines.
Events(self, categories)
Filter received events to only those in the list <categories>.
ExtensionState(self, context, extension)
Return the state of <extension> in <context>.
Getvar(self, channel, variable, default=<Asterisk.Util.Unspecified>)
Return the value of <channel>'s <variable>, or <default> if <variable>
is not set.
Hangup(self, channel)
Hangup <channel>.
ListCommands(self)
Return a dict of all available <action> => <desc> items.
Logoff(self)
Close the connection to the PBX.
MailboxCount(self, mailbox)
Return a (<new_msgs>, <old_msgs>) tuple for the given <mailbox>.
MailboxStatus(self, mailbox)
Return the number of messages in <mailbox>.
Monitor(self, channel, pathname, format, mix)
Begin monitoring of <channel> into <pathname> using <format>.
Originate(self, channel, context=None, extension=None, priority=None, application=None, data=None, timeout=None, caller_id=None, variable=None, account=None, async=None)
Originate(channel, context = .., extension = .., priority = ..[, ...])
Originate(channel, application = ..[, data = ..[, ...]])
 
Originate a call on <channel>, bridging it to the specified dialplan
extension (format 1) or application (format 2).
 
    <context>       Dialplan context to bridge with.
    <extension>     Context extension to bridge with.
    <priority>      Context priority to bridge with.
 
    <application>   Application to bridge with.
    <data>          Application parameters.
 
    <timeout>       Answer timeout for <channel> in milliseconds.
    <caller_id>     Outgoing channel Caller ID.
    <variable>      channel variable to set (K=V[|K2=V2[|..]]).
    <account>       CDR account code.
    <async>         Return successfully immediately.
Originate2(self, channel, parameters)
Originate a call, using parameters in the mapping <parameters>.
Provided for compatibility with RPC bridges that do not support keyword
arguments.
ParkedCalls(self)
Return a nested dict describing currently parked calls.
Ping(self)
No-op to ensure the PBX is still there and keep the connection alive.
QueueAdd(self, queue, interface, penalty=0)
Add <interface> to <queue> with optional <penalty>.
QueueRemove(self, queue, interface)
Remove <interface> from <queue>.
QueueStatus(self)
Return a complex nested dict describing queue statii.
Queues = QueueStatus(self)
Return a complex nested dict describing queue statii.
Redirect(self, channel, context, extension='s', priority=1, channel2=None)
Redirect <channel> to <priority> of <extension> in <context>,
optionally bridging with <channel2>
SetCDRUserField(self, channel, data, append=False)
Append or replace <channel>'s CDR user field with <data>'.
Setvar(self, channel, variable, value)
Set <variable> of <channel> to <value>.
Status(self)
Return a nested dict of channel statii.
StopMonitor(self, channel)
Stop monitoring of <channel>.

Methods inherited from ZapataActions:
ZapDNDoff(self, channel)
Disable DND status on Zapata driver <channel>.
ZapDNDon(self, channel)
Enable DND status on Zapata driver <channel>.
ZapDialOffhook(self, channel, number)
Off-hook dial <number> on Zapata driver <channel>.
ZapHangup(self, channel)
Hangup Zapata driver <channel>.
ZapShowChannels(self)
Return a nested dict of Zapata driver channel statii.
ZapTransfer(self, channel)
Transfer Zapata driver <channel>.

 
class GoneAwayError(BaseException)
    This exception is raised when the Manager connection becomes closed.
 
 
Method resolution order:
GoneAwayError
BaseException
Asterisk.BaseException
exceptions.Exception

Methods inherited from Asterisk.BaseException:
__init__(self, error)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class InternalError(BaseException)
    This exception is raised when an error occurs within a Manager object.
 
 
Method resolution order:
InternalError
BaseException
Asterisk.BaseException
exceptions.Exception

Methods inherited from Asterisk.BaseException:
__init__(self, error)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class Manager(BaseManager, CoreActions, ZapataActions)
    Asterisk Manager API protocol implementation, core event handler
placeholders, and core actions.
 
 
Method resolution order:
Manager
BaseManager
Asterisk.Logging.InstanceLogger
CoreActions
ZapataActions
__builtin__.object

Methods inherited from BaseManager:
__init__(self, address, username, secret, listen_events=True)
Provide communication methods for the PBX instance running at
<address>. Authenticate using <username> and <secret>. Receive event
information from the Manager API if <listen_events> is True.
__repr__(self)
Return a string representation of this object.
close(self)
Log off and close the connection to the PBX.
get_channel(self, channel_id)
Return a channel object for the given <channel_id>.
on_Event(self, event)
Triggered when an event is received from the Manager.
read(self)
Called by the parent code when activity is detected on our fd.
read_response(self, id)
Return the response packet found for the given action <id>.
responses_waiting(self)
Return truth if there are unprocessed buffered responses.
serve_forever(self)
Handle one event at a time until doomsday.
strip_evinfo(self, event)
Given an event, remove it's ActionID and Event members.

Methods inherited from Asterisk.Logging.InstanceLogger:
getLogger(self)
Return the Logger instance which receives debug messages for this class
instance.
getLoggerName(self)
Return the name where log messages for this instance is sent.

Data and other attributes inherited from Asterisk.Logging.InstanceLogger:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'InstanceLogger' objects>
list of weak references to the object (if defined)

Methods inherited from CoreActions:
AbsoluteTimeout(self, channel, timeout)
Set the absolute timeout of <channel> to <timeout>.
ChangeMonitor(self, channel, pathname)
Change the monitor filename of <channel> to <pathname>.
Command(self, command)
Execute console command <command> and return its output lines.
Events(self, categories)
Filter received events to only those in the list <categories>.
ExtensionState(self, context, extension)
Return the state of <extension> in <context>.
Getvar(self, channel, variable, default=<Asterisk.Util.Unspecified>)
Return the value of <channel>'s <variable>, or <default> if <variable>
is not set.
Hangup(self, channel)
Hangup <channel>.
ListCommands(self)
Return a dict of all available <action> => <desc> items.
Logoff(self)
Close the connection to the PBX.
MailboxCount(self, mailbox)
Return a (<new_msgs>, <old_msgs>) tuple for the given <mailbox>.
MailboxStatus(self, mailbox)
Return the number of messages in <mailbox>.
Monitor(self, channel, pathname, format, mix)
Begin monitoring of <channel> into <pathname> using <format>.
Originate(self, channel, context=None, extension=None, priority=None, application=None, data=None, timeout=None, caller_id=None, variable=None, account=None, async=None)
Originate(channel, context = .., extension = .., priority = ..[, ...])
Originate(channel, application = ..[, data = ..[, ...]])
 
Originate a call on <channel>, bridging it to the specified dialplan
extension (format 1) or application (format 2).
 
    <context>       Dialplan context to bridge with.
    <extension>     Context extension to bridge with.
    <priority>      Context priority to bridge with.
 
    <application>   Application to bridge with.
    <data>          Application parameters.
 
    <timeout>       Answer timeout for <channel> in milliseconds.
    <caller_id>     Outgoing channel Caller ID.
    <variable>      channel variable to set (K=V[|K2=V2[|..]]).
    <account>       CDR account code.
    <async>         Return successfully immediately.
Originate2(self, channel, parameters)
Originate a call, using parameters in the mapping <parameters>.
Provided for compatibility with RPC bridges that do not support keyword
arguments.
ParkedCalls(self)
Return a nested dict describing currently parked calls.
Ping(self)
No-op to ensure the PBX is still there and keep the connection alive.
QueueAdd(self, queue, interface, penalty=0)
Add <interface> to <queue> with optional <penalty>.
QueueRemove(self, queue, interface)
Remove <interface> from <queue>.
QueueStatus(self)
Return a complex nested dict describing queue statii.
Queues = QueueStatus(self)
Return a complex nested dict describing queue statii.
Redirect(self, channel, context, extension='s', priority=1, channel2=None)
Redirect <channel> to <priority> of <extension> in <context>,
optionally bridging with <channel2>
SetCDRUserField(self, channel, data, append=False)
Append or replace <channel>'s CDR user field with <data>'.
Setvar(self, channel, variable, value)
Set <variable> of <channel> to <value>.
Status(self)
Return a nested dict of channel statii.
StopMonitor(self, channel)
Stop monitoring of <channel>.

Methods inherited from ZapataActions:
ZapDNDoff(self, channel)
Disable DND status on Zapata driver <channel>.
ZapDNDon(self, channel)
Enable DND status on Zapata driver <channel>.
ZapDialOffhook(self, channel, number)
Off-hook dial <number> on Zapata driver <channel>.
ZapHangup(self, channel)
Hangup Zapata driver <channel>.
ZapShowChannels(self)
Return a nested dict of Zapata driver channel statii.
ZapTransfer(self, channel)
Transfer Zapata driver <channel>.

 
class PermissionDenied(BaseException)
    This exception is raised when our connection is not permitted to perform a
requested action.
 
 
Method resolution order:
PermissionDenied
BaseException
Asterisk.BaseException
exceptions.Exception

Methods inherited from Asterisk.BaseException:
__init__(self, error)
__str__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)

 
class ZapChannel(BaseChannel)
    
Method resolution order:
ZapChannel
BaseChannel
Asterisk.Logging.InstanceLogger
__builtin__.object

Methods defined here:
ZapDNDoff(self)
Disable DND status on this Zapata driver channel.
ZapDNDon(self)
Enable DND status on this Zapata driver channel.
ZapDialOffhook(self, number)
Off-hook dial <number> on this Zapata driver channel.
ZapHangup(self)
Hangup this Zapata driver channel.
ZapTransfer(self)
Transfer this Zapata driver channel.

Methods inherited from BaseChannel:
AbsoluteTimeout(self, timeout)
Set the absolute timeout of this channel to <timeout>.
ChangeMonitor(self, pathname)
Change the monitor filename of this channel to <pathname>.
Getvar(self, variable, default=<Asterisk.Util.Unspecified>)
Return the value of this channel's <variable>, or <default> if variable
is not set.
Hangup(self)
Hangup this channel.
Monitor(self, pathname, format, mix)
Begin monitoring of this channel into <pathname> using <format>.
Redirect(self, context, extension='s', priority=1, channel2=None)
Redirect this channel to <priority> of <extension> in <context>,
optionally bridging with <channel2>.
SetCDRUserField(self, data, append=False)
Append or replace this channel's CDR user field with <data>.
Setvar(self, variable, value)
Set the <variable> in this channel to <value>.
Status(self)
Return the Status() dict for this channel (wasteful!).
StopMonitor(self)
Stop monitoring of this channel.
__eq__(self, other)
Return truth if <other> is equal to this object.
__getitem__(self, key)
Fetch <key> as a variable from this channel.
__hash__(self)
Return the hash value of this channel.
__init__(self, manager, id)
Initialise a new Channel object belonging to <id> reachable via
BaseManager <manager>.
__repr__(self)
__setitem__(self, key, value)
Set <key> as a variable on this channel.
__str__(self)

Methods inherited from Asterisk.Logging.InstanceLogger:
getLogger(self)
Return the Logger instance which receives debug messages for this class
instance.
getLoggerName(self)
Return the name where log messages for this instance is sent.

Data and other attributes inherited from Asterisk.Logging.InstanceLogger:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'InstanceLogger' objects>
list of weak references to the object (if defined)

 
class ZapataActions(__builtin__.object)
    Provide methods for Manager API actions exposed by the Zapata driver.
 
  Methods defined here:
ZapDNDoff(self, channel)
Disable DND status on Zapata driver <channel>.
ZapDNDon(self, channel)
Enable DND status on Zapata driver <channel>.
ZapDialOffhook(self, channel, number)
Off-hook dial <number> on Zapata driver <channel>.
ZapHangup(self, channel)
Hangup Zapata driver <channel>.
ZapShowChannels(self)
Return a nested dict of Zapata driver channel statii.
ZapTransfer(self, channel)
Transfer Zapata driver <channel>.

Data and other attributes defined here:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'ZapataActions' objects>
list of weak references to the object (if defined)

 
Data
        __author__ = 'David M. Wilson <dw-py-asterisk-Manager.py@botanicus.net>'
__id__ = '$Id: Asterisk.Manager.html 103 2004-10-17 21:00:47Z dw $'

 
Author
        David M. Wilson <dw-py-asterisk-Manager.py@botanicus.net>