#!/usr/bin/env python import gammu import sys # Create state machine object sm = gammu.StateMachine() # Read /etc/gammurc sm.ReadConfig() # Connect to phone sm.Init() # Reads network information from phone netinfo = sm.GetNetworkInfo() # Print information print 'State: %s' % netinfo['State'] if netinfo['State'] != "HomeNetwork": sys.exit(2)