Send SMS from Python on the Nokia N900

The script

The following Python script can be used to send a SMS on the Nokia N900.

#!/usr/bin/python

import pexpect # Python module for controlling other programms.
import time
import sys
from subprocess import * # Pyton module for spwaning new processes.

tmp  = raw_input("Enter mobile number:\n");
tmp = tmp.rstrip('\n')

if (tmp[0] == tmp[1] == "0"):
    number = tmp
elif (tmp[0] == "0" ) and (tmp[1] != "0"):
    number = "+49"+tmp[1:]
else:
    print "[-] This does not seem to be a mobile phone number. "
    sys.exit()

string = 'at+cmgs='+"\""+number+"\""+'\r'
string = string.rstrip('\n')

#print string
Message = raw_input("Enter text:\n")

child = pexpect.spawn('pnatd');
child.send('at\r');
time.sleep(0.25);
child.send('at+cmgf=1\r');
time.sleep(0.25);
child.send(string);
child.send(Message);
child.send(chr(26));
child.send(chr(26));
child.sendeof();

Issues

'module' object has no attribute 'GPSDControl'

The Python script name shall not be 'location.py' otherwise the interpreter will fail with the following error message:

Traceback (most recent call last):
File "location.py", line 1, in <module>
import location
File "/home/user/location.py", line 25, in <module>
control = location.GPSDControl.get_default()
AttributeError: 'module' object has no attribute 'GPSDControl'