-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (25 loc) · 832 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Main file to find and send user Craigslist housing posts.
"""
import time
import users
import posts
import mail
def main():
"""Main app to execute subscription based email notifications."""
users_json = users.get_users()
# At start of subscription, drop all content and populate db without sending email
posts.drop_contents()
for _ in posts.get(users_json):
pass
while True:
# Sleep for a day (-80 seconds) to fetch posts
print("sleeping...")
time.sleep(86320)
# Get users' json file for every iteration - allows for updates during operation
users_json = users.get_users()
user_posts = zip(users_json, posts.get(users_json))
for user, post in user_posts:
mail.write_email(user, post)
if __name__ == "__main__":
main()