Skip to content

Commit 8f632ae

Browse files
Merge pull request #51 from Moduland/internet_debug
Internet function debug param
2 parents 1309d25 + 36d4f91 commit 8f632ae

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
- `network_control`, `network_enable` and `network_disable` functions
1010
### Changed
1111
- `sync` parameter added to `wakeup` function
12+
- `debug` parameter added to `internet` function
1213
## [0.45] - 2020-12-26
1314
### Added
1415
- `__main__.py`

orangetool/orangetool_ip.py

+6-3
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)