How to use the jsonrpcclient.http_client.HTTPClient function in jsonrpcclient

To help you get started, we’ve selected a few jsonrpcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github steemit / yo / testscripts / test_healthcheck.py View on Github external
def test_healthcheck():
    client = HTTPClient('http://localhost:8080')
    print(client.request('yo.healthcheck'))
github steemit / yo / testscripts / test_update_userprefs.py View on Github external
def test_update_userprefs():
    client = HTTPClient('http://localhost:8080')
    req = Request(
        'yo.enable_transports',
        username=username,
        transports={
            'vote': ['email', 'gareth@steemit.com']
        })
    print('request sent:')
    pprint.pprint(req)
    results = client.send(req)

    print('Server response:')
    pprint.pprint(results)
github steemit / yo / testscripts / test_api_test_method.py View on Github external
def test_api():
    client = HTTPClient('http://localhost:8080')
    print(client.request('yo.api_test_method'))
github aaroncox / chainsync / chainsync / clients / http / rpc.py View on Github external
import requests
import sys
import datetime
import time

from jsonrpcclient.http_client import HTTPClient
from jsonrpcclient.request import Request

from jsonrpcclient import config
config.validate = False


class Client(HTTPClient):

    def send(self, request, **kwargs):
        # start_time = time.time()
        response = super(Client, self).send(request, **kwargs)
        # total_time = "%.3f" % (time.time() - start_time)
        # print("[{}] http request - {} kb / {} sec - {} {}".format(datetime.datetime.now(), sys.getsizeof(str(response)) / 1000, total_time, request, list(kwargs)))
        # print(response)
        if 'error' in response:
            print("response error")
            print(response)
            raise requests.RequestException()
        return response

    def request(self, method_name, *args, **kwargs):
        # start_time = time.time()
        response = super(Client, self).send(Request(method_name, *args, **kwargs))
github trinity-project / trinity / gateway / network / jsonrpc.py View on Github external
def jsonrpc_request_sync(method, params, addr):
        try:
            endpoint = 'http://' + addr[0] + ":" + str(addr[1])
            client = HTTPClient(endpoint)
            rpc_logger.info("--> sender to {}\n : {}".format(addr,params))
            res = client.request(method, params)
            rpc_logger.info("<-- receiver from {}\n : {}".format(addr,res))
        except Exception as e:
            res = None
        finally:
            return res
github bcb / jsonrpcclient / jsonrpcclient / http_server.py View on Github external
"""
HTTPServer.

Deprecated module; use HTTPClient instead. Remove in version 3.
"""
from warnings import warn

from .http_client import HTTPClient


warn("HTTPServer is deprecated, use HTTPClient", DeprecationWarning)


class HTTPServer(HTTPClient):
    """Deprecate by subclassing"""

    pass
github steemit / yo / yo / utils / simple_client.py View on Github external
def __init__(self,endpoint_url='http://localhost:8080'):
       self.client = http_client.HTTPClient(endpoint_url)