-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_script.py
51 lines (40 loc) · 1.46 KB
/
update_script.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import asyncio
import logging
from app import count_new_properties
from config.logging import logging_setup
from email_data.send_email import prepare_email_html, send_email
from rightmove.database import mark_properties_reviewed
from rightmove.enhancements import update_enhanced_data
from rightmove.geolocation import update_locations
from rightmove.run import download_properties, download_property_data
logger = logging.getLogger(__name__)
logger = logging_setup(logger)
def main():
# Download the latest properties and data:
logger.info("Downloading properties and data...")
asyncio.run(download_properties("BUY"))
asyncio.run(download_property_data(update=True))
# Update geolocation data:
logger.info("Updating geolocation data...")
update_locations()
# Getting Floorplan data:
logger.info("Getting Floorplan data...")
update_enhanced_data()
logger.info("Getting number of new properties...")
count = count_new_properties()
if count == 0:
logger.warning("No new properties found.")
return
# Mark properties as reviewed:
logger.info("Marking properties as reviewed...")
email_id = mark_properties_reviewed()
# Send email:
if email_id:
logger.info("Creating email...")
if prepare_email_html(email_id):
logger.info("Sending email...")
send_email()
else:
logger.info("No properties found in latest review.")
if __name__ == "__main__":
main()