PyKannel
From MobileHacking.org
PyKannel is a python library that provides an interface to the SMS functionality provided by Kannel. It can be used from within any python application to add telephony features. With Kannel's stability and scalability, it is possible to put together a robust SMS-enabled application very quickly.
Installation
1) Download PyKannel from GitHub using the following command (you will have to install Git to do this).
git clone git://github.com/adammck/pykannel.git
Now, you will need to make sure that it is in your python path. This can be done in several ways. Probably the most common is to:
2) Put PyKannel somewhere and then symlink to it from your site-packages directory. Depending on the operating system you are using and how you installed Python, this can be in one of several places. You should be able to search your file system to find the appropriate directory. For example on Ubuntu Hardy, the default is /usr/lib/python2.5/site-packages/. To do this, first move pykannel to where you want to keep it:
mv pykannel /path/to/where/you/want/it/
and then create a symlink from your site-packages to kannel.py:
sudo ln -s /path/to/where/you/want/it/pykannel/kannel.py /path/to/your/site-packages/kannel.py
3) Test your installation by opening a python prompt:
python
then at the python prompt import pykannel:
from kannel import *
This command should run without any error. If you get an "ImportError: No module named..." error, then you do not have it setup correctly and need to make sure that it is in your path. Run:
cd /path/to/your/site-packages ls -al
You should see a line such as:
... kannel.py -> /path/to/where/you/want/it/pykannel/kannel.py ...
in the output.
4) Once you can run that with no error, you have installed pykannel successfully and can start to build applications with it.
Running
PyKannel has a built in test to show you how it works. Make sure you have your phone plugged in and that you have Kannel installed and working OK. You will probably need to edit the Kannel username and password in kannel.py to reflect your settings before you can run the test. Once you have this, to run it type:
python kannel.py
This will ask you for a number to send an SMS to. Enter the number and press <ENTER>. It will send out the SMS and then go into SMS receive mode. If you send an SMS back to your phone (the one that is plugged in to the computer), it will reply with its own message telling you what the message it received was.
By inspecting the code, you should be able to see how it works and write your application to solve your problem or fit your use case.

