--- /dev/null +++ b/sms.py @@ -1 +1,28 @@ +import logger +import argparse +import datetime + +parser = argparse.ArgumentParser(description="""Send sms to users whose post are published. + Start and end date default to present day. + Start time defaults to 00:00:00. + End time defaults to 23:59:59.""") +parser.add_argument('-s','--start-date', type=str, default=datetime.datetime.strftime(datetime.date.today(), '%Y-%m-%d'), help="Start date (YYYY-MM-DD)") +parser.add_argument('-e','--end-date', type=str, default=datetime.datetime.strftime(datetime.date.today(), '%Y-%m-%d'), help="End date (YYYY-MM-DD)") +parser.add_argument('-S','--start-time', type=str, default = '00:00:00', help="Start time (HH:MM:SS)") +parser.add_argument('-E','--end-time', type=str, default='23:59:59', help="End time (HH:MM:SS)") + +args = parser.parse_args() +t1 = args.start_date + " " + args.start_time +t2 = args.end_date + " " + args.end_time + + +posts = logger.Logger('lb_postings') +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) +users_list = [] +if users.count() > 0: + for user in users: + users_list.append(user.user) + print users_list +else: + print "No posts posted."