def connectionLost(self, reason): if self.runCase: self.runCase.onConnectionLost(self.failedByMe) self.caseEnd = time.time() caseResult = {"case": self.case, "id": caseClasstoId(self.Case), "description": self.Case.DESCRIPTION, "expectation": self.Case.EXPECTATION, "agent": self.caseAgent, "started": self.caseStarted, "duration": int(round(1000. * (self.caseEnd - self.caseStart))), # case execution time in ms "reportTime": self.runCase.reportTime, # True/False switch to control report output of duration "behavior": self.runCase.behavior, "behaviorClose": self.runCase.behaviorClose, "expected": self.runCase.expected, "expectedClose": self.runCase.expectedClose, "received": self.runCase.received, "result": self.runCase.result, "resultClose": self.runCase.resultClose, "wirelog": self.wirelog, "createWirelog": self.createWirelog, "closedByMe": self.closedByMe, "failedByMe": self.failedByMe, "droppedByMe": self.droppedByMe, "wasClean": self.wasClean, "wasNotCleanReason": self.wasNotCleanReason, "wasServerConnectionDropTimeout": self.wasServerConnectionDropTimeout, "wasOpenHandshakeTimeout": self.wasOpenHandshakeTimeout, "wasCloseHandshakeTimeout": self.wasCloseHandshakeTimeout, "localCloseCode": self.localCloseCode, "localCloseReason": self.localCloseReason, "remoteCloseCode": self.remoteCloseCode, "remoteCloseReason": self.remoteCloseReason, "isServer": self.isServer, "createStats": self.createStats, "rxOctetStats": self.rxOctetStats, "rxFrameStats": self.rxFrameStats, "txOctetStats": self.txOctetStats, "txFrameStats": self.txFrameStats, "httpRequest": self.http_request_data, "httpResponse": self.http_response_data} self.factory.logCase(caseResult) # parent's connectionLost does useful things WebSocketProtocol.connectionLost(self,reason)
def connectionLost(self, reason): if self.runCase: self.runCase.onConnectionLost(self.failedByMe) self.caseEnd = time.time() caseResult = {"case": self.case, "id": self.factory.CaseSet.caseClasstoId(self.Case), "description": self.Case.DESCRIPTION, "expectation": self.Case.EXPECTATION, "agent": self.caseAgent, "started": self.caseStarted, "duration": int(round(1000. * (self.caseEnd - self.caseStart))), # case execution time in ms "reportTime": self.runCase.reportTime, # True/False switch to control report output of duration "reportCompressionRatio": self.runCase.reportCompressionRatio, "behavior": self.runCase.behavior, "behaviorClose": self.runCase.behaviorClose, "expected": self.runCase.expected, "expectedClose": self.runCase.expectedClose, "received": self.runCase.received, "result": self.runCase.result, "resultClose": self.runCase.resultClose, "wirelog": self.wirelog, "createWirelog": self.createWirelog, "closedByMe": self.closedByMe, "failedByMe": self.failedByMe, "droppedByMe": self.droppedByMe, "wasClean": self.wasClean, "wasNotCleanReason": self.wasNotCleanReason, "wasServerConnectionDropTimeout": self.wasServerConnectionDropTimeout, "wasOpenHandshakeTimeout": self.wasOpenHandshakeTimeout, "wasCloseHandshakeTimeout": self.wasCloseHandshakeTimeout, "localCloseCode": self.localCloseCode, "localCloseReason": self.localCloseReason, "remoteCloseCode": self.remoteCloseCode, "remoteCloseReason": self.remoteCloseReason, "isServer": self.factory.isServer, "createStats": self.createStats, "rxOctetStats": self.rxOctetStats, "rxFrameStats": self.rxFrameStats, "txOctetStats": self.txOctetStats, "txFrameStats": self.txFrameStats, "httpRequest": self.http_request_data, "httpResponse": self.http_response_data, "trafficStats": self.runCase.trafficStats.__json__() if self.runCase.trafficStats else None} def cleanBin(e_old): e_new = [] for t in e_old: if t[0] == 'message': e_new.append((t[0], asciiLogData(t[1]), t[2])) elif t[0] in ['ping', 'pong']: e_new.append((t[0], asciiLogData(t[1]))) elif t[0] == 'timeout': e_new.append(t) else: print t raise Exception("unknown part type %s" % t[0]) return e_new for k in caseResult['expected']: e_old = caseResult['expected'][k] caseResult['expected'][k] = cleanBin(e_old) caseResult['received'] = cleanBin(caseResult['received']) ## now log the case results ## self.factory.logCase(caseResult) # parent's connectionLost does useful things WebSocketProtocol.connectionLost(self,reason)
def sendFSEvent(self, json): WebSocketProtocol.sendMessage(self, json) print 'to', self.peerstr