Skip to content

Commit

Permalink
add function arg description. add if condation default browser downlo…
Browse files Browse the repository at this point in the history
…ad path has screenshot file then remove it
  • Loading branch information
CopyDemon committed Sep 10, 2024
1 parent d026bf1 commit 5550b3b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion idaes_ui/fv/fsvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ async def _async_save_diagram(
Args:
screenshot_name: string use as screenshot saved name, if undefined will use flowsheet as screenshot saved name
live_server_url: string use for playwright to open browser on
save_to: string where to save the screenshot file
image_type: string the screenshot image type
display: bool to display or not display it in jupyter
"""
# import playwright to generate screenshot
from playwright.async_api import async_playwright
Expand Down Expand Up @@ -444,14 +448,20 @@ async def _async_save_diagram(
# Move download to save_to and display image and display image saved path
if os.path.exists(download_path):
# Save image to save to and display
# read from download screenshot file

# read from download screenshot file
with open(download_path, "rb") as source_file:
file_content = source_file.read()
# write to save path
with open(diagram_saved_path, "wb") as target_file:
target_file.write(file_content)

# remove playwright downloaded screenshot file when diagram_saved_path != download_path
if diagram_saved_path != download_path and os.path.exists(
download_path
):
os.remove(download_path)

if os.path.exists(diagram_saved_path):
_log.info(f"File downloaded: {diagram_saved_path}")
else:
Expand Down

0 comments on commit 5550b3b

Please sign in to comment.