mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Merge branch 'main' into feature/read-site-notes-pdf
This commit is contained in:
commit
c11c85a974
1 changed files with 15 additions and 11 deletions
|
|
@ -7,23 +7,27 @@ from utils.logger import setup_logger
|
|||
logger = setup_logger()
|
||||
|
||||
|
||||
def get_token_from_local_storage(email: str, password: str) -> str:
|
||||
def get_token_from_local_storage(email: str, password: str, record_video: bool = False) -> str:
|
||||
logger.info("Starting Playwright flow")
|
||||
|
||||
# For local testing / debugging, we save videos of the flow
|
||||
video_dir = os.path.join(os.path.dirname(__file__), "videos")
|
||||
os.makedirs(video_dir, exist_ok=True)
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(
|
||||
headless=True,
|
||||
args=["--no-sandbox", "--disable-dev-shm-usage"],
|
||||
)
|
||||
|
||||
context = browser.new_context(
|
||||
record_video_dir=video_dir,
|
||||
record_video_size={"width": 1280, "height": 720},
|
||||
)
|
||||
video_dir = None
|
||||
if record_video:
|
||||
video_dir = os.path.join(os.path.dirname(__file__), "videos")
|
||||
os.makedirs(video_dir, exist_ok=True)
|
||||
|
||||
if record_video:
|
||||
context = browser.new_context(
|
||||
record_video_dir=video_dir,
|
||||
record_video_size={"width": 1280, "height": 720},
|
||||
)
|
||||
else:
|
||||
context = browser.new_context()
|
||||
page = context.new_page()
|
||||
|
||||
try:
|
||||
|
|
@ -71,8 +75,8 @@ def get_token_from_local_storage(email: str, password: str) -> str:
|
|||
raise Exception(f"Unexpected error: {str(e)}")
|
||||
|
||||
finally:
|
||||
logger.info("Closing browser context (saving video)...")
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
logger.info(f"Video(s) saved in: {video_dir}")
|
||||
if record_video and video_dir:
|
||||
logger.info(f"Video(s) saved in: {video_dir}")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue