From 34e8926be4c39b05de9fc448cd6d6bcdb18fadae Mon Sep 17 00:00:00 2001 From: Tobias Oberstein Date: Wed, 8 Jan 2014 15:11:27 +0100 Subject: [PATCH] fxies for Python 2.6 --- autobahn/autobahn/websocket/protocol.py | 4 ++-- examples/asyncio/websocket/echo/client.py | 10 +++++----- examples/asyncio/websocket/echo/client_coroutines.py | 10 +++++----- .../asyncio/websocket/echo/client_coroutines_py2.py | 10 +++++----- examples/asyncio/websocket/echo/server.py | 10 +++++----- examples/twisted/websocket/echo/client.py | 10 +++++----- examples/twisted/websocket/echo/client_coroutines.py | 10 +++++----- examples/twisted/websocket/echo/server.py | 10 +++++----- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/autobahn/autobahn/websocket/protocol.py b/autobahn/autobahn/websocket/protocol.py index 82c50ce1..5e1860df 100644 --- a/autobahn/autobahn/websocket/protocol.py +++ b/autobahn/autobahn/websocket/protocol.py @@ -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')) diff --git a/examples/asyncio/websocket/echo/client.py b/examples/asyncio/websocket/echo/client.py index d91ea388..50657bb5 100644 --- a/examples/asyncio/websocket/echo/client.py +++ b/examples/asyncio/websocket/echo/client.py @@ -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)) diff --git a/examples/asyncio/websocket/echo/client_coroutines.py b/examples/asyncio/websocket/echo/client_coroutines.py index e268ca2c..5d14e2be 100644 --- a/examples/asyncio/websocket/echo/client_coroutines.py +++ b/examples/asyncio/websocket/echo/client_coroutines.py @@ -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)) diff --git a/examples/asyncio/websocket/echo/client_coroutines_py2.py b/examples/asyncio/websocket/echo/client_coroutines_py2.py index db2333a4..794e34b2 100644 --- a/examples/asyncio/websocket/echo/client_coroutines_py2.py +++ b/examples/asyncio/websocket/echo/client_coroutines_py2.py @@ -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)) diff --git a/examples/asyncio/websocket/echo/server.py b/examples/asyncio/websocket/echo/server.py index efdd457c..888706b4 100644 --- a/examples/asyncio/websocket/echo/server.py +++ b/examples/asyncio/websocket/echo/server.py @@ -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)) diff --git a/examples/twisted/websocket/echo/client.py b/examples/twisted/websocket/echo/client.py index 7b3e6b29..f0275c2e 100644 --- a/examples/twisted/websocket/echo/client.py +++ b/examples/twisted/websocket/echo/client.py @@ -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)) diff --git a/examples/twisted/websocket/echo/client_coroutines.py b/examples/twisted/websocket/echo/client_coroutines.py index aef83200..cb81c30d 100644 --- a/examples/twisted/websocket/echo/client_coroutines.py +++ b/examples/twisted/websocket/echo/client_coroutines.py @@ -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)) diff --git a/examples/twisted/websocket/echo/server.py b/examples/twisted/websocket/echo/server.py index e9c3a86a..1b435651 100644 --- a/examples/twisted/websocket/echo/server.py +++ b/examples/twisted/websocket/echo/server.py @@ -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))