fxies for Python 2.6

This commit is contained in:
Tobias Oberstein
2014-01-08 15:11:27 +01:00
parent 680b620dfd
commit 34e8926be4
8 changed files with 37 additions and 37 deletions

View File

@@ -3205,9 +3205,9 @@ class WebSocketServerProtocol(WebSocketProtocol):
"""
Send out HTTP error response.
"""
response = "HTTP/1.1 {} {}\x0d\x0a".format(code, reason)
response = "HTTP/1.1 {0} {1}\x0d\x0a".format(code, reason)
for h in responseHeaders:
response += "{}: {}\x0d\x0a".format(h[0], h[1])
response += "{0}: {1}\x0d\x0a".format(h[0], h[1])
response += "\x0d\x0a"
self.sendData(response.encode('utf8'))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2013 Tavendo GmbH
## Copyright (C) 2013-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ from autobahn.asyncio.websocket import WebSocketClientProtocol, \
class MyClientProtocol(WebSocketClientProtocol):
def onConnect(self, response):
print("Server connected: {}".format(response.peer))
print("Server connected: {0}".format(response.peer))
def onOpen(self):
print("WebSocket connection open.")
@@ -39,12 +39,12 @@ class MyClientProtocol(WebSocketClientProtocol):
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2013 Tavendo GmbH
## Copyright (C) 2013-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import asyncio
class MyClientProtocol(WebSocketClientProtocol):
def onConnect(self, response):
print("Server connected: {}".format(response.peer))
print("Server connected: {0}".format(response.peer))
@asyncio.coroutine
def onOpen(self):
@@ -40,12 +40,12 @@ class MyClientProtocol(WebSocketClientProtocol):
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2013 Tavendo GmbH
## Copyright (C) 2013-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ import asyncio
class MyClientProtocol(WebSocketClientProtocol):
def onConnect(self, response):
print("Server connected: {}".format(response.peer))
print("Server connected: {0}".format(response.peer))
@asyncio.coroutine
def onOpen(self):
@@ -40,12 +40,12 @@ class MyClientProtocol(WebSocketClientProtocol):
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2013 Tavendo GmbH
## Copyright (C) 2013-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -23,22 +23,22 @@ from autobahn.asyncio.websocket import WebSocketServerProtocol, \
class MyServerProtocol(WebSocketServerProtocol):
def onConnect(self, request):
print("Client connecting: {}".format(request.peer))
print("Client connecting: {0}".format(request.peer))
def onOpen(self):
print("WebSocket connection open.")
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
## echo back message verbatim
self.sendMessage(payload, isBinary)
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2011-2013 Tavendo GmbH
## Copyright (C) 2011-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ from autobahn.twisted.websocket import WebSocketClientProtocol, \
class MyClientProtocol(WebSocketClientProtocol):
def onConnect(self, response):
print("Server connected: {}".format(response.peer))
print("Server connected: {0}".format(response.peer))
def onOpen(self):
print("WebSocket connection open.")
@@ -39,12 +39,12 @@ class MyClientProtocol(WebSocketClientProtocol):
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2011-2013 Tavendo GmbH
## Copyright (C) 2011-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ def sleep(delay):
class MyClientProtocol(WebSocketClientProtocol):
def onConnect(self, response):
print("Server connected: {}".format(response.peer))
print("Server connected: {0}".format(response.peer))
@inlineCallbacks
def onOpen(self):
@@ -45,12 +45,12 @@ class MyClientProtocol(WebSocketClientProtocol):
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))

View File

@@ -1,6 +1,6 @@
###############################################################################
##
## Copyright (C) 2011-2013 Tavendo GmbH
## Copyright (C) 2011-2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -23,22 +23,22 @@ from autobahn.twisted.websocket import WebSocketServerProtocol, \
class MyServerProtocol(WebSocketServerProtocol):
def onConnect(self, request):
print("Client connecting: {}".format(request.peer))
print("Client connecting: {0}".format(request.peer))
def onOpen(self):
print("WebSocket connection open.")
def onMessage(self, payload, isBinary):
if isBinary:
print("Binary message received: {} bytes".format(len(payload)))
print("Binary message received: {0} bytes".format(len(payload)))
else:
print("Text message received: {}".format(payload.decode('utf8')))
print("Text message received: {0}".format(payload.decode('utf8')))
## echo back message verbatim
self.sendMessage(payload, isBinary)
def onClose(self, wasClean, code, reason):
print("WebSocket connection closed: {}".format(reason))
print("WebSocket connection closed: {0}".format(reason))