Add TODO about refactoring subprocess usage

This commit is contained in:
Mikhail Gordeev 2020-05-06 15:25:35 +03:00
parent 2135f80dac
commit e789e5dc82

View File

@ -247,15 +247,18 @@ class CB:
print(string)
else:
if stdout_to_file:
# TODO rewrite using subprocess.run
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
rc = p.wait()
maybe_fail(string, rc)
# TODO rewrite by passing f as stdout value
with open(stdout_to_file, 'w') as f:
if p.stdout:
f.write(p.stdout.read().decode())
if p.stdout is not None:
p.stdout.close()
else:
# TODO rewrite using subprocess.run
rc = subprocess.call(cmd)
maybe_fail(string, rc)