Skip to content

Commit

Permalink
flush stdout before converting mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelbray32 committed Feb 16, 2024
1 parent 79a17e1 commit bfc870c
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/spyglass/position/v1/dlc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pathlib
import pwd
import subprocess
import sys
from collections import abc
from contextlib import redirect_stdout
from itertools import groupby
Expand Down Expand Up @@ -538,17 +539,23 @@ def _convert_mp4(
"copy",
f"{dest_path.as_posix()}",
]
try:
convert_process = subprocess.Popen(
convert_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError as err:
raise RuntimeError(
f"command {err.cmd} return with error (code {err.returncode}): {err.output}"
) from err
out, _ = convert_process.communicate()
print(out.decode("utf-8"))
print(f"finished converting {filename}")
if dest_path.exists():
print(f"{dest_path} already exists, skipping conversion")
else:
try:
sys.stdout.flush()
convert_process = subprocess.Popen(
convert_command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as err:
raise RuntimeError(
f"command {err.cmd} return with error (code {err.returncode}): {err.output}"
) from err
out, _ = convert_process.communicate()
print(out.decode("utf-8"))
print(f"finished converting {filename}")
print(
f"Checking that number of packets match between {orig_filename} and {dest_filename}"
)
Expand Down

0 comments on commit bfc870c

Please sign in to comment.