def check_connect():
global status_connect
try:
UTM_connect = HTTPConnection("test.ru")
UTM_connect.request("GET", "/")
UTM_connect.close()
except ConnectionRefusedError:
status_connect = 0
except TimeoutError:
status_connect = 0
except ConnectionError:
status_connect = 0
else:
status_connect = 1
class check_docs_cl(QtCore.QThread):
def __init__(self, parent = None):
QtCore.QThread.__init__(self, parent)
def run(self):
check_connect()
if status_connect == 1:
'''парсинг сайта'''
class docsTimer(QtCore.QObject):
def __init__(self):
QtCore.QObject.__init__(self)
self.basictimer = QtCore.QBasicTimer()
self.basictimer.start(10000, self)
def timerEvent(self, QTimerEvent):
check_docs.start()
class main_cl(QtGui.QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi("main.ui", self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
main_window = main_cl()
check_docs = check_docs_cl()
check_connect()
if status_connect == 1:
docs_timer = docsTimer()
sys.exit(app.exec_())