| 1 |
Fromscip-debian debian hplip 3.26.4+dfsg0-2 hplip/patches/`0038-Accelerate-HTTP-check-by-doing-a-HEAD-not-a-GET.patch`#From.: Didier Raboud <[email protected]scip-debian . . . identity/`[email protected]`.> |
| 2 |
Datescip-debian debian hplip 3.26.4+dfsg0-2 hplip/patches/`0038-Accelerate-HTTP-check-by-doing-a-HEAD-not-a-GET.patch`#Date.: Thu, 19 Sep 2019 08:47:34 +0200 |
| 3 |
Subjectscip-debian debian hplip 3.26.4+dfsg0-2 hplip/patches/`0038-Accelerate-HTTP-check-by-doing-a-HEAD-not-a-GET.patch`#Subject.: =?utf-8?q?Accelerate_HTTP=C2=A0check_by_doing_a_HEAD=2C_not_a_GET?= |
| 4 |
|
| 5 |
--- |
| 6 |
base/utils.py | 23 +++++++++++++---------- |
| 7 |
1 file changed, 13 insertions(+), 10 deletions(-) |
| 8 |
|
| 9 |
diff --git a/base/utils.pyscip-debian debian hplip 3.26.4+dfsg0-2 hplip/upstream/`base/utils.py`: b/base/utils.pyscip-debian debian hplip 3.26.4+dfsg0-2 hplip/upstream/`base/utils.py`: |
| 10 |
index e6b5532..e927ccf 100644 |
| 11 |
--- a/base/utils.py |
| 12 |
+++ b/base/utils.py |
| 13 |
@@ -2280,12 +2280,14 @@ def check_library( so_file_path): |
| 14 |
return ret_val |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
+def download_via_wget(target, head=False): |
| 19 |
status = -1 |
| 20 |
wget = which("wget") |
| 21 |
if target and wget: |
| 22 |
wget = os.path.join(wget, "wget") |
| 23 |
cmd = "%s --cache=off --tries=3 --timeout=60 --output-document=- %s" % (wget, target) |
| 24 |
+ if head: |
| 25 |
+ cmd += " --spider -S" |
| 26 |
log.debug(cmd) |
| 27 |
status, output = run(cmd) |
| 28 |
log.debug("wget returned: %d" % status) |
| 29 |
@@ -2293,12 +2295,14 @@ def download_via_wget(target): |
| 30 |
log.debug("wget not found") |
| 31 |
return status |
| 32 |
|
| 33 |
|
| 34 |
+def download_via_curl(target, head=False): |
| 35 |
status = -1 |
| 36 |
curl = which("curl") |
| 37 |
if target and curl: |
| 38 |
curl = os.path.join(curl, "curl") |
| 39 |
cmd = "%s --output - --connect-timeout 5 --max-time 10 %s" % (curl, target) |
| 40 |
+ if head: |
| 41 |
+ cmd += " --head" |
| 42 |
log.debug(cmd) |
| 43 |
status, output = run(cmd) |
| 44 |
log.debug("curl returned: %d" % status) |
| 45 |
@@ -2319,14 +2323,13 @@ def check_network_via_ping(target): |
| 46 |
log.debug("ping not found") |
| 47 |
return status |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
+def check_network_connection(url=HTTP_CHECK_TARGET, ping_server=PING_CHECK_TARGET): |
| 58 |
+ status = download_via_wget(url, head=True) |
| 59 |
+ if (status != 0): |
| 60 |
+ status = download_via_curl(url, head=True) |
| 61 |
+ if (status != 0): |
| 62 |
+ status = check_network_via_ping(ping_server) |
| 63 |
+ return (status == 0) |
| 64 |
|
| 65 |
#Expands '*' in File/Dir names. |
| 66 |
def expandList(Files_List, prefix_dir=None): |