forked from p34709852/monkey
Agent: Fix functions defined in HTTPIslandAPIClient and use the handle_island_errors() decorator on them
This commit is contained in:
parent
fa9225370e
commit
8ab17a96e3
|
@ -24,8 +24,24 @@ def handle_island_errors(fn):
|
|||
|
||||
return decorated
|
||||
|
||||
|
||||
class HTTPIslandAPIClient(IIslandAPIClient):
|
||||
"""
|
||||
A client for the Island's HTTP API
|
||||
"""
|
||||
|
||||
@handle_island_errors
|
||||
def __init__(self, island_server: str):
|
||||
requests.get( # noqa: DUO123
|
||||
f"https://{island_server}/api?action=is-up",
|
||||
verify=False,
|
||||
timeout=MEDIUM_REQUEST_TIMEOUT,
|
||||
)
|
||||
self._island_server = island_server
|
||||
|
||||
# TODO: set server address as object property when init is called in find_server and pass
|
||||
# object around? won't need to pass island server and create object in every function
|
||||
@handle_island_errors
|
||||
def send_log(self, data: str):
|
||||
requests.post( # noqa: DUO123
|
||||
"https://%s/api/log" % (self._island_server,),
|
||||
|
@ -34,6 +50,7 @@ def handle_island_errors(fn):
|
|||
timeout=MEDIUM_REQUEST_TIMEOUT,
|
||||
)
|
||||
|
||||
@handle_island_errors
|
||||
def get_pba_file(self, filename: str):
|
||||
return requests.get( # noqa: DUO123
|
||||
"https://%s/api/pba/download/%s" % (self.server_address, filename),
|
||||
|
|
Loading…
Reference in New Issue