As part of the OEP platform at my previous College, we thought of an SMS subsystem to handle SMS Messages to Danish Mobile Phones. The idea was a system that could expedite messages about account changes (such as being locked out, or forgotten password), simple and easy. I decided from start, to code it in Python.
In the OEP project, we already had one system we’d like to rely on. The Central user database, LDAP. This means that any script I’d create, had to integrate with this. This means that my script would be able to accept both phone numbers, and user names as parameters – after which it’d find the matching phone number in the LDAP database.
In the LDAP base, phone numbers are recorded under the column “mobile”. So first I had to find this – in python using the LDAP connection module. This tool is freely available for Python, and can be downloaded through the Application package system in Ubuntu.
After I found the method, and created a scripted function to retrieve a phone number given a username. I would have to tend to the other aspects of the system. Mainly I’d like to maintain two aspects of this system. One with, and one without using a database as a queue (MySQL). The idea of the database, is to have a queue that can be used to ensure that messages are delivered in a timeframe. For example, there’s no need to disturb users at the middle of the night, to tell them something non-important. The database’ job is then to maintain a list of messages that are ready to be sent, and those that have been sent.
But to ease the overall system, I created the SMS Send script so that it could be used as a python module as well. Allowing it to be used from the timed script running regularily, checking the database and sending messages. This way, it’s possible to centralize everything, avoiding doing double-work.