Skip to content

Commit

Permalink
handle escape in 'run_subprocess'
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Aug 28, 2024
1 parent 714f58f commit 911ef45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
14 changes: 14 additions & 0 deletions client/ayon_core/lib/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ def run_subprocess(*args, **kwargs):
| getattr(subprocess, "CREATE_NO_WINDOW", 0)
)

# Escape parentheses for bash
if (
kwargs.get("shell") is True
and len(args) == 1
and isinstance(args[0], str)
and os.getenv("SHELL") in ("/bin/bash", "/bin/sh")
):
new_arg = (
args[0]
.replace("(", "\\(")
.replace(")", "\\)")
)
args = (new_arg, )

# Get environents from kwarg or use current process environments if were
# not passed.
env = kwargs.get("env") or os.environ
Expand Down
7 changes: 0 additions & 7 deletions client/ayon_core/plugins/publish/extract_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,6 @@ def _render_output_definitions(
raise NotImplementedError

subprcs_cmd = " ".join(ffmpeg_args)
if os.getenv("SHELL") in ("/bin/bash", "/bin/sh"):
# Escape parentheses for bash
subprcs_cmd = (
subprcs_cmd
.replace("(", "\\(")
.replace(")", "\\)")
)

# run subprocess
self.log.debug("Executing: {}".format(subprcs_cmd))
Expand Down
7 changes: 0 additions & 7 deletions client/ayon_core/plugins/publish/extract_review_slate.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,6 @@ def process(self, instance):
" ".join(output_args)
]
slate_subprocess_cmd = " ".join(slate_args)
if os.getenv("SHELL") in ("/bin/bash", "/bin/sh"):
# Escape parentheses for bash
slate_subprocess_cmd = (
slate_subprocess_cmd
.replace("(", "\\(")
.replace(")", "\\)")
)

# run slate generation subprocess
self.log.debug(
Expand Down
7 changes: 0 additions & 7 deletions client/ayon_core/plugins/publish/extract_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,6 @@ def _create_thumbnail_ffmpeg(self, src_path, dst_path):
# output file
jpeg_items.append(path_to_subprocess_arg(dst_path))
subprocess_command = " ".join(jpeg_items)
if os.getenv("SHELL") in ("/bin/bash", "/bin/sh"):
# Escape parentheses for bash
subprocess_command = (
subprocess_command
.replace("(", "\\(")
.replace(")", "\\)")
)

try:
run_subprocess(
Expand Down

0 comments on commit 911ef45

Please sign in to comment.