Skip to content

Commit 8fb5027

Browse files
authored
Update Shell.py
1 parent cad6db3 commit 8fb5027

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

src/cloudmesh/common/Shell.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,18 +1063,16 @@ def live(cls, command, cwd=None):
10631063
process = subprocess.Popen(
10641064
shlex.split(command), cwd=cwd, stdout=subprocess.PIPE
10651065
)
1066-
result = b""
1067-
while True:
1068-
output = process.stdout.read(1)
1069-
if output == b"" and process.poll() is not None:
1070-
break
1071-
if output:
1072-
result = result + output
1073-
sys.stdout.write(output.decode("utf-8"))
1074-
sys.stdout.flush()
1075-
rc = process.poll()
1076-
data = dotdict({"status": rc, "text": output.decode("utf-8")})
1077-
return data
1066+
1067+
output_lines = []
1068+
for line in iter(process.stdout.readline, b''):
1069+
sys.stdout.write(line.decode("utf-8"))
1070+
sys.stdout.flush()
1071+
output_lines.append(line)
1072+
1073+
rc = process.wait()
1074+
full_output = b"".join(output_lines).decode("utf-8")
1075+
return dotdict({"status": rc, "text": full_output})
10781076

10791077
@staticmethod
10801078
def calculate_disk_space(directory):

0 commit comments

Comments
 (0)