mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-07-14 00:00:34 +02:00
Revert "Implemented connectivity check (Fixed #1038)"
This reverts commit bc8e4c92b8
.
This commit is contained in:
parent
bc8e4c92b8
commit
0f727b8bed
@ -242,8 +242,7 @@ def main():
|
|||||||
|
|
||||||
update_sources = prompt_for_update(freshen=settings["freshen"], update_auto=auto)
|
update_sources = prompt_for_update(freshen=settings["freshen"], update_auto=auto)
|
||||||
if update_sources:
|
if update_sources:
|
||||||
if await_network_connection():
|
update_all_sources(source_data_filename, settings["hostfilename"])
|
||||||
update_all_sources(source_data_filename, settings["hostfilename"])
|
|
||||||
|
|
||||||
gather_exclusions = prompt_for_exclusions(skip_prompt=auto)
|
gather_exclusions = prompt_for_exclusions(skip_prompt=auto)
|
||||||
|
|
||||||
@ -326,34 +325,6 @@ def main():
|
|||||||
flush_cache=settings["flushdnscache"], prompt_flush=not auto
|
flush_cache=settings["flushdnscache"], prompt_flush=not auto
|
||||||
)
|
)
|
||||||
|
|
||||||
def await_network_connection(retries=3, delay=10):
|
|
||||||
"""
|
|
||||||
Check if we have a proper name resolution and connectivity
|
|
||||||
By pinging a common domain
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
retries : int
|
|
||||||
Number of times to retry again (on ping failure)
|
|
||||||
delay : int
|
|
||||||
How many seconds to wait before retrying again (on ping failure)
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
-> bool
|
|
||||||
True : A ping succeded
|
|
||||||
False : All retries have failed
|
|
||||||
"""
|
|
||||||
while retries:
|
|
||||||
if 0 == subprocess.call(['ping', 'one.one.one.one', '-c', '1'],
|
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL):
|
|
||||||
return True
|
|
||||||
|
|
||||||
print(f'No internet connection! Retrying in {delay} seconds')
|
|
||||||
time.sleep(delay)
|
|
||||||
retries -= 1
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# Prompt the User
|
# Prompt the User
|
||||||
def prompt_for_update(freshen, update_auto):
|
def prompt_for_update(freshen, update_auto):
|
||||||
|
Loading…
Reference in New Issue
Block a user