Skip to content

Commit

Permalink
Update is_url() (ultralytics#9566)
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Jocher <[email protected]>

Signed-off-by: Glenn Jocher <[email protected]>
  • Loading branch information
glenn-jocher authored Sep 23, 2022
1 parent 30fa9b6 commit 1320ce1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
import torch


def is_url(url, check_online=True):
# Check if online file exists
def is_url(url, check_exists=True):
# Check if string is URL and check if URL exists
try:
url = str(url)
result = urllib.parse.urlparse(url)
assert all([result.scheme, result.netloc, result.path]) # check if is url
return (urllib.request.urlopen(url).getcode() == 200) if check_online else True # check if exists online
return (urllib.request.urlopen(url).getcode() == 200) if check_exists else True # check if exists online
except (AssertionError, urllib.request.HTTPError):
return False

Expand Down

0 comments on commit 1320ce1

Please sign in to comment.