Skip to content

Commit

Permalink
utils.execute: fixes for stdin_data feature
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed May 23, 2024
1 parent 8cc27b3 commit 6966e7e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mlonmcu/setup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ def execute(
for line in process.stdout:
if encoding:
line = line.decode(encoding, errors="replace")
new_line = prefix + line
new_line = prefix + line
else:
new_line = line
out_str = out_str + new_line
print_func(new_line.replace("\n", ""))
exit_code = None
Expand All @@ -273,14 +275,15 @@ def execute(
os.kill(pid, signal.SIGINT)
else:
try:
p = subprocess.Popen([i for i in args], **kwargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p = subprocess.Popen(
[i for i in args], **kwargs, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
if stdin_data:
out_str = p.communicate(input=stdin_data)[0]
else:
out_str = p.communicate()[0]
if encoding:
out_str = out_str.decode(encoding, errors="replace")
out_str = prefix + out_str
out_str = prefix + out_str
exit_code = p.poll()
# print_func(out_str)
if handle_exit is not None:
Expand Down

0 comments on commit 6966e7e

Please sign in to comment.