fix: more pylint fixes
This commit is contained in:
parent
ecdca8f0ee
commit
22d1205a26
1 changed files with 6 additions and 5 deletions
|
@ -35,7 +35,7 @@ class RestAdapter:
|
||||||
if not ssl and not enforced_signing:
|
if not ssl and not enforced_signing:
|
||||||
disable_warnings()
|
disable_warnings()
|
||||||
|
|
||||||
def _do(self, http_method: str, endpoint: str, params: Dict = None, data: Dict = None) -> Result:
|
def _do(self, http_method: str, endpoint: str, params: Dict = None, data: Dict = None, timeout: float = 60) -> Result:
|
||||||
"""Internal method to make a request to the Zipline server. You shouldn't use this directly.
|
"""Internal method to make a request to the Zipline server. You shouldn't use this directly.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -43,6 +43,7 @@ class RestAdapter:
|
||||||
endpoint (str): The endpoint to make the request to.
|
endpoint (str): The endpoint to make the request to.
|
||||||
params (Dict = None): Python dictionary of query parameters to send with the request.
|
params (Dict = None): Python dictionary of query parameters to send with the request.
|
||||||
data (Dict = None): Python dictionary of data to send with the request.
|
data (Dict = None): Python dictionary of data to send with the request.
|
||||||
|
timeout (float = 60): Number of seconds to wait for the request to complete.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Result: A Result object containing the status code, message, and data from the request.
|
Result: A Result object containing the status code, message, and data from the request.
|
||||||
|
@ -56,9 +57,9 @@ class RestAdapter:
|
||||||
|
|
||||||
try: # Perform an HTTP request, catching and re-raising any exceptions
|
try: # Perform an HTTP request, catching and re-raising any exceptions
|
||||||
# will eventually refactor this to use asyncio/aiohttp instead for async operation
|
# will eventually refactor this to use asyncio/aiohttp instead for async operation
|
||||||
response = requests.request(method=http_method, url=full_url, verify=self._enforced_signing, params=params, headers=headers, json=data)
|
response = requests.request(method=http_method, url=full_url, verify=self._enforced_signing, params=params, headers=headers, json=data, timeout=timeout)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
self._logger.error(msg=(str(e)))
|
self._logger.error(msg=str(e))
|
||||||
raise HTTPFailure("Could not connect to Zipline server") from e
|
raise HTTPFailure("Could not connect to Zipline server") from e
|
||||||
|
|
||||||
try: # Deserialize JSON output to Python object, or return failed Result on exception
|
try: # Deserialize JSON output to Python object, or return failed Result on exception
|
||||||
|
@ -71,7 +72,7 @@ class RestAdapter:
|
||||||
|
|
||||||
if is_success:
|
if is_success:
|
||||||
return Result(success=is_success, status_code=response.status_code, message=response.reason, data=data_out)
|
return Result(success=is_success, status_code=response.status_code, message=response.reason, data=data_out)
|
||||||
else:
|
|
||||||
return Result(success=is_success, status_code=response.status_code, message=data_out['error'], data=data_out)
|
return Result(success=is_success, status_code=response.status_code, message=data_out['error'], data=data_out)
|
||||||
|
|
||||||
def get(self, endpoint: str, params: Dict = None) -> Result:
|
def get(self, endpoint: str, params: Dict = None) -> Result:
|
||||||
|
|
Loading…
Reference in a new issue