Check the internet link just with a small http request to an URL present in the configuration. If the link is down, retry 3 times. Returns: bool: True if everything works.
(self)
| 655 | return "" |
| 656 | |
| 657 | def check_internet(self) -> bool: |
| 658 | """Check the internet link just with a small http request |
| 659 | to an URL present in the configuration. If the link is down, |
| 660 | retry 3 times. |
| 661 | |
| 662 | Returns: |
| 663 | bool: True if everything works. |
| 664 | """ |
| 665 | attempts = 3 |
| 666 | |
| 667 | while True: |
| 668 | try: |
| 669 | url = get_config(("network", "internet_check")) |
| 670 | requests.get(url, timeout=3) |
| 671 | return True |
| 672 | except: |
| 673 | if attempts == 0: |
| 674 | return False |
| 675 | else: |
| 676 | time.sleep(5) |
| 677 | attempts -= 1 |
| 678 | |
| 679 | def get_public_ip(self) -> list: |
| 680 | """Get the public IP address |
no test coverage detected