mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
correctly save to sharepoint
This commit is contained in:
parent
37a12ffb28
commit
32e37990d2
1 changed files with 23 additions and 5 deletions
|
|
@ -11,6 +11,8 @@ from playwright.sync_api import (
|
|||
)
|
||||
|
||||
from utils.logger import setup_logger
|
||||
from utils.sharepoint.domna_sharepoint_client import DomnaSharepointClient
|
||||
from utils.sharepoint.domna_sites import DomnaSites
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
|
|
@ -87,7 +89,7 @@ def extract_succinct_address(deal_name: str) -> str:
|
|||
|
||||
postcode = None
|
||||
if postcode_match:
|
||||
postcode = postcode_match.group(1).replace(" ", "").upper()
|
||||
postcode = postcode_match.group(1).upper()
|
||||
|
||||
first_part = left_part.split(",")[0].strip()
|
||||
|
||||
|
|
@ -197,6 +199,11 @@ def download_report() -> None:
|
|||
|
||||
matching_properties: List[str] = []
|
||||
|
||||
sharepoint_client = DomnaSharepointClient(
|
||||
sharepoint_location=DomnaSites.PRIVATE_PAY
|
||||
)
|
||||
sharepoint_base_path = "/Projects/Southern Housing/SH-SURV-26-001/Assessments"
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
|
||||
|
|
@ -221,10 +228,11 @@ def download_report() -> None:
|
|||
try:
|
||||
cells: Locator = row.locator("td")
|
||||
|
||||
address: str = cells.nth(5).inner_text().strip()
|
||||
postcode: str = cells.nth(7).inner_text().strip()
|
||||
first_name: str = cells.nth(1).inner_text().strip()
|
||||
last_name: str = cells.nth(2).inner_text().strip()
|
||||
address: str = cells.nth(5).inner_text().strip()
|
||||
postcode: str = cells.nth(7).inner_text().strip()
|
||||
# uprn: str = cells.nth(8).inner_text().strip()
|
||||
status: str = cells.nth(9).inner_text().strip()
|
||||
|
||||
if first_name == "Oliver" and last_name == "Stephens":
|
||||
|
|
@ -253,8 +261,18 @@ def download_report() -> None:
|
|||
|
||||
for report_type in report_types:
|
||||
selector: str = build_report_selector(report_type)
|
||||
download_report_by_selector(page, selector)
|
||||
# TODO: stick in sharepoint
|
||||
file_path: str = download_report_by_selector(page, selector)
|
||||
try:
|
||||
sharepoint_client.upload_file(
|
||||
file_path=file_path,
|
||||
sharepoint_path=f"{sharepoint_base_path}/{sharepoint_address}/1. Retrofit Assessment/A. Assessment",
|
||||
file_name=os.path.basename(file_path),
|
||||
)
|
||||
# TODO: stick in s3
|
||||
finally:
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
logger.info(f"Deleted local file: {file_path}")
|
||||
|
||||
page.go_back()
|
||||
page.wait_for_selector(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue