[gimp-web] gimp-check-mirrors.py: exception handling for unreachable hosts
- From: Michael Schumacher <schumaml src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-web] gimp-check-mirrors.py: exception handling for unreachable hosts
- Date: Wed, 7 Oct 2020 18:31:40 +0000 (UTC)
commit 9c5892a5eedb8084f5f9c8cb01ae1c903b53d845
Author: Michael Schumacher <schumaml gmx de>
Date: Wed Oct 7 20:30:46 2020 +0200
gimp-check-mirrors.py: exception handling for unreachable hosts
tools/downloads/gimp-check-mirrors.py | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/tools/downloads/gimp-check-mirrors.py b/tools/downloads/gimp-check-mirrors.py
index 17491a5f..6522ab9a 100644
--- a/tools/downloads/gimp-check-mirrors.py
+++ b/tools/downloads/gimp-check-mirrors.py
@@ -1,14 +1,15 @@
#!/usr/bin/env python
+import os
import argparse
import fileinput
import urllib.request
-from urllib.error import HTTPError
+from urllib.error import HTTPError, URLError
import concurrent.futures
# argparse for mirrorsfile and uri
parser = argparse.ArgumentParser(description='Check if GIMP download mirrors have a file from
download.gimp.org.')
-parser.add_argument('--mirrorsfile', metavar='<file>',
+parser.add_argument('--mirrorsfile', metavar='<file>', default=os.path.abspath(__file__) +
'downloads.http.txt',
help='A file with one download mirror per line, either https:// or http://. Is expected
to point to the equivalent of https://download.gimp.org/pub/gimp/, as some mirrors only have that directory
structure.')
parser.add_argument('--uri', metavar='<uri>',
help='URI pointing to the file on download.gimp.org, e.g.
https://download.gimp.org/pub/gimp/v2.10/gimp-2.10.20.tar.bz2')
@@ -19,8 +20,7 @@ args = parser.parse_args()
# get local path
dgo_uri = args.uri
dgo_uri_local = dgo_uri.replace('https://download.gimp.org/pub/gimp/', '')
-dgo_uri_local = dgo_uri.replace('https://download.gimp.org/mirror/pub/gimp/', '')
-
+dgo_uri_local = dgo_uri_local.replace('https://download.gimp.org/mirror/pub/gimp/', '')
def load_url(url, timeout):
with urllib.request.urlopen(url, timeout=timeout) as conn:
@@ -39,7 +39,9 @@ with fileinput.input(files=(args.mirrorsfile), mode='r') as f:
# for future in concurrent.futures.as_completed(future_to_url):
try:
#data= future.result()
- response = urllib.request.urlopen(url=request, timeout=30)
+ response = urllib.request.urlopen(url=request, timeout=10)
print(str(response.status) + ' : ' + mirror_uri)
except HTTPError as error:
print(str(error.code) + ' : ' + mirror_uri)
+ except URLError as error:
+ print(str(error.reason) + ' : ' + mirror_uri)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]