Commit b5619042 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Applied pyflakes & pep8

parent 667d6115
...@@ -146,7 +146,7 @@ class Connection(object): ...@@ -146,7 +146,7 @@ class Connection(object):
frame = self.sock.recv() frame = self.sock.recv()
if frame.opcode != OPCODE_CLOSE: if frame.opcode != OPCODE_CLOSE:
raise ValueError('expected CLOSE frame, got %s instead' % frame) raise ValueError('expected CLOSE frame, got %s' % frame)
res_code, res_reason = frame.unpack_close() res_code, res_reason = frame.unpack_close()
......
...@@ -3,8 +3,6 @@ import socket ...@@ -3,8 +3,6 @@ import socket
from os import urandom from os import urandom
from string import printable from string import printable
from errors import SocketClosed
OPCODE_CONTINUATION = 0x0 OPCODE_CONTINUATION = 0x0
OPCODE_TEXT = 0x1 OPCODE_TEXT = 0x1
...@@ -154,7 +152,7 @@ class Frame(object): ...@@ -154,7 +152,7 @@ class Frame(object):
pl = printstr(self.payload)[:max_pl_disp] pl = printstr(self.payload)[:max_pl_disp]
if len(self.payload) > max_pl_disp: if len(self.payload) > max_pl_disp:
pl += '...' pl += '...'
return s + ' payload=%s>' % pl return s + ' payload=%s>' % pl
...@@ -176,7 +174,7 @@ class ControlFrame(Frame): ...@@ -176,7 +174,7 @@ class ControlFrame(Frame):
125 bytes. 125 bytes.
""" """
if len(self.payload) > 125: if len(self.payload) > 125:
raise ValueError('control frames must not be larger than 125' \ raise ValueError('control frames must not be larger than 125 '
'bytes') 'bytes')
return Frame.pack(self) return Frame.pack(self)
......
...@@ -42,8 +42,8 @@ class websocket(object): ...@@ -42,8 +42,8 @@ class websocket(object):
>>> sock.connect(('', 8000)) >>> sock.connect(('', 8000))
>>> sock.send(twspy.Frame(twspy.OPCODE_TEXT, 'Hello, Server!')) >>> sock.send(twspy.Frame(twspy.OPCODE_TEXT, 'Hello, Server!'))
""" """
def __init__(self, sock=None, protocols=[], extensions=[], sfamily=socket.AF_INET, def __init__(self, sock=None, protocols=[], extensions=[],
sproto=0): sfamily=socket.AF_INET, sproto=0):
""" """
Create a regular TCP socket of family `family` and protocol Create a regular TCP socket of family `family` and protocol
...@@ -251,10 +251,12 @@ class websocket(object): ...@@ -251,10 +251,12 @@ class websocket(object):
# Request protocols and extension, these are later checked with the # Request protocols and extension, these are later checked with the
# actual supported values from the server's response # actual supported values from the server's response
if self.protocols: if self.protocols:
shake += 'Sec-WebSocket-Protocol: %s\r\n' % ', '.join(self.protocols) shake += 'Sec-WebSocket-Protocol: %s\r\n' \
% ', '.join(self.protocols)
if self.extensions: if self.extensions:
shake += 'Sec-WebSocket-Extensions: %s\r\n' % ', '.join(self.extensions) shake += 'Sec-WebSocket-Extensions: %s\r\n' \
% ', '.join(self.extensions)
if auth: if auth:
shake += 'Authorization: %s\r\n' % auth shake += 'Authorization: %s\r\n' % auth
...@@ -351,7 +353,6 @@ class websocket(object): ...@@ -351,7 +353,6 @@ class websocket(object):
self.handshake_started = True self.handshake_started = True
receive_response(send_request(location)) receive_response(send_request(location))
def enable_ssl(self, *args, **kwargs): def enable_ssl(self, *args, **kwargs):
""" """
Transforms the regular socket.socket to an ssl.SSLSocket for secure Transforms the regular socket.socket to an ssl.SSLSocket for secure
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment