mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
look for creationflags in kwargs instead of explicit argument
This commit is contained in:
parent
e69ba621d1
commit
0f9e12955c
1 changed files with 5 additions and 11 deletions
|
|
@ -74,20 +74,18 @@ def execute(args,
|
|||
return popen.returncode
|
||||
|
||||
|
||||
def run_subprocess(*args, creationflags=None, **kwargs):
|
||||
def run_subprocess(*args, **kwargs):
|
||||
"""Convenience method for getting output errors for subprocess.
|
||||
|
||||
Output logged when process finish.
|
||||
|
||||
Entered arguments and keyword arguments are passed to subprocess Popen.
|
||||
|
||||
Set 'creationflags' to '0' (int) if auto-fix for creation of new window
|
||||
should be ignored.
|
||||
On windows are 'creationflags' filled with flags that should cause ignore
|
||||
creation of new window.
|
||||
|
||||
Args:
|
||||
*args: Variable length argument list passed to Popen.
|
||||
creationflags (int): Creation flags for 'subprocess.Popen'.
|
||||
Differentiate on OS.
|
||||
**kwargs : Arbitrary keyword arguments passed to Popen. Is possible to
|
||||
pass `logging.Logger` object under "logger" to use custom logger
|
||||
for output.
|
||||
|
|
@ -103,17 +101,13 @@ def run_subprocess(*args, creationflags=None, **kwargs):
|
|||
# Modify creation flags on windows to hide console window if in UI mode
|
||||
if (
|
||||
platform.system().lower() == "windows"
|
||||
and creationflags is None
|
||||
and "creationflags" not in kwargs
|
||||
):
|
||||
creationflags = (
|
||||
kwargs["creationflags"] = (
|
||||
subprocess.CREATE_NEW_PROCESS_GROUP
|
||||
| subprocess.DETACHED_PROCESS
|
||||
)
|
||||
|
||||
# Ignore if creation flags is set to '0' or 'None'
|
||||
if creationflags:
|
||||
kwargs["creationflags"] = creationflags
|
||||
|
||||
# Get environents from kwarg or use current process environments if were
|
||||
# not passed.
|
||||
env = kwargs.get("env") or os.environ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue