diff --git a/README.rst b/README.rst index bb8a138..c96d77e 100644 --- a/README.rst +++ b/README.rst @@ -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 ------- diff --git a/asterisk/__init__.py b/asterisk/__init__.py index 6815d3a..52350cc 100644 --- a/asterisk/__init__.py +++ b/asterisk/__init__.py @@ -11,4 +11,4 @@ """ __all__ = ['agi', 'agitb', 'config', 'manager'] -__version__ = '0.5.1' +__version__ = '0.5.2' diff --git a/asterisk/agi.py b/asterisk/agi.py index dd1eacf..631f0c3 100755 --- a/asterisk/agi.py +++ b/asterisk/agi.py @@ -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', @@ -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): @@ -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. """ @@ -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") @@ -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") @@ -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': @@ -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=''): @@ -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 diff --git a/asterisk/agitb.py b/asterisk/agitb.py index cdd3be9..5d780ca 100644 --- a/asterisk/agitb.py +++ b/asterisk/agitb.py @@ -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 diff --git a/asterisk/manager.py b/asterisk/manager.py index ce09efc..0fa06ff 100644 --- a/asterisk/manager.py +++ b/asterisk/manager.py @@ -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 @@ -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 @@ -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:]) @@ -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() @@ -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 diff --git a/examples/agi_script.py b/examples/agi_script.py index 13035db..585fcef 100755 --- a/examples/agi_script.py +++ b/examples/agi_script.py @@ -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') \ No newline at end of file +agi.set_variable('EXT_CALLERID', '1')