It's a demo to get the idea behind, uses requests and the rich library. Kind Regards,
Abdur-Rahmaan Janhangeer about <https://compileralchemy.github.io/> | blog <https://www.pythonkitchen.com> github <https://github.com/Abdur-RahmaanJ> Mauritius On Wed, Feb 9, 2022 at 12:24 PM Gisle Vanem <gisle.va...@gmail.com> wrote: > 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 > -- https://mail.python.org/mailman/listinfo/python-list