Add debug messages for VLC/mpv/Client-Server comms

This commit is contained in:
Et0h 2014-10-10 19:39:43 +01:00
parent 7fb2709629
commit 1b3e370d6d
6 changed files with 13 additions and 5 deletions

View File

@ -61,6 +61,7 @@ class SyncplayClient(object):
constants.SHOW_DIFFERENT_ROOM_OSD = config['showDifferentRoomOSD']
constants.SHOW_SAME_ROOM_OSD = config['showSameRoomOSD']
constants.SHOW_DURATION_NOTIFICATION = config['showDurationNotification']
constants.DEBUG_MODE = config['debug']
self.lastLeftTime = 0
self.lastLeftUser = u""
self.protocolFactory = SyncClientFactory(self)
@ -637,6 +638,10 @@ class UiManager(object):
self.__ui = ui
self.lastError = ""
def showDebugMessage(self, message):
if constants.DEBUG_MODE and message.rstrip():
print "{}{}".format(time.strftime(constants.UI_TIME_FORMAT, time.localtime()),message.rstrip())
def showMessage(self, message, noPlayer=False, noTimestamp=False):
if not noPlayer: self.showOSDMessage(message)
self.__ui.showMessage(message, noTimestamp)

View File

@ -22,6 +22,7 @@ SHOW_SLOWDOWN_OSD = True # Show notifications of slowing down / reverting on ti
SHOW_SAME_ROOM_OSD = True # Show OSD notifications for events relating to room user is in
SHOW_DIFFERENT_ROOM_OSD = False # Show OSD notifications for events relating to room user is not in
SHOW_DURATION_NOTIFICATION = True
DEBUG_MODE = False
#Changing these might be ok
DEFAULT_REWIND_THRESHOLD = 4

View File

@ -148,6 +148,8 @@ class MplayerPlayer(BasePlayer):
self._paused = value
def lineReceived(self, line):
if line:
self._client.ui.showDebugMessage("player << {}".format(line))
match = self.RE_ANSWER.match(line)
if not match:
self._handleUnknownLine(line)
@ -290,6 +292,7 @@ class MplayerPlayer(BasePlayer):
def sendLine(self, line):
try:
line = (line.decode('utf8') + u"\n").encode('utf8')
self.__playerController._client.ui.showDebugMessage("player >> {}".format(line))
self.__process.stdin.write(line)
except IOError:
pass

View File

@ -130,6 +130,7 @@ class VlcPlayer(BasePlayer):
self._listener.sendLine("get-filename")
def lineReceived(self, line):
self._client.ui.showDebugMessage("player >> {}".format(line))
match, name, value = self.RE_ANSWER.match(line), "", ""
if match:
name, value = match.group('command'), match.group('argument')
@ -327,15 +328,14 @@ class VlcPlayer(BasePlayer):
self.__playerController.drop()
def found_terminator(self):
# print "received: {}".format("".join(self._ibuffer))
self.__playerController.lineReceived("".join(self._ibuffer))
self._ibuffer = []
def sendLine(self, line):
if self.connected:
# print "send: {}".format(line)
try:
self.push(line + "\n")
self._client.ui.showDebugMessage("player >> {}".format(line))
except:
pass
if line == "close-vlc":

View File

@ -30,6 +30,7 @@ class JSONCommandProtocol(LineReceiver):
if not line:
return
try:
self._client.ui.showDebugMessage("client/server << {}".format(line))
messages = json.loads(line)
except:
self.dropWithError(getMessage("not-json-server-error").format(line))
@ -39,6 +40,7 @@ class JSONCommandProtocol(LineReceiver):
def sendMessage(self, dict_):
line = json.dumps(dict_)
self.sendLine(line)
self._client.ui.showDebugMessage("client/server >> {}".format(line))
def drop(self):
self.transport.loseConnection()

View File

@ -117,9 +117,6 @@ class MainWindow(QtGui.QMainWindow):
def userListChange(self):
self._syncplayClient.showUserList()
def showDebugMessage(self, message):
print(message)
def showErrorMessage(self, message, criticalerror = False):
message = unicode(message)