Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_healthcheck():
client = HTTPClient('http://localhost:8080')
print(client.request('yo.healthcheck'))
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)
def test_api():
client = HTTPClient('http://localhost:8080')
print(client.request('yo.api_test_method'))
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))
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
"""
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
def __init__(self,endpoint_url='http://localhost:8080'):
self.client = http_client.HTTPClient(endpoint_url)