#7 Fixing false negative results
This commit is contained in:
parent
e0036fa352
commit
1ec878378b
|
@ -7,8 +7,12 @@ def ping(host: str) -> int:
|
||||||
:param host:
|
:param host:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
res = ping3.ping(dest_addr=host, unit='ms')
|
NUMBER_OF_ATTEMPTS = 5
|
||||||
if res:
|
|
||||||
return int(res)
|
for iteration in range(NUMBER_OF_ATTEMPTS):
|
||||||
else:
|
res = ping3.ping(dest_addr=host, unit='ms')
|
||||||
return -1
|
|
||||||
|
if res:
|
||||||
|
return int(res)
|
||||||
|
|
||||||
|
return -1
|
||||||
|
|
|
@ -6,12 +6,17 @@ def ping(url: str) -> int:
|
||||||
:param url: The URL of the website to ping
|
:param url: The URL of the website to ping
|
||||||
:return: The HTTP status code
|
:return: The HTTP status code
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
res = requests.get(url)
|
|
||||||
except:
|
|
||||||
return -1
|
|
||||||
|
|
||||||
if res:
|
NUMBER_OF_ATTEMPTS = 5
|
||||||
return res.status_code
|
|
||||||
else:
|
for iteration in range(NUMBER_OF_ATTEMPTS):
|
||||||
return -1
|
res = None
|
||||||
|
try:
|
||||||
|
res = requests.get(url)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if res:
|
||||||
|
return res.status_code
|
||||||
|
|
||||||
|
return -1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user