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

#21 and #10 #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<img align="right" src="cirrina.jpg" width="200">
<img align="right" src="doc/cirrina.jpg" width="200">

# cirrina

Expand Down
18 changes: 8 additions & 10 deletions cirrina/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@
"""

import aiohttp_jrpc
import asyncio

class RPCClient(object):

class RPCClient:
""" Base JsonRPC Client """
# pylint: disable=too-few-public-methods
def __init__(self, url):
self.remote = aiohttp_jrpc.Client(url)

def __getattr__(self, attr):
@asyncio.coroutine
def wrapper(*args, **kw):
ret = yield from self.remote.call(attr, {'args': args, 'kw': kw})
if ret.error:
if ret.error['code'] == -32602:
raise TypeError(ret.error['message'])
async def _wrapper(*args, **kw):
ret = await self.remote.call(attr, {'args': args, 'kw': kw})
if ret.error and ret.error['code'] == -32602:
raise TypeError(ret.error['message'])
return ret.result

return wrapper

return _wrapper
Loading