Debian Codegraph @

debian/patches/0038-Accelerate-HTTP-check-by-doing-a-HEAD-not-a-GET.patch

raw symbols SCIP
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 -def download_via_wget(target):
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 -def download_via_curl(target):
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 -def check_network_connection(host = "www.hp.com", port=80):
50 - import socket
51 - try:
52 - socket.setdefaulttimeout(10)
53 - socket.create_connection((host, port))
54 - return True
55 - except OSError:
56 - return False
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):