Skip to content

Commit

Permalink
Don't use colons in filenames as this doesn't work on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Nov 13, 2024
1 parent 5be96fc commit 9249ad6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions jupyter_output_monitor/_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ def _monitor_output(url, output, wait_after_execute, headless):

timestamp = isotime()

# Colons are invalid in filenames on Windows
filename_timestamp = timestamp.replace(":", "-")

screenshot_filename = os.path.join(
output,
f"input-{input_index:03d}-{timestamp}.png",
f"input-{input_index:03d}-{filename_timestamp}.png",
)
image = Image.open(BytesIO(screenshot_bytes))
image.save(screenshot_filename)
Expand Down Expand Up @@ -188,9 +191,13 @@ def _monitor_output(url, output, wait_after_execute, headless):
print(" -> change detected!")

timestamp = isotime()

# Colons are invalid in filenames on Windows
filename_timestamp = timestamp.replace(":", "-")

screenshot_filename = os.path.join(
output,
f"output-{output_index:03d}-{timestamp}.png",
f"output-{output_index:03d}-{filename_timestamp}.png",
)
image = Image.open(BytesIO(screenshot_bytes))
image.save(screenshot_filename)
Expand Down

0 comments on commit 9249ad6

Please sign in to comment.