PyGnokii

From MobileHacking.org

Jump to: navigation, search

PyGnokii is a python library that provides an interface to the mobile phone functionality provided by Gnokii. It can be used from within any python application to add telephony features. With Gnokii's ability to connect to most mobile phones and the versatility and ease of application development provided by python, it is very easy to get a fully functional mobile application off the ground quickly. At the moment PyGnokii is only fully functional for Linux because it relies on the inotify kernel subsystem for file system notification.

Contents

Dependencies

Currently PyGnokii depends on the following libraries:

  • pyinotify - a library for receiving notification of filesystem changes (a python interface to inotify). PyGnokii uses this to notify the application of incoming SMSs.

Installation

1) Download PyGnokii from GitHub using the following command (you will have to install Git to do this).

git clone git://github.com/adammck/pygnokii.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 PyGnokii 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 pygnokii to where you want to keep it:

mv pygnokii /path/to/where/you/want/it/

and then create a symlink from your site-packages to gnokii.py:

sudo ln -s /path/to/where/you/want/it/pygnokii/gnokii.py /path/to/your/site-packages/gnokii.py

3) Test your installation by opening a python prompt:

python

then at the python prompt import pygnokii:

from gnokii 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:

...
gnokii.py -> /path/to/where/you/want/it/pygnokii/gnokii.py
...

in the output.

4) Once you can run that with no error, you have installed gnokii successfully and can start to build applications with it.

Running

PyGnokii has a built in test to show you how it works. Make sure you have your phone plugged in and that you have Gnokii installed and working OK. Once you have this, to run it type:

python gnokii.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), pygnokii will print out the incoming message and then send a "thank you" reply SMS to the sender.

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.

Development

PyGnokii is still in the early stages of development, and so could use some additional feedback and help. You can contact adammck, mejymejy or ewheeler if you have ideas or want to collaborate/contribute to the project.

Personal tools