Skip to content
Snippets Groups Projects
Commit 28ccf362 authored by pascal.mouquet_ird.fr's avatar pascal.mouquet_ird.fr
Browse files

new l2a_archive tile function to archive l2a products in corresponding folder

parent 607557fc
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ class Config:
"l1c_path": "",
"l1c_archive_path": "/ARCHIVE_SENTINEL-PROD/S2_L1C_ARCHIVE",
"l2a_path": "",
"l2a_archive_path": "/ARCHIVE_SENTINEL-PROD/S2_L2A_ARCHIVE",
"indices_path": "",
"time_series_path": "",
"monthly_summaries_path": ""}
......
......@@ -333,11 +333,19 @@ class Tile:
#~ logger.info("Product: local / archived / total".format(human_size(getFolderSize(str(self.paths['l1c'])))))
local = getFolderSize(str(self.paths["l1c"]))
total = getFolderSize(str(self.paths["l1c"]), True)
logger.info("l1c: {} (l: {} / a: {})".format(human_size(total),
logger.info("l1c: {} (local: {} / archived: {})".format(human_size(total),
human_size(local),
human_size(total-local),
))
logger.info("l2a: {}".format(human_size(getFolderSize(str(self.paths["l2a"]), True))))
#~ logger.info("l2a: {}".format(human_size(getFolderSize(str(self.paths["l2a"]), True))))
local = getFolderSize(str(self.paths["l2a"]))
total = getFolderSize(str(self.paths["l2a"]), True)
logger.info("l2a: {} (local: {} / archived: {})".format(human_size(total),
human_size(local),
human_size(total-local),
))
for indice, path in self._paths["indices"].items():
logger.info("{}: {}".format(indice, human_size(getFolderSize(str(path), True))))
......@@ -516,4 +524,33 @@ class Tile:
if not count:
logger.info("No L1C products to archive")
def archive_l2a(self):
"""
Check and move l1c products to archive folder
"""
if (self.clean_lib()['identified_problems']-self.clean_lib()['removed_problems']) == 0:
logger.info("No tile error processing l2a archive")
l2a_archive_path = Path(Config().get("l2a_archive_path"))
prod_list = self.l2a
if prod_list:
count = 0
for prod in prod_list:
l2a = L2aProduct(prod.identifier)
if not l2a.path.is_symlink():
count += 1
move_path = l2a_archive_path / l2a.tile / l2a.path.name
logger.info("archiving {}".format(l2a.identifier))
move_path.parent.mkdir(exist_ok=True)
shutil.move(str(l2a.path), str(move_path.parent))
l2a.path.symlink_to(move_path, target_is_directory = True)
logger.info("{} products archived".format(count))
else:
logger.info("No L2A products, nothing to archive")
else:
logger.info("Error(s) in l2a product(s) please correct them running clean_lib(remove=True) before archiving")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment