Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
7693c896
Unverified
Commit
7693c896
authored
Jun 13, 2019
by
Francisco Massa
Committed by
GitHub
Jun 13, 2019
Browse files
Raise error during downloading (#1013)
* Raise error during downloading * Fix py2 error and lint
parent
f9348a04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
test/test_datasets_utils.py
test/test_datasets_utils.py
+7
-0
torchvision/datasets/utils.py
torchvision/datasets/utils.py
+3
-1
No files found.
test/test_datasets_utils.py
View file @
7693c896
...
@@ -62,6 +62,13 @@ class Tester(unittest.TestCase):
...
@@ -62,6 +62,13 @@ class Tester(unittest.TestCase):
warnings
.
warn
(
msg
,
RuntimeWarning
)
warnings
.
warn
(
msg
,
RuntimeWarning
)
raise
unittest
.
SkipTest
(
msg
)
raise
unittest
.
SkipTest
(
msg
)
@
unittest
.
skipIf
(
sys
.
version_info
<
(
3
,),
"Python2 doesn't raise error"
)
def
test_download_url_dont_exist
(
self
):
with
get_tmp_dir
()
as
temp_dir
:
url
=
"http://github.com/pytorch/vision/archive/this_doesnt_exist.zip"
with
self
.
assertRaises
(
URLError
):
utils
.
download_url
(
url
,
temp_dir
)
def
test_extract_zip
(
self
):
def
test_extract_zip
(
self
):
with
get_tmp_dir
()
as
temp_dir
:
with
get_tmp_dir
()
as
temp_dir
:
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.zip'
)
as
f
:
with
tempfile
.
NamedTemporaryFile
(
suffix
=
'.zip'
)
as
f
:
...
...
torchvision/datasets/utils.py
View file @
7693c896
...
@@ -82,7 +82,7 @@ def download_url(url, root, filename=None, md5=None):
...
@@ -82,7 +82,7 @@ def download_url(url, root, filename=None, md5=None):
url
,
fpath
,
url
,
fpath
,
reporthook
=
gen_bar_updater
()
reporthook
=
gen_bar_updater
()
)
)
except
OSError
:
except
urllib
.
error
.
URLError
as
e
:
if
url
[:
5
]
==
'https'
:
if
url
[:
5
]
==
'https'
:
url
=
url
.
replace
(
'https:'
,
'http:'
)
url
=
url
.
replace
(
'https:'
,
'http:'
)
print
(
'Failed download. Trying https -> http instead.'
print
(
'Failed download. Trying https -> http instead.'
...
@@ -91,6 +91,8 @@ def download_url(url, root, filename=None, md5=None):
...
@@ -91,6 +91,8 @@ def download_url(url, root, filename=None, md5=None):
url
,
fpath
,
url
,
fpath
,
reporthook
=
gen_bar_updater
()
reporthook
=
gen_bar_updater
()
)
)
else
:
raise
e
def
list_dir
(
root
,
prefix
=
False
):
def
list_dir
(
root
,
prefix
=
False
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment