mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added function 'path_to_subprocess_arg' which decide if path should be wrapped in quotes
This commit is contained in:
parent
004b2c5a5e
commit
3d9970aa4f
2 changed files with 13 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ from .execute import (
|
|||
execute,
|
||||
run_subprocess,
|
||||
split_command_to_list,
|
||||
path_to_subprocess_arg,
|
||||
CREATE_NO_WINDOW
|
||||
)
|
||||
from .log import PypeLogger, timeit
|
||||
|
|
@ -173,6 +174,7 @@ __all__ = [
|
|||
"execute",
|
||||
"run_subprocess",
|
||||
"split_command_to_list",
|
||||
"path_to_subprocess_arg",
|
||||
"CREATE_NO_WINDOW",
|
||||
|
||||
"env_value_to_bool",
|
||||
|
|
|
|||
|
|
@ -139,6 +139,14 @@ def run_subprocess(*args, **kwargs):
|
|||
return full_output
|
||||
|
||||
|
||||
def path_to_subprocess_arg(path):
|
||||
"""Prepare path for subprocess arguments.
|
||||
|
||||
Returned path can be wrapped with quotes or kept as is.
|
||||
"""
|
||||
return subprocess.list2cmdline([path])
|
||||
|
||||
|
||||
def split_command_to_list(string_command):
|
||||
"""Split string subprocess command to list.
|
||||
|
||||
|
|
@ -159,6 +167,9 @@ def split_command_to_list(string_command):
|
|||
Returns:
|
||||
list: Command separated into individual arguments.
|
||||
"""
|
||||
if not string_command:
|
||||
return []
|
||||
|
||||
kwargs = {}
|
||||
# Use 'posix' argument only on windows
|
||||
if platform.system().lower() == "windows":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue