Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to skip tls cert verification #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion classify_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import glob
import urllib
import tempfile
import ssl

# pip install progressbar2, not progressbar
import progressbar
Expand Down Expand Up @@ -93,6 +94,8 @@
# on the CPU or GPU.
use_gpu = True

# Enable when downloads have invalid certificates and you want to risk trusting them
insecure_urllib = False

#%% Constants

Expand Down Expand Up @@ -176,7 +179,9 @@ def download_url(url, destination_filename=None, progress_updater=None, force_do
print('Bypassing download of already-downloaded file {}'.format(os.path.basename(url)))
return destination_filename
print('Downloading file {}'.format(os.path.basename(url)),end='')
urllib.request.urlretrieve(url, destination_filename, progress_updater)
if (insecure_urllib):
ssl._create_default_https_context = ssl._create_unverified_context
urllib.request.urlretrieve(url, destination_filename, progress_updater)
assert(os.path.isfile(destination_filename))
nBytes = os.path.getsize(destination_filename)
print('...done, {} bytes.'.format(nBytes))
Expand Down