Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in JSONTokenApi plugin #192

Closed
wants to merge 1 commit into from
Closed

Fix bug in JSONTokenApi plugin #192

wants to merge 1 commit into from

Conversation

grz0
Copy link
Contributor

@grz0 grz0 commented Aug 22, 2015

Fixes:

handler exception: 'method' object is not subscriptable
exception
Traceback (most recent call last):
File "/root/websockify/websockify/websocket.py", line 910, in top_new_client
client = self.do_handshake(startsock, address)
File "/root/websockify/websockify/websocket.py", line 845, in do_handshake
self.RequestHandlerClass(retsock, address, self)
File "/root/websockify/websockify/websocket.py", line 114, in init
SimpleHTTPRequestHandler.init(self, req, addr, server)
File "/usr/lib/python3.4/socketserver.py", line 673, in init
self.handle()
Fixes:
File "/root/websockify/websockify/websocket.py", line 570, in handle
SimpleHTTPRequestHandler.handle(self)
File "/usr/lib/python3.4/http/server.py", line 398, in handle
self.handle_one_request()
File "/usr/lib/python3.4/http/server.py", line 386, in handle_one_request
method()
File "/root/websockify/websockify/websocket.py", line 536, in do_GET
if not self.handle_websocket():
File "/root/websockify/websockify/websocket.py", line 524, in handle_websocket
self.new_websocket_client()
File "/root/websockify/websockify/websocketproxy.py", line 48, in new_websocket_client
(self.server.target_host, self.server.target_port) = self.get_target(self.server.token_plugin, self.path)
File "/root/websockify/websockify/websocketproxy.py", line 103, in get_target
result_pair = target_plugin.lookup(token)
File "/root/websockify/websockify/token_plugins.py", line 72, in lookup
return self.process_result(resp)
File "/root/websockify/websockify/token_plugins.py", line 82, in process_result
return (resp.json['host'], resp.json['port'])
TypeError: 'method' object is not subscriptable

@@ -79,4 +79,4 @@ class JSONTokenApi(BaseTokenAPI):
# should go

def process_result(self, resp):
return (resp.json['host'], resp.json['port'])
return (str(resp.json()['host']), str(resp.json()['port']))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the calls to str() are necessary here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my test, I have error message:
handler exception: Int or String expected

When I change the line to:
return (str(resp.json['host']), str(resp.json['port']))

it solve the error. So on my case the str() is needed.
And the resp.json()[] is not work, so it should use just resp.json[].

My python is version 2.6.6

@DirectXMan12
Copy link
Member

In general, LGTM 👍. Just one inline comment.

@DirectXMan12 DirectXMan12 added bug Something isn't working python labels Aug 24, 2015
@DirectXMan12 DirectXMan12 self-assigned this Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants