Skip to content

Commit 190d084

Browse files
author
v.shepard
committed
PBCKP-588 fixes after review - replace subprocess.run on subprocess.Popen
1 parent 089ab9b commit 190d084

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

testgres/operations/local_ops.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,26 @@ def exec_command(self, cmd, wait_exit=False, verbose=False,
6060
result = buf.read().decode(encoding)
6161
return result
6262
else:
63-
if proc:
64-
return subprocess.Popen(cmd, shell=shell, stdin=input, stdout=stdout, stderr=stderr)
65-
process = subprocess.run(
63+
process = subprocess.Popen(
6664
cmd,
67-
input=input,
6865
shell=shell,
69-
text=text,
7066
stdout=stdout,
7167
stderr=stderr,
72-
timeout=CMD_TIMEOUT_SEC,
7368
)
69+
if proc:
70+
return process
71+
result, error = process.communicate(input)
7472
exit_status = process.returncode
75-
result = process.stdout
76-
error = process.stderr
73+
7774
found_error = "error" in error.decode(encoding or 'utf-8').lower()
75+
7876
if encoding:
7977
result = result.decode(encoding)
8078
error = error.decode(encoding)
8179

8280
if expect_error:
8381
raise Exception(result, error)
82+
8483
if exit_status != 0 or found_error:
8584
if exit_status == 0:
8685
exit_status = 1

0 commit comments

Comments
 (0)