Print ssl warning on use, not on module import.

pull/319/head
Jussi Pakkanen 9 years ago
parent 60896c0f04
commit f1a7a0cee3
  1. 10
      wraptool.py

@ -29,11 +29,12 @@ try:
has_ssl = True
API_ROOT = 'https://wrapdb.mesonbuild.com/v1/'
except ImportError:
print('Warning: ssl not available, traffic not authenticated.',
file=sys.stderr)
has_ssl = False
API_ROOT = 'http://wrapdb.mesonbuild.com/v1/'
ssl_warning_printed = False
from glob import glob
wrapdb_certificate = '''-----BEGIN CERTIFICATE-----
@ -103,9 +104,14 @@ def build_ssl_context():
return ctx
def open_wrapdburl(urlstring):
global ssl_warning_printed
if has_ssl:
return urllib.request.urlopen(urlstring, context=build_ssl_context())
else:
if not ssl_warning_printed:
print('Warning: ssl not available, traffic not authenticated.',
file=sys.stderr)
ssl_warning_printed = True
return urllib.request.urlopen(urlstring)
def get_result(urlstring):

Loading…
Cancel
Save