BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
boswatch.network.netCheck.NetCheck Class Reference

Worker class to check internet connection. More...

Public Member Functions

def __init__ (self, hostname="https://www.google.com/", timeout=1)
 Create a new NetCheck instance.
 
def checkConn (self)
 Check the connection.
 

Data Fields

 connectionState
 

Protected Attributes

 _hostname
 
 _timeout
 

Detailed Description

Worker class to check internet connection.

Constructor & Destructor Documentation

◆ __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() # initiate a first check
35

Member Function Documentation

◆ 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: # todo find right exception type
46 logging.warning("%s is not reachable", self._hostname)
47 self.connectionState = False
48 return False

Field Documentation

◆ _hostname

boswatch.network.netCheck.NetCheck._hostname
protected

◆ _timeout

boswatch.network.netCheck.NetCheck._timeout
protected

◆ connectionState

boswatch.network.netCheck.NetCheck.connectionState