Commit 5481ee89 authored by JOSSOUD Olivier's avatar JOSSOUD Olivier
Browse files

FTPOPAR. Download single day.

parent f16913bf
Pipeline #57036 passed with stages
in 1 minute and 36 seconds
......@@ -13,7 +13,7 @@ class Collector(ftp.FtpCollector):
self.object_id = "FTPOPAR"
ftp.FtpCollector.__init__(self, self.object_id, config_parser, log)
def download_maido_ftir(self, first_day: datetime.date, last_day: datetime.date):
def download_maido_ftir(self, day: datetime.date):
"""Download all Picarro files from FTP server.
The distant files will be deleted from the server if the transfer is successful.
......@@ -25,17 +25,15 @@ class Collector(ftp.FtpCollector):
"""
self.logger.write(self.object_id, "Download Maido's FTIR meteo data.")
self._ftp_connect_()
ftp_session = self._ftp_connect_()
days_list = [first_day + datetime.timedelta(days=x) for x in range((last_day - first_day).days + 1)]
for day in days_list:
source_filepath = self.base_dir + "/" + day.strftime("%Y%m%d") + "Meteo125HR.xls"
dest_filepath = self.__get_dest_filepath__(day)
success = self._ftp_download_file(self.session, source_filepath, dest_filepath)
if success:
self.__compress_file__(day, dest_filepath)
source_filepath = self.base_dir + "/" + day.strftime("%Y%m%d") + "Meteo125HR.xls"
dest_filepath = self.__get_dest_filepath__(day)
success = self._ftp_download_file(ftp_session, source_filepath, dest_filepath)
if success:
self.__compress_file__(day, dest_filepath)
self.session.quit()
ftp_session.quit()
def __get_dest_filepath__(self, day: datetime.date) -> str:
# Build destination directory
......
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