Worker class to check internet connection.
More...
|
def | __init__ (self, hostname="https://www.google.com/", timeout=1) |
| Create a new NetCheck instance.
|
|
def | checkConn (self) |
| Check the connection.
|
|
Worker class to check internet connection.
◆ __init__()
def boswatch.network.netCheck.NetCheck.__init__ |
( |
|
self, |
|
|
|
hostname = "https://www.google.com/" , |
|
|
|
timeout = 1 |
|
) |
| |
Create a new NetCheck instance.
@param hostname: host against connection check is running ("https://www.google.com/")
@param timeout: timeout for connection check in sec. (1)
26 def __init__(self, hostname="https://www.google.com/", timeout=1):
27 r"""!Create a new NetCheck instance
28
29 @param hostname: host against connection check is running ("https://www.google.com/")
30 @param timeout: timeout for connection check in sec. (1)"""
31 self._hostname = hostname
32 self._timeout = timeout
33 self.connectionState = False
34 self.checkConn()
35
◆ checkConn()
def boswatch.network.netCheck.NetCheck.checkConn |
( |
|
self | ) |
|
Check the connection.
@return True or False
36 def checkConn(self):
37 r"""!Check the connection
38
39 @return True or False"""
40 try:
41 urlopen(self._hostname, timeout=self._timeout)
42 logging.debug("%s is reachable", self._hostname)
43 self.connectionState = True
44 return True
45 except:
46 logging.warning("%s is not reachable", self._hostname)
47 self.connectionState = False
48 return False
◆ _hostname
boswatch.network.netCheck.NetCheck._hostname |
|
protected |
◆ _timeout
boswatch.network.netCheck.NetCheck._timeout |
|
protected |
◆ connectionState
boswatch.network.netCheck.NetCheck.connectionState |