Skip to content

Commit f286bd3

Browse files
fix : debug param added to internet function
1 parent 1309d25 commit f286bd3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

orangetool/orangetool_ip.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import platform
1111

1212

13-
def internet(host="8.8.8.8", port=53, timeout=3):
13+
def internet(host="8.8.8.8", port=53, timeout=3, debug=False):
1414
"""
1515
Check internet connections.
1616
@@ -20,6 +20,8 @@ def internet(host="8.8.8.8", port=53, timeout=3):
2020
:type port:int
2121
:param timeout: times that check the connection
2222
:type timeout:int
23+
:param debug:flag for using debug Mode
24+
:type debug:bool
2325
:return bool: True if Connection is Stable
2426
>>> internet() # if there is stable internet connection
2527
True
@@ -30,8 +32,9 @@ def internet(host="8.8.8.8", port=53, timeout=3):
3032
socket.setdefaulttimeout(timeout)
3133
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
3234
return True
33-
except Exception as ex:
34-
print(str(ex))
35+
except Exception as e:
36+
if debug:
37+
print(str(e))
3538
return False
3639

3740

0 commit comments

Comments
 (0)