Created
September 11, 2011 16:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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