From 51824608865b66ab04b018f55055124edbe603f3 Mon Sep 17 00:00:00 2001 From: Abubakar Abid Date: Tue, 13 Dec 2022 20:30:47 -0600 Subject: [PATCH] Patching `test_get_ip` attempt 2 (#2810) * ip-patch-2 * formatting * patch 2 --- CHANGELOG.md | 2 ++ gradio/utils.py | 5 ++++- test/test_utils.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da843145ce..d3fd63b51b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ No changes to highlight. ## Full Changelog: * Fixed typo in parameter `visible` in classes in `templates.py` by [@abidlabs](https://github.com/abidlabs) in [PR 2805](https://github.com/gradio-app/gradio/pull/2805) +* Switched external service for getting IP address from `https://api.ipify.org` to `https://checkip.amazonaws.com/` by [@abidlabs](https://github.com/abidlabs) in [PR 2810](https://github.com/gradio-app/gradio/pull/2810) + ## Contributors Shoutout: No changes to highlight. diff --git a/gradio/utils.py b/gradio/utils.py index 233eb53007..7ee00f686e 100644 --- a/gradio/utils.py +++ b/gradio/utils.py @@ -78,8 +78,11 @@ def version_check(): def get_local_ip_address() -> str: + """Gets the public IP address or returns the string "No internet connection" if unable to obtain it.""" try: - ip_address = requests.get("https://api.ipify.org", timeout=3).text + ip_address = requests.get( + "https://checkip.amazonaws.com/", timeout=3 + ).text.strip() except (requests.ConnectionError, requests.exceptions.ReadTimeout): ip_address = "No internet connection" return ip_address diff --git a/test/test_utils.py b/test/test_utils.py index e04c6c8f88..581cd2d0fb 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -103,6 +103,7 @@ class TestUtils: class TestIPAddress: + @pytest.mark.flaky def test_get_ip(self): ip = get_local_ip_address() if ip == "No internet connection":