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

try to correct few possible issues during download

parent 53a2088a
No related branches found
No related tags found
No related merge requests found
......@@ -69,17 +69,24 @@ class S2cEodag:
end = end,
tileIdentifier = self.name,
)
logger.info("{} - Searching online products, ref: {}".format(self.name, ref))
logging.disable(level=logging.WARNING)
self.products = self.dag.search_all(
**default_search_criteria
)
logging.disable(logging.NOTSET)
try:
self.products = self.dag.search_all(
**default_search_criteria
)
logging.disable(logging.NOTSET)
except simplejson.errors.JSONDecodeError:
logging.disable(logging.NOTSET)
logger.info("Issue with this tile search for now, pass")
pass
# if not isinstance(ref, list):
# ref_string = ref
# else:
# ref_string = "specific cloudmask(s) and / or indice(s) product(s)"
logger.info("Searching online products, ref: {}".format(ref))
fitered = self.products[:]
for p in fitered:
......@@ -285,6 +292,7 @@ class S2cEodag:
outputs_prefix: str = None,
extract: bool = True,
delete_archive: bool = True,
remove_existing_zipfile: bool = True,
):
if not outputs_prefix:
if "L1C" in product_id.properties['title']:
......@@ -294,11 +302,19 @@ class S2cEodag:
outputs_prefix = str(Path(Config().get(root_path)) / self.name)
setup_logging(verbose = 2)
if remove_existing_zipfile:
zip_file = L1cProduct(product_id.properties["id"]).zipfile
if zip_file:
logger.info("Found existing zipfile {}".format(zip_file.name))
try:
L1cProduct(product_id.properties["id"]).remove(zipfile = True)
except:
logger.info("Issue with removing {}".format(zip_file))
pass
if product_id.properties["storageStatus"] == "ONLINE":
# logging.disable(level=logging.WARNING)
try:
L1cProduct(product_id.properties["id"]).remove(zipfile = True)
downloaded_path = self.dag.download(
product_id,
outputs_prefix = outputs_prefix,
......@@ -308,9 +324,8 @@ class S2cEodag:
timeout=0,
)
except:
logger.info("Issue with dowloading{}, removing corrupted zipfile".format(product_id.properties["id"]))
downloaded_path = None
logger.info("Issue with {}, removing corrupted zipfile".format(product_id.properties["id"]))
L1cProduct(product_id.properties["id"]).remove(zipfile = True)
pass
if downloaded_path:
logger.info("dl_path {}".format(downloaded_path))
......
......@@ -427,7 +427,11 @@ class L1cProduct(Product):
@property
def zip_path(self) -> str:
"""Returns zip path"""
return self.path.parent / (self.path.stem + ".zip")
zip_path = self.path.parent / (self.path.stem + ".zip")
if zip_path.exists():
return zip_path
else:
return None
# METADATA
@property
......
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