Commit 4a1fa1481beff9691f8280d23fee0032240524d6
- Diff rendering mode:
- inline
- side by side
sms.py
(12 / 4)
  | |||
1 | 1 | import logger | |
2 | 2 | import argparse | |
3 | 3 | import datetime | |
4 | import requests | ||
5 | import smsConf as conf | ||
4 | 6 | ||
5 | 7 | parser = argparse.ArgumentParser(description="""Send sms to users whose post are published. | |
6 | 8 | Start and end date default to present day. | |
… | … | ||
19 | 19 | ||
20 | 20 | ||
21 | 21 | posts = logger.Logger('lb_postings') | |
22 | users = posts.lt.query.with_entities(posts.lt.user).filter(posts.lt.status == 3, posts.lt.posted.between(t1, t2), posts.lt.sms_sent == False) | ||
22 | users = 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) | ||
23 | 23 | users_list = [] | |
24 | id_list = [] | ||
24 | 25 | if users.count() > 0: | |
25 | 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)) | ||
28 | 28 | else: | |
29 | print "No posts posted." | ||
29 | return False | ||
30 | |||
31 | |||
32 | def 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 |