Skip to content

Commit

Permalink
Merge pull request #140 from rpodgorny/python3
Browse files Browse the repository at this point in the history
python3 compatibility fixes
  • Loading branch information
kanaka committed Oct 2, 2014
2 parents 63209f8 + 303a713 commit f36877c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion websockify/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def recv_frames(self):
def send_close(self, code=1000, reason=''):
""" Send a WebSocket orderly close frame. """

msg = pack(">H%ds" % len(reason), code, reason)
msg = pack(">H%ds" % len(reason), code, s2b(reason))
buf, h, t = self.encode_hybi(msg, opcode=0x08, base64=False)
self.request.send(buf)

Expand Down
6 changes: 3 additions & 3 deletions websockify/websocketproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_target(self, target_cfg, path):
# Extract the token parameter from url
args = parse_qs(urlparse(path)[4]) # 4 is the query from url

if not args.has_key('token') or not len(args['token']):
if not 'token' in args or not len(args['token']):
raise self.EClose("Token not present")

token = args['token'][0].rstrip('\n')
Expand All @@ -105,14 +105,14 @@ def get_target(self, target_cfg, path):

targets = {}
for f in cfg_files:
for line in [l.strip() for l in file(f).readlines()]:
for line in [l.strip() for l in open(f).readlines()]:
if line and not line.startswith('#'):
ttoken, target = line.split(': ')
targets[ttoken] = target.strip()

self.vmsg("Target config: %s" % repr(targets))

if targets.has_key(token):
if token in targets:
return targets[token].split(':')
else:
raise self.EClose("Token '%s' not found" % token)
Expand Down

0 comments on commit f36877c

Please sign in to comment.