Skip to content

Commit

Permalink
print debug commands in shell-escaped form
Browse files Browse the repository at this point in the history
  • Loading branch information
slhck committed May 13, 2024
1 parent 94c2c6a commit d293324
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ffmpeg_normalize/_cmd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import re
import shlex
import subprocess
from platform import system
from shutil import which
Expand Down Expand Up @@ -75,7 +76,7 @@ def run_ffmpeg_command(self, cmd: list[str]) -> Iterator[float]:
float: Progress percentage
"""
# wrapper for 'ffmpeg-progress-yield'
_logger.debug(f"Running command: {cmd}")
_logger.debug(f"Running command: {shlex.join(cmd)}")
ff = FfmpegProgress(cmd, dry_run=self.dry)
yield from ff.run_command_with_progress()

Expand All @@ -96,7 +97,7 @@ def run_command(self, cmd: list[str]) -> CommandRunner:
Raises:
RuntimeError: If command returns non-zero exit code
"""
_logger.debug(f"Running command: {cmd}")
_logger.debug(f"Running command: {shlex.join(cmd)}")

if self.dry:
_logger.debug("Dry mode specified, not actually running command")
Expand All @@ -116,7 +117,7 @@ def run_command(self, cmd: list[str]) -> CommandRunner:
stderr = stderr_bytes.decode("utf8", errors="replace")

if p.returncode != 0:
raise RuntimeError(f"Error running command {cmd}: {stderr}")
raise RuntimeError(f"Error running command {shlex.join(cmd)}: {stderr}")

self.output = stdout + stderr
return self
Expand Down

0 comments on commit d293324

Please sign in to comment.