Abdur-Rahmaan Janhangeer wrote:

Thanks everybody for the answers. It was very enlightening. Here's my
solution:

# using rich console
def ensure_internet():
console = Console()
domains = [
'https://google.com',
'https://yahoo.com',
'https://bing.com',
'https://www.ecosia.org',
'https://www.wikipedia.org'
]
results = []
with console.status("Checking internet ...", spinner="dots"):
for domain in domains:
try:
requests.get(domain)
results.append(1)
except Exception as e:
results.append(0)
if not any(results):
print('No internet connection')
sys.exit()

Was this supposed to be a self-contained working
program? It doesn't work here.

Were/what is 'Console()' for example?

--
--gv
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to