Added some extra formating

This commit is contained in:
Uriziel 2013-10-13 18:01:34 +02:00
parent 22b426a5ea
commit 68486f1e43

View File

@ -1,4 +1,4 @@
#coding:utf8
# coding:utf8
from twisted.protocols.basic import LineReceiver
import json
import syncplay
@ -6,6 +6,7 @@ from functools import wraps
import time
from syncplay.messages import getMessage
class JSONCommandProtocol(LineReceiver):
def handleMessages(self, messages):
for message in messages.iteritems():
@ -21,7 +22,7 @@ class JSONCommandProtocol(LineReceiver):
elif command == "Error":
self.handleError(message[1])
else:
self.dropWithError(getMessage("en", "unknown-command-server-error").format(message[1])) #TODO: log, not drop
self.dropWithError(getMessage("en", "unknown-command-server-error").format(message[1])) # TODO: log, not drop
def lineReceived(self, line):
line = line.strip()
@ -48,6 +49,7 @@ class JSONCommandProtocol(LineReceiver):
def dropWithError(self, error):
raise NotImplementedError()
class SyncClientProtocol(JSONCommandProtocol):
def __init__(self, client):
self._client = client
@ -187,7 +189,7 @@ class SyncClientProtocol(JSONCommandProtocol):
def handleHttpRequest(self, request):
pass
def sendState(self, position, paused, doSeek, latencyCalculation, stateChange = False):
def sendState(self, position, paused, doSeek, latencyCalculation, stateChange=False):
state = {}
positionAndPausedIsSet = position is not None and paused is not None
clientIgnoreIsNotSet = self.clientIgnoringOnTheFly == 0 or self.serverIgnoringOnTheFly != 0
@ -210,7 +212,7 @@ class SyncClientProtocol(JSONCommandProtocol):
self.sendMessage({"State": state})
def handleError(self, error):
self.dropWithError(error["message"]) #TODO: more processing and fallbacking
self.dropWithError(error["message"]) # TODO: more processing and fallbacking
def sendError(self, message):
self.sendMessage({"Error": {"message": message}})
@ -229,7 +231,7 @@ class SyncServerProtocol(JSONCommandProtocol):
str(id(self)),
)))
def requireLogged(f): #@NoSelf
def requireLogged(f): # @NoSelf
@wraps(f)
def wrapper(self, *args, **kwds):
if(not self._logged):
@ -339,7 +341,7 @@ class SyncServerProtocol(JSONCommandProtocol):
def handleList(self, _):
self.sendList()
def sendState(self, position, paused, doSeek, setBy, senderLatency, watcherLatency, forced = False):
def sendState(self, position, paused, doSeek, setBy, senderLatency, watcherLatency, forced=False):
playstate = {
"position": position,
"paused": paused,
@ -395,7 +397,7 @@ class SyncServerProtocol(JSONCommandProtocol):
self.sendLine(self._factory.gethttpRequestReply())
def handleError(self, error):
self.dropWithError(error["message"]) #TODO: more processing and fallbacking
self.dropWithError(error["message"]) # TODO: more processing and fallbacking
def sendError(self, message):
self.sendMessage({"Error": {"message": message}})