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

Unable to get server address from existing ServerProxy object #53

Open
djetelina opened this issue Oct 19, 2017 · 0 comments
Open

Unable to get server address from existing ServerProxy object #53

djetelina opened this issue Oct 19, 2017 · 0 comments

Comments

@djetelina
Copy link
Contributor

djetelina commented Oct 19, 2017

if I get passed a ServerProxy object to a function, there's no way for me to get it's address other than creating, catching and parsing an exception.

>>> some_server = fastrpc.ServerProxy('http://wanted.com:2250/RPC2')
>>> some_server
<ServerProxy object at 0xe98ea0>
>>> dir(some_server)
['host', 'last_call', 'path', 'port', 'url']
>>> some_server.url
<Method object at 0x7fca6f1b5f10>
>>> some_server.url()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
Fault: <fastrpc.Fault: 404, mtd: object does/does not exist: Nor default method nor method of such name are registered: url [method url() @ http://wanted.com:2250/RPC2]>
>>> some_server.host
<Method object at 0xf621f0>
>>> some_server.host()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
Fault: <fastrpc.Fault: 404, mtd: object does/does not exist: Nor default method nor method of such name are registered: host [method host() @ http://wanted.com:2250/RPC2]>
>>> repr(some_server)
'<ServerProxy object at 0xe98ea0>'
>>> str(some_server)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'str' object is not callable

# The only solution for now, other than wrapping it
>>> try:
...    some_server.no_method()
... except fastrpc.Fault as e:
...     print(repr(e).split('@')[1].split(']')[0])

 http://wanted.com:2250/RPC2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant