File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -287,20 +287,24 @@ def load_json(location):
287287
288288
289289# FIXME: rename to is_online: BUT do we really need this at all????
290+ # This is needed to check for the network connection when user wants to fetch
291+ # the licenses from DJE/LicenseDB
290292def have_network_connection ():
291293 """
292294 Return True if an HTTP connection to some public web site is possible.
293295 """
294- import socket
295- import http .client as httplib
296+ import requests
297+
298+ url = "https://scancode-licensedb.aboutcode.org/"
296299
297- http_connection = httplib .HTTPConnection ('dejacode.org' , timeout = 10 ) # NOQA
298300 try :
299- http_connection .connect ()
300- except socket .error :
301+ response = requests .get (url )
302+ if response .status_code == 200 :
303+ return True
304+ else :
305+ return False
306+ except requests .exceptions .RequestException :
301307 return False
302- else :
303- return True
304308
305309
306310def extract_zip (location ):
You can’t perform that action at this time.
0 commit comments