From ac3ed3cce2dbc939ad3f19038764ea7e8baad78f Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 2 Oct 2021 14:50:11 +0300 Subject: [PATCH 1/3] Fix #307 error reporting on fetch failures --- lib/fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fetch.py b/lib/fetch.py index df85aea..bd5b63b 100644 --- a/lib/fetch.py +++ b/lib/fetch.py @@ -63,7 +63,7 @@ def fetch_all(skip_existing=True): raise output = process.communicate()[0] if process.returncode != 0: - sys.stdout.write("\nERROR:\n---\n" + output) + sys.stdout.write("\nERROR:\n---\n" + str(output)) fatal("---\nCould not fetch %s" % adptr) else: print("Done") From 140b64d5cb269dedd08984ef950e5d5e6ecfb215 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 13 Nov 2021 21:03:34 +0300 Subject: [PATCH 2/3] Better fix for #307 is to return text stream from Popen `universal_newlines` make this in compatible way with older Python. --- lib/fetch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/fetch.py b/lib/fetch.py index bd5b63b..7b1bc62 100644 --- a/lib/fetch.py +++ b/lib/fetch.py @@ -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") From b918a33200bcb2d53d8e52c499bf41bbdc89f849 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sat, 13 Nov 2021 21:04:46 +0300 Subject: [PATCH 3/3] fetch.py: report when files are already downloaded --- lib/fetch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/fetch.py b/lib/fetch.py index 7b1bc62..db0c458 100644 --- a/lib/fetch.py +++ b/lib/fetch.py @@ -91,6 +91,7 @@ def fetch_all(skip_existing=True): if os.path.exists(location): if skip_existing: existing_locations.append(location) + print("Already exists %s" % (location)) else: fatal("%s already exists" % location)