add py3.4 compatibility
The "bytes % bytes" syntax only appeared on py3.5, so don't use it. Updated travis to expect py3.4 works. The twisted side is probably even more broken for py3.4 than it is for py3.5.
This commit is contained in:
parent
c261f3e713
commit
540fceb795
|
@ -9,7 +9,6 @@ python:
|
|||
matrix:
|
||||
allow_failures:
|
||||
- python: "3.3"
|
||||
- python: "3.4"
|
||||
fast_finish: true
|
||||
install:
|
||||
- pip install . Twisted pyflakes
|
||||
|
|
|
@ -42,15 +42,15 @@ class TransitError(Exception):
|
|||
|
||||
def build_receiver_handshake(key):
|
||||
hexid = HKDF(key, 32, CTXinfo=b"transit_receiver")
|
||||
return b"transit receiver %s ready\n\n" % hexlify(hexid)
|
||||
return b"transit receiver "+hexlify(hexid)+b" ready\n\n"
|
||||
|
||||
def build_sender_handshake(key):
|
||||
hexid = HKDF(key, 32, CTXinfo=b"transit_sender")
|
||||
return b"transit sender %s ready\n\n" % hexlify(hexid)
|
||||
return b"transit sender "+hexlify(hexid)+b" ready\n\n"
|
||||
|
||||
def build_relay_handshake(key):
|
||||
token = HKDF(key, 32, CTXinfo=b"transit_relay_token")
|
||||
return b"please relay %s\n" % hexlify(token)
|
||||
return b"please relay "+hexlify(token)+b"\n"
|
||||
|
||||
TIMEOUT=15
|
||||
|
||||
|
|
|
@ -26,23 +26,23 @@ class EventsProtocol:
|
|||
# face of firewall/NAT timeouts. It also helps unit tests, since
|
||||
# apparently twisted.web.client.Agent doesn't consider the connection
|
||||
# to be established until it sees the first byte of the reponse body.
|
||||
self.request.write(b": %s\n\n" % comment)
|
||||
self.request.write(b": " + comment + b"\n\n")
|
||||
|
||||
def sendEvent(self, data, name=None, id=None, retry=None):
|
||||
if name:
|
||||
self.request.write(b"event: %s\n" % name.encode("utf-8"))
|
||||
self.request.write(b"event: " + name.encode("utf-8") + b"\n")
|
||||
# e.g. if name=foo, then the client web page should do:
|
||||
# (new EventSource(url)).addEventListener("foo", handlerfunc)
|
||||
# Note that this basically defaults to "message".
|
||||
self.request.write(b"\n")
|
||||
if id:
|
||||
self.request.write(b"id: %s\n" % id.encode("utf-8"))
|
||||
self.request.write(b"id: " + id.encode("utf-8") + b"\n")
|
||||
self.request.write(b"\n")
|
||||
if retry:
|
||||
self.request.write(b"retry: %d\n" % retry) # milliseconds
|
||||
self.request.write(b"retry: " + retry + b"\n") # milliseconds
|
||||
self.request.write(b"\n")
|
||||
for line in data.splitlines():
|
||||
self.request.write(b"data: %s\n" % line.encode("utf-8"))
|
||||
self.request.write(b"data: " + line.encode("utf-8") + b"\n")
|
||||
self.request.write(b"\n")
|
||||
|
||||
def stop(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user