Skip to content

Commit

Permalink
simplified conftest and removed unused fixtures (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottekostelic committed Aug 19, 2024
1 parent da11876 commit b38dbbe
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 443 deletions.
54 changes: 26 additions & 28 deletions file_retriever/_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def get_file_data(self, file_name: str, dir: str) -> FileInfo:
try:
self._check_dir(dir)

# Retrieve file permissions
permissions = None

def get_file_permissions(data):
Expand All @@ -214,6 +213,19 @@ def get_file_permissions(data):
except ftplib.error_perm:
raise RetrieverFileError

def is_active(self) -> bool:
"""
Checks if connection to server is active.
Returns:
bool: True if connection is active, False otherwise
"""
status = self.connection.voidcmd("NOOP")
if status.startswith("2"):
return True
else:
return False

def list_file_data(self, dir: str) -> List[FileInfo]:
"""
Retrieves metadata for each file in `dir` on server.
Expand Down Expand Up @@ -241,19 +253,6 @@ def list_file_data(self, dir: str) -> List[FileInfo]:
raise RetrieverFileError
return files

def is_active(self) -> bool:
"""
Checks if connection to server is active.
Returns:
bool: True if connection is active, False otherwise
"""
status = self.connection.voidcmd("NOOP")
if status.startswith("2"):
return True
else:
return False

def write_file(self, file: File, dir: str, remote: bool) -> FileInfo:
"""
Writes file to directory. If `remote` is True, then file is written
Expand All @@ -278,7 +277,6 @@ def write_file(self, file: File, dir: str, remote: bool) -> FileInfo:
ftplib.error_perm: if unable to write file to remote directory
OSError: if unable to write file to local directory
"""
# make sure file stream is at beginning before writing
file.file_stream.seek(0)

if remote is True:
Expand Down Expand Up @@ -433,6 +431,19 @@ def get_file_data(self, file_name: str, dir: str) -> FileInfo:
except OSError:
raise RetrieverFileError

def is_active(self) -> bool:
"""
Checks if connection to server is active.
Returns:
bool: True if connection is active, False otherwise
"""
channel = self.connection.get_channel()
if channel is None or channel is not None and channel.closed:
return False
else:
return True

def list_file_data(self, dir: str) -> List[FileInfo]:
"""
Retrieves metadata for each file in `dir` on server.
Expand All @@ -454,19 +465,6 @@ def list_file_data(self, dir: str) -> List[FileInfo]:
logger.error(f"Unable to retrieve file data for {dir}: {e}")
raise RetrieverFileError

def is_active(self) -> bool:
"""
Checks if connection to server is active.
Returns:
bool: True if connection is active, False otherwise
"""
channel = self.connection.get_channel()
if channel is None or channel is not None and channel.closed:
return False
else:
return True

def write_file(self, file: File, dir: str, remote: bool) -> FileInfo:
"""
Writes file to directory. If `remote` is True, then file is written
Expand Down
Loading

0 comments on commit b38dbbe

Please sign in to comment.