Skip to content

Commit

Permalink
@ktf suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
singiamtel committed Sep 27, 2024
1 parent 9726442 commit 37966dc
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions alibuild_helpers/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

from alibuild_helpers.log import debug, warning, dieOnError

def is_string(s):
return isinstance(s, str)


def decode_with_fallback(data):
"""Try to decode DATA as utf-8; if that doesn't work, fall back to latin-1.
Expand All @@ -29,7 +25,7 @@ def decode_with_fallback(data):

def getoutput(command, timeout=None):
"""Run command, check it succeeded, and return its stdout as a string."""
proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=PIPE)
proc = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=PIPE)
try:
stdout, stderr = proc.communicate(timeout=timeout)
except TimeoutExpired:
Expand All @@ -43,7 +39,7 @@ def getoutput(command, timeout=None):

def getstatusoutput(command, timeout=None):
"""Run command and return its return code and output (stdout and stderr)."""
proc = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT)
proc = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=STDOUT)
try:
merged_output, _ = proc.communicate(timeout=timeout)
except TimeoutExpired:
Expand All @@ -59,7 +55,7 @@ def getstatusoutput(command, timeout=None):


def execute(command, printer=debug, timeout=None):
popen = Popen(command, shell=is_string(command), stdout=PIPE, stderr=STDOUT)
popen = Popen(command, shell=isinstance(command, str), stdout=PIPE, stderr=STDOUT)
start_time = time.time()
for line in iter(popen.stdout.readline, b""):
printer("%s", decode_with_fallback(line).strip("\n"))
Expand Down

0 comments on commit 37966dc

Please sign in to comment.