Skip to content

Instantly share code, notes, and snippets.

@gtracy
Created September 11, 2011 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtracy/1209748 to your computer and use it in GitHub Desktop.
Save gtracy/1209748 to your computer and use it in GitHub Desktop.
CronHandler for sending SMS to a list of users in the GAE datastore
class CronHandler(webapp.RequestHandler):
def get(self,time_slot=""):
logging.debug('running cron for timeslot %s' % time_slot)
if systemIsOn() is False:
logging.error('bailing... the system is turned off')
return
# grab the row of data out of the spreadsheet
results = getResults(time_slot)
messages = getMessages(results)
# cycle over all the users and send them a message
users = db.GqlQuery("select * from User").fetch(200)
if len(users) <= 0:
logging.error('No users in the system!')
for u in users:
# send the SMS out with a background task
logging.debug('sending notifications to %s' % u.phone_number)
task = Task(url='/sendsmstask',
params={'phone':u.phone_number,
'msg_one':messages[0],
'msg_two':messages[1],
'msg_three':messages[2],
})
task.add('smssender')
## end CronHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment