Commit 4f21a57f3e61172ab191398b90482e595d0608e0
Adding sms.py
- Queries lb_postings to find out posts which have
not been acknowledged with an sms.
- sms.py 27 +++++++++++++++++++++++++++
| | | | | | 1 | import logger |
---|
| | 2 | import argparse |
---|
| | 3 | import datetime |
---|
| | 4 | |
---|
| | 5 | parser = argparse.ArgumentParser(description="""Send sms to users whose post are published. |
---|
| | 6 | Start and end date default to present day. |
---|
| | 7 | Start time defaults to 00:00:00. |
---|
| | 8 | End time defaults to 23:59:59.""") |
---|
| | 9 | parser.add_argument('-s','--start-date', type=str, default=datetime.datetime.strftime(datetime.date.today(), '%Y-%m-%d'), help="Start date (YYYY-MM-DD)") |
---|
| | 10 | parser.add_argument('-e','--end-date', type=str, default=datetime.datetime.strftime(datetime.date.today(), '%Y-%m-%d'), help="End date (YYYY-MM-DD)") |
---|
| | 11 | parser.add_argument('-S','--start-time', type=str, default = '00:00:00', help="Start time (HH:MM:SS)") |
---|
| | 12 | parser.add_argument('-E','--end-time', type=str, default='23:59:59', help="End time (HH:MM:SS)") |
---|
| | 13 | |
---|
| | 14 | args = parser.parse_args() |
---|
| | 15 | t1 = args.start_date + " " + args.start_time |
---|
| | 16 | t2 = args.end_date + " " + args.end_time |
---|
| | 17 | |
---|
| | 18 | |
---|
| | 19 | posts = logger.Logger('lb_postings') |
---|
| | 20 | 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) |
---|
| | 21 | users_list = [] |
---|
| | 22 | if users.count() > 0: |
---|
| | 23 | for user in users: |
---|
| | 24 | users_list.append(user.user) |
---|
| | 25 | print users_list |
---|
| | 26 | else: |
---|
| | 27 | print "No posts posted." |
---|