1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00

Better fix for #307 is to return text stream from Popen

`universal_newlines` make this in compatible way with older Python.
This commit is contained in:
Anatoli Babenia
2021-11-13 21:03:34 +03:00
parent ac3ed3cce2
commit 140b64d5cb
+4 -2
View File
@@ -57,13 +57,15 @@ def fetch_all(skip_existing=True):
sys.stdout.write("Fetching %s..." % (adptr))
sys.stdout.flush()
try:
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
process = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True)
except OSError:
print("\nERROR: %s" % cmd)
raise
output = process.communicate()[0]
if process.returncode != 0:
sys.stdout.write("\nERROR:\n---\n" + str(output))
sys.stdout.write("\nERROR:\n---\n" + output)
fatal("---\nCould not fetch %s" % adptr)
else:
print("Done")