Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 7d500ea0 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

FTP. Functions have no more reason to be private.

parent e45fa970
......@@ -40,7 +40,7 @@ def ftp_connect(ftp_config: dict, log: logger.Logger, object_id: str) -> ftplib.
return session
def _ftp_list_files_(ftp_session: ftplib.FTP, distant_directory_path: str, log: logger.Logger, object_id: str) -> list:
def ftp_list_files(ftp_session: ftplib.FTP, distant_directory_path: str, log: logger.Logger, object_id: str) -> list:
"""List the files in the distant FTP directory.
Parameters
......@@ -72,10 +72,10 @@ def _ftp_list_files_(ftp_session: ftplib.FTP, distant_directory_path: str, log:
return filepaths
def _ftp_download_file(source_filepath: str, dest_filepath: str,
log: logger.Logger, object_id: str,
ftp_config: dict = None, ftp_session: ftplib.FTP = None,
delete_if_success: bool = False) -> bool:
def ftp_download_file(source_filepath: str, dest_filepath: str,
log: logger.Logger, object_id: str,
ftp_config: dict = None, ftp_session: ftplib.FTP = None,
delete_if_success: bool = False) -> bool:
"""Download a file from the FTP server.
Parameters
......
......@@ -28,8 +28,8 @@ class Collector(utils.LogConfig):
dest_filepath = self.__get_dest_filepath__(yyyymm)
# Download
success = ftp._ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_config=self.config[self.object_id])
success = ftp.ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_config=self.config[self.object_id])
# Compress
if success:
......
......@@ -40,15 +40,15 @@ class Collector(utils.LogConfig):
source_filepath = source_dir + source_filename
# Check that to-be-downloaded file exists
source_filepaths = ftp._ftp_list_files_(ftp_session, source_dir, self.logger, self.object_id)
source_filepaths = ftp.ftp_list_files(ftp_session, source_dir, self.logger, self.object_id)
if source_filepath not in source_filepaths:
self.logger.write(self.object_id, "File not found: " + source_filepath)
raise FileNotFoundError(source_filepath)
# Download file
dest_filepath = self.__get_picarro_dest_filepath__(source_filepath)
success = ftp._ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_session=ftp_session)
success = ftp.ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_session=ftp_session)
ftp_session.quit()
......@@ -96,11 +96,11 @@ class Collector(utils.LogConfig):
ftp_session = ftp.ftp_connect(self.config[self.object_id], self.logger, self.object_id)
hobo_distant_path = self.distant_base_dir + "/" + site_id + "/hobo/"
source_filepaths = ftp._ftp_list_files_(ftp_session, hobo_distant_path, self.logger, self.object_id)
source_filepaths = ftp.ftp_list_files(ftp_session, hobo_distant_path, self.logger, self.object_id)
for source_filepath in source_filepaths:
dest_filepath = self.__get_hobo_dest_filepath__(source_filepath)
ftp._ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_session=ftp_session)
ftp.ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_session=ftp_session)
ftp_session.quit()
......
......@@ -32,8 +32,8 @@ class Collector(utils.LogConfig):
dest_filepath = self.__get_dest_filepath__(day)
# Download
success = ftp._ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_config=self.config[self.object_id])
success = ftp.ftp_download_file(source_filepath, dest_filepath, self.logger, self.object_id,
ftp_config=self.config[self.object_id])
# Compress
if success:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment