documentation

This page contains a list of all official pycall documentation. It lists exactly what features pycall provides you.

classes

pycall contains a single class, CallFile. To use the CallFile class, it must be imported from pycall.callfile:

from pycall.callfile import CallFile

The fields that CallFile contains can be specified when a CallFile object is created, or at any other time. Fields listed in bold may be required.

trunk_type

The type of trunk to use (SIP / Local / DAHDI / etc.) When pycall generates the actual call file, this will show up in the Channel directive.

trunk_name

The name of the trunk to use (flowroute, g0, etc.) When pycall generates the actual call file, this will show up in the Channel directive.

number

The number we are going to call. Must be presented as it should be dialed, you cannot rely on the PBX rules to format it correctly.

callerid_name

The textual name to show on caller ID (if your provider supports it).

callerid_num

The numerical caller ID to show (if your provider supports it).

max_retries

The maximum amount of times to retry the call if it is not answered. Default is 0.

retry_time

The amount of seconds between retry attempts. Default is 300 (5 minutes).

wait_time

The amount of seconds to ring the number while waiting for an answer. Default is 45.

account

The account code associated with the call. Account codes are used in Asterisk CDR logs.

context

The context to go to once the call has been answered. Standard Asterisk dial plan references contexts in this form: [context].

extension

The extension to go to once the call has been answered. Standard Asterisk dial plan references extensions in this form: exten => extension,priority,action.

priority

The priority to go to once the call has been answered. Standard Asterisk dial plan references priorities in this form: exten => extension,priority,action.

application

The dial plan application to run once the call has been answered. Standard Asterisk dial plan references applications (actions) in this form: exten => extension,priority,action.

data

The options to be passed to the application. Standard Asterisk dial plan references data in this form: exten => extension,priority,action(data).

sets

A python dictionary containing any channel variables that should be set, and their values.

always_delete

If the file's modification time is in the future, the call will not be deleted.

Can be either True or False.

archive

Move the completed call file to the sub-spooling directory outgoing_done and append a new line reading Status: value, where value is Completed, Expired, or Failed.

Can be either True or False.

user

The user to schedule the call file as. If none is specified, then the user who is running the script will own the call file.

tmpdir

The temporary directory where the call file will be generated before finally being moved to the Asterisk spooling directory. The default location is determined by your host operating system (usually /tmp/).

It is generally recommended that this directory be on the same filesystem as the spooling directory.

Note that either context, extension, and priority must be specified -- OR application and data, but not both.

functions

The CallFile class provides a single function:

CallFile.run([time])

Create an actual call file and schedule it with Asterisk. The call file is generated based on the parameters specified in the CallFile object. If time is specified, the call file will be created, and its access time will be set to time. This way, Asterisk will not execute the call file until the the designated time is reached.

This function may raise exceptions (specified below).

exceptions

pycall includes its own exceptions which may be raised when calling the function, run. To use any of the exceptions below, they must be imported from pycall.callfileexceptions:

from pycall.callfileexceptions import NoTrunkTypeDefined

The exceptions are:

NoTrunkTypeDefined

This exception is raised if there is no trunk_type field defined.

NoTrunkNameDefined

This exception is raised if there is no trunk_name field defined.

NoNumberDefined

This exception is raised if there is no number field defined.

NoActionDefined

This exception is raised if there is no action defined. In order to successfully generate a call file, either context, extension, and priority must be specified, or application and data must be specified.

IncorrectTime

This exception is raised if the function run is called with the optional parameter time, and time is not a valid datetime object.

NoAsteriskPermission

This exception is raised if your script does not have permission to move the call file to the Asterisk spooling directory.

NoPermissionException

This exception is raised if the user field is specified, but your script does not have permission to change ownership of the generated call file to the specified user.

NoUserException

This exception is raised if the user field is specified, but the user specified does not exist on the system.

If you would like to see code examples demonstrating pycall usage, you can visit the examples page.