Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ directly on the host where Asterisk is running. Since Asterisk doesn't
run on windows platforms (and probably never will) the agi part of the
package can only be run on Asterisk platforms.

Examples are available in the `examples/` directory.

FastAGI
-------

Expand Down
2 changes: 1 addition & 1 deletion asterisk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"""

__all__ = ['agi', 'agitb', 'config', 'manager']
__version__ = '0.5.1'
__version__ = '0.5.2'
22 changes: 11 additions & 11 deletions asterisk/agi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set et sw=4 fenc=utf-8:
# vim: set et sw=4 fenc=utf-8:
"""
.. module:: agi
:synopsis: This module contains functions and classes to implment AGI scripts in python.
:synopsis: This module contains functions and classes to implement AGI scripts in python.

pyvr

{'agi_callerid' : 'mars.putland.int',
Expand Down Expand Up @@ -52,7 +52,7 @@ class AGIAppError(AGIError):
pass

# there are several different types of hangups we can detect
# they all are derrived from AGIHangup
# they all are derived from AGIHangup


class AGIHangup(AGIAppError):
Expand Down Expand Up @@ -82,10 +82,10 @@ class AGIUsageError(AGIError):
class AGIInvalidCommand(AGIError):
pass


class AGI:
"""
This class encapsulates communication between Asterisk an a python script.
This class encapsulates communication between Asterisk and a python script.
It handles encoding commands to Asterisk and parsing responses from
Asterisk.
"""
Expand Down Expand Up @@ -138,7 +138,7 @@ def _handle_sighup(self, signum, frame):
self._got_sighup = True

def test_hangup(self):
"""This function throws AGIHangup if we have recieved a SIGHUP"""
"""This function throws AGIHangup if we have received a SIGHUP"""
if self._got_sighup:
raise AGISIGHUPHangup("Received SIGHUP from Asterisk")

Expand Down Expand Up @@ -185,7 +185,7 @@ def get_result(self, stdin=sys.stdin):

# If user hangs up... we get 'hangup' in the data
if data == 'hangup':
raise AGIResultHangup("User hungup during execution")
raise AGIResultHangup("User hung up during execution")

if key == 'result' and value == '-1':
raise AGIAppError("Error executing application, or hangup")
Expand Down Expand Up @@ -225,7 +225,7 @@ def wait_for_digit(self, timeout=DEFAULT_TIMEOUT):
"""agi.wait_for_digit(timeout=DEFAULT_TIMEOUT) --> digit
Waits for up to 'timeout' milliseconds for a channel to receive a DTMF
digit. Returns digit dialed
Throws AGIError on channel falure
Throws AGIError on channel failure
"""
res = self.execute('WAIT FOR DIGIT', timeout)['result'][0]
if res == '0':
Expand Down Expand Up @@ -320,7 +320,7 @@ def send_image(self, filename):
"""
res = self.execute('SEND IMAGE', filename)['result'][0]
if res != '0':
raise AGIAppError('Channel falure on channel %s' %
raise AGIAppError('Channel failure on channel %s' %
self.env.get('agi_channel', 'UNKNOWN'))

def say_digits(self, digits, escape_digits=''):
Expand Down Expand Up @@ -656,7 +656,7 @@ def database_put(self, family, key, value):
family), self._quote(key), self._quote(value))
res, value = result['result']
if res == '0':
raise AGIDBError('Unable to put vaule in databale: family=%s, key=%s, value=%s' % (family, key, value))
raise AGIDBError('Unable to put value in database: family=%s, key=%s, value=%s' % (family, key, value))

def database_del(self, family, key):
"""agi.database_del(family, key) --> None
Expand Down
4 changes: 2 additions & 2 deletions asterisk/agitb.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def handle(self, info=None):
self.file.write(doc + '\n')

if self.agi:
self.agi.verbose('A problem occured in a python script', 4)
self.agi.verbose('A problem occurred in a python script', 4)
else:
self.file.write('A problem occured in a python script\n')
self.file.write('A problem occurred in a python script\n')

if self.logdir is not None:
import os
Expand Down
12 changes: 6 additions & 6 deletions asterisk/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def handle_event(event, manager):

Remember all header, response, and event names are case sensitive.

Not all manager actions are implmented as of yet, feel free to add them
Not all manager actions are implemented as of yet, feel free to add them
and submit patches.

Specification
Expand Down Expand Up @@ -90,7 +90,7 @@ def __init__(self, response):
# 'dialplan show something') contains a \n\r\n sequence in the
# middle of output. We hope this happens only *once* during a
# misbehaved command *and* the command ends with --END COMMAND--
# in that case we return an Event. Otherwise we asume it is
# in that case we return an Event. Otherwise we assume it is
# from a misbehaving command not returning a proper header (e.g.
# IAXnetstats in Asterisk 1.4.X)
# A better solution is probably to retain some knowledge of
Expand All @@ -113,7 +113,7 @@ def parse(self, response):
data = []
for n, line in enumerate(response):
# all valid header lines end in \r\n in Asterisk<=13
# and all valid headers lines in Asterisk>13 dont's starts
# and all valid headers lines in Asterisk>13 dont's start
# with 'Output:'
if not line.endswith('\r\n') or line.startswith('Output:'):
data.extend(response[n:])
Expand Down Expand Up @@ -407,11 +407,11 @@ def unregister_event(self, event, function):
def message_loop(self):
"""
The method for the event thread.
This actually recieves all types of messages and places them
This actually receives all types of messages and places them
in the proper queues.
"""

# start a thread to recieve data
# start a thread to receive data
t = threading.Thread(target=self._receive_data)
t.setDaemon(True)
t.start()
Expand Down Expand Up @@ -529,7 +529,7 @@ def close(self):
# Manager actions

def login(self, username, secret):
"""Login to the manager, throws ManagerAuthException when login falis"""
"""Login to the manager, throws ManagerAuthException when login fails"""

cdict = {'Action': 'Login'}
cdict['Username'] = username
Expand Down
2 changes: 1 addition & 1 deletion examples/agi_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
phone_exten = agi.get_variable('PHONE_EXTEN')

# Set variable, it will be available in dialplan
agi.set_variable('EXT_CALLERID', '1')
agi.set_variable('EXT_CALLERID', '1')