Added server online check

This commit is contained in:
angelblue05 2015-04-26 15:41:39 -05:00
parent 6ec92da158
commit 9020c1c908
4 changed files with 193 additions and 129 deletions

View file

@ -18,6 +18,7 @@ from DownloadUtils import DownloadUtils
from PlaybackUtils import PlaybackUtils
from LibrarySync import LibrarySync
from WriteKodiDB import WriteKodiDB
from UserClient import UserClient
import Utils as utils
pendingUserDataList = []
@ -30,6 +31,8 @@ class WebSocketThread(threading.Thread):
logLevel = 0
client = None
keepRunning = True
uc = UserClient()
def __init__(self, *args):
@ -246,7 +249,7 @@ class WebSocketThread(threading.Thread):
LibrarySync().updatePlayCount(itemId)
def on_error(self, ws, error):
self.logMsg("Error : " + str(error))
self.logMsg("Error : " + str(error), 2)
#raise
def on_close(self, ws):
@ -298,7 +301,7 @@ class WebSocketThread(threading.Thread):
username = WINDOW.getProperty('currUser')
server = WINDOW.getProperty('server%s' % username)
host = WINDOW.getProperty('server_%s' % username)
if(self.logLevel >= 1):
websocket.enableTrace(True)
'''
@ -323,12 +326,19 @@ class WebSocketThread(threading.Thread):
self.client.on_open = self.on_open
while not self.KodiMonitor.abortRequested():
self.logMsg("Client Starting")
self.client.run_forever()
if(self.keepRunning):
self.logMsg("Client Needs To Restart")
if (self.keepRunning):
# Server is not online, suppress future warning
if WINDOW.getProperty("Server_online") == "true":
self.logMsg("Server is unreachable.", 1)
WINDOW.setProperty("Server_online", "false")
xbmcgui.Dialog().notification("Error connecting", "Server is unreachable.")
if self.KodiMonitor.waitForAbort(5):
break
self.logMsg("Thread Exited")