Skip to content

Commit

Permalink
Merge pull request #121 from agfor/api_shim_non_callable
Browse files Browse the repository at this point in the history
Allow access non-callable client attributes through the API shim
  • Loading branch information
sibson committed Jan 16, 2018
2 parents d12ed38 + bf44655 commit 913e49d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vncdotool/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, factory, timeout=60 * 60):
self.factory = factory
self.queue = queue.Queue()
self._timeout = timeout
self.protocol = None

def __enter__(self):
return self
Expand All @@ -69,6 +70,10 @@ def timeout(self, timeout):
self._timeout = timeout

def connect(self, host, port=5900, family=socket.AF_INET):
def capture_protocol(protocol):
self.protocol = protocol
return protocol
self.factory.deferred.addCallback(capture_protocol)
reactor.callWhenRunning(
factory_connect, self.factory, host, port, family)

Expand Down Expand Up @@ -104,7 +109,10 @@ def proxy_call(*args, **kwargs):

return result

return proxy_call
if callable(method):
return proxy_call
else:
return getattr(self.protocol, attr)

def __dir__(self):
return dir(self.__class__) + dir(self.factory.protocol)
Expand Down

0 comments on commit 913e49d

Please sign in to comment.