MCPcopy Create free account
hub / github.com/geekcomputers/Python / checkInternetConnectivity

Function checkInternetConnectivity

check_internet_con.py:12–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10
11
12def checkInternetConnectivity():
13 try:
14 url = argv[1]
15 print(url)
16 protocols = ["https://", "http://"]
17 if not any(x for x in protocols if x in url):
18 url = "https://" + url
19 print("URL:" + url)
20 except BaseException:
21 url = "https://google.com"
22 try:
23 urlopen(url, timeout=2)
24 print(f'Connection to "{url}" is working')
25
26 except URLError as E:
27 print("Connection error:%s" % E.reason)
28
29
30checkInternetConnectivity()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected