Skip to content

Commit

Permalink
chore: refine cmd_exec.py
Browse files Browse the repository at this point in the history
  • Loading branch information
halajohn committed Dec 16, 2024
1 parent b0434df commit 32b7d57
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .gnfiles/build/scripts/cmd_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
# Refer to the "LICENSE" file in the root directory for more information.
#
import sys
import io
import os
import subprocess


# psutil is not a builtin module, so use it if it exists.
# `psutil` is not a builtin module, so use it if it exists.
try:
import psutil

has_psutil = True
except ImportError:
has_psutil = False

# Reconfigure stdout to use UTF-8 on Windows.
if sys.platform == "win32":
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")


def get_cmd_output(cmd: str, log_level: int = 0) -> tuple[int, str]:
"""Return (status, output) of executing cmd in a shell."""
Expand Down

0 comments on commit 32b7d57

Please sign in to comment.