From 3b0bbbe5d3cb9d841c27784f68b8b09595419e9a Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:47:21 +0200 Subject: [PATCH] escape parenthesis when running script using shell=True --- .../plugins/publish/extract_thumbnail.py | 8 ++++++++ openpype/plugins/publish/extract_review.py | 7 +++++++ openpype/plugins/publish/extract_review_slate.py | 8 ++++++++ openpype/plugins/publish/extract_thumbnail.py | 8 ++++++++ 4 files changed, 31 insertions(+) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/extract_thumbnail.py b/openpype/hosts/standalonepublisher/plugins/publish/extract_thumbnail.py index a2afd160fab..fe2084cf2a6 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/extract_thumbnail.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/extract_thumbnail.py @@ -93,6 +93,14 @@ def process(self, instance): subprocess_jpeg = " ".join(jpeg_items) + if os.getenv("SHELL") in ("/bin/bash", "/bin/sh"): + # Escape parentheses for bash + subprocess_jpeg = ( + subprocess_jpeg + .replace("(", "\\(") + .replace(")", "\\)") + ) + # run subprocess self.log.debug("Executing: {}".format(subprocess_jpeg)) run_subprocess( diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index 8448c45e70e..7eef0e66688 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -418,6 +418,13 @@ 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)) diff --git a/openpype/plugins/publish/extract_review_slate.py b/openpype/plugins/publish/extract_review_slate.py index 4e3406d3f9a..9c557d1c386 100644 --- a/openpype/plugins/publish/extract_review_slate.py +++ b/openpype/plugins/publish/extract_review_slate.py @@ -270,6 +270,14 @@ def process(self, instance): ] 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( "Slate Executing: {}".format(slate_subprocess_cmd) diff --git a/openpype/plugins/publish/extract_thumbnail.py b/openpype/plugins/publish/extract_thumbnail.py index 40e4b23ee0e..53fdd30dcfa 100644 --- a/openpype/plugins/publish/extract_thumbnail.py +++ b/openpype/plugins/publish/extract_thumbnail.py @@ -447,6 +447,14 @@ 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( subprocess_command, shell=True, logger=self.log