mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-06 23:04:11 +00:00
add timer and netCheck
This commit is contained in:
parent
a5ef0ac229
commit
c7e301317f
2 changed files with 109 additions and 0 deletions
35
boswatch/network/netCheck.py
Normal file
35
boswatch/network/netCheck.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
|
||||
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
|
||||
German BOS Information Script
|
||||
by Bastian Schroll
|
||||
|
||||
@file: netCheck.py
|
||||
@date: 21.09.2018
|
||||
@author: Bastian Schroll
|
||||
@description: Worker to check internet connection
|
||||
"""
|
||||
import logging
|
||||
from urllib.request import urlopen
|
||||
|
||||
logging.debug("- %s loaded", __name__)
|
||||
|
||||
|
||||
class NetCheck:
|
||||
"""!Worker class to check internet connection"""
|
||||
|
||||
def __init__(self, hostname="https://www.google.com/", timeout=1):
|
||||
self._hostname = hostname
|
||||
self._timeout = timeout
|
||||
|
||||
def checkConn(self):
|
||||
try:
|
||||
urlopen(self._hostname, timeout=self._timeout)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
Loading…
Add table
Add a link
Reference in a new issue