Island: Fix typo in AgentRetrievalError

This commit is contained in:
Ilija Lazoroski 2022-06-07 19:52:54 +02:00
parent 28a07e4fdd
commit 0a8cbbc771
3 changed files with 13 additions and 12 deletions

View File

@ -1,2 +1,3 @@
from .file_storage import FileRetrievalError, IFileRepository, LocalStorageFileRepository
from .i_agent_binary_repository import IAgentBinaryRepository, AgentRetrivalError
from .i_agent_binary_repository import IAgentBinaryRepository, AgentRetrievalError
from .agent_binary_repository import AgentBinaryRepository

View File

@ -1,6 +1,6 @@
from typing import BinaryIO
from . import AgentRetrivalError, FileRetrivalError, IAgentBinaryRepository, IFileRepository
from . import AgentRetrievalError, FileRetrievalError, IAgentBinaryRepository, IFileRepository
LINUX_AGENT_FILE_NAME = "monkey-linux-64"
WINDOWS_AGENT_FILE_NAME = "monkey-windows-64.exe"
@ -10,18 +10,18 @@ class AgentBinaryRepository(IAgentBinaryRepository):
def __init__(self, file_repository: IFileRepository):
self._file_repository = file_repository
def __get_binary(self, filename) -> BinaryIO:
def get_linux_binary(self) -> BinaryIO:
return self._get_binary(LINUX_AGENT_FILE_NAME)
def get_windows_binary(self) -> BinaryIO:
return self._get_binary(WINDOWS_AGENT_FILE_NAME)
def _get_binary(self, filename: str) -> BinaryIO:
try:
agent_binary = self._file_repository.open_file(filename)
return agent_binary
except FileRetrivalError as err:
raise AgentRetrivalError(
except FileRetrievalError as err:
raise AgentRetrievalError(
f"An error occurred while retrieving the {filename}"
f" agent binary from {self._file_repository}: {err}"
)
def get_linux_binary(self) -> BinaryIO:
self.__get_binary(LINUX_AGENT_FILE_NAME)
def get_windows_binary(self) -> BinaryIO:
self.__get_binary(WINDOWS_AGENT_FILE_NAME)

View File

@ -2,7 +2,7 @@ import abc
from typing import BinaryIO
class AgentRetrivalError(IOError):
class AgentRetrievalError(IOError):
pass