Python ESL

From FreeSWITCH Wiki
Jump to: navigation, search

Contents

About

The Python ESL module allows for native interaction with FreeSWITCH over the event socket interface. It allows for sending commands, receiving output and sending and receiving events and IVR interaction from the FreeSWITCH server. The Python ESL module is an auto-generated swig python module with a binary component to it. You CANNOT just copy the PM file and use that, you must properly compile the module and get the _ESL.so file generated also (which must be kept in the same directory as the ESL.py). Note any time a change to libesl occurs you will need to re-make and install the python ESL module or else things may break or work un-expectedly.

Installation

In the freeswitch source directory change to libs/esl and run:

make pymod
make pymod-install

This should install the ESL module into your python site-packages folder. If for some reason you want to manually install it or keep it locally you still must run the make pymod command to compile it but then can copy the libs/esl/_ESL.so and libs/esl/ESL.py to a folder of your choosing.

The following libraries may be needed for things to work properly: TBD

CentOS - some dependencies

TBD

Usage

The python module provides two classes ESLconnection and ESLevent they are documented generally (non-python specific) at:

http://docs.freeswitch.org/classESLconnection.html

and

http://docs.freeswitch.org/classESLevent.html

You will want to first include the module:

import ESL;

You can then establish a connection using:

con = ESL.ESLconnection("127.0.0.1", "8021", "ClueCon");


Troubleshooting

TBD

Examples

There are examples in libs/esl/python

  • events.py - subscribe to all events and print them to stdout
  • server.py - TBD
  • single_command.py - execute a single command over ESL