Commit 4a1fa1481beff9691f8280d23fee0032240524d6

  • avatar
  • arvind
  • Fri Jan 24 19:11:18 IST 2014
Adding capability to send sms
       -Using smscountry api to send out messages to users whose
       recordings have been posted.
  • Diff rendering mode:
  • inline
  • side by side

sms.py

1import logger1import logger
2import argparse2import argparse
3import datetime3import datetime
4import requests
5import smsConf as conf
46
5parser = argparse.ArgumentParser(description="""Send sms to users whose post are published.7parser = argparse.ArgumentParser(description="""Send sms to users whose post are published.
6 Start and end date default to present day.8 Start and end date default to present day.
1919
2020
21posts = logger.Logger('lb_postings')21posts = logger.Logger('lb_postings')
22users = posts.lt.query.with_entities(posts.lt.user).filter(posts.lt.status == 3, posts.lt.posted.between(t1, t2), posts.lt.sms_sent == False)
22users = posts.lt.query.with_entities(posts.lt.user, posts.lt.id).filter(posts.lt.status == 3, posts.lt.posted.between(t1, t2), posts.lt.sms_sent == False)
23users_list = []23users_list = []
24id_list = []
24if users.count() > 0:25if users.count() > 0:
25 for user in users:26 for user in users:
26 users_list.append(user.user)
27 print users_list
27 sendSMS('91'+user.user, 'Hi, your recording has been successfully posted at http://cgnetswara.org/index.php?id='+user.id))
28else:28else:
29 print "No posts posted."
29 return False
30
31
32def sendSMS(number, message):
33 data = {'user': conf.username, 'passwd': conf.passwd, 'message': message, 'mobilenumber':number, 'mtype':'N', 'DR':'Y'}
34 sms = requests.get(conf.url, params=data)
35 return sms