Skip to content

Commit

Permalink
Patching test_get_ip attempt 2 (#2810)
Browse files Browse the repository at this point in the history
* ip-patch-2

* formatting

* patch 2
  • Loading branch information
abidlabs authored Dec 14, 2022
1 parent b492212 commit 5182460
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion gradio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def test_readme_to_html_correct_parse(self):


class TestIPAddress:
@pytest.mark.flaky
def test_get_ip(self):
ip = get_local_ip_address()
if ip == "No internet connection":
Expand Down

0 comments on commit 5182460

Please sign in to comment.