From c147f916284c1d788e67474475416d4919a34593 Mon Sep 17 00:00:00 2001
From: Impact <pascal.mouquet@ird.fr>
Date: Thu, 12 Nov 2020 16:06:01 +0400
Subject: [PATCH] added possibility that Tile().l2a is empty in latest_ql
 computing

---
 sen2chain/tiles.py | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/sen2chain/tiles.py b/sen2chain/tiles.py
index 382c1b1..157eb29 100644
--- a/sen2chain/tiles.py
+++ b/sen2chain/tiles.py
@@ -887,19 +887,22 @@ class Tile:
         And remove previous ones
         """
         p = self.l2a.last.identifier
-        l2a = L2aProduct(p)
-
-        outfullpath = l2a.path.parent / "QL" / (l2a.tile + '_' + p[0:4] + Tile._get_date(p).strftime("%Y%m%d") + '_QL_latest.jpg')
-        outfullpath.parent.mkdir(parents=True, exist_ok=True)
-        old_ql = list((l2a.path.parent / "QL").glob('*_QL_latest.jpg*'))
-        liste=[a for a in old_ql if str(outfullpath) not in str(a)]
-        for f in liste:
-            f.unlink()
-        if outfullpath in old_ql:
-            logger.info("{} - Latest QL already done".format(self.name))
-            return
+        if p:
+            l2a = L2aProduct(p)
+
+            outfullpath = l2a.path.parent / "QL" / (l2a.tile + '_' + p[0:4] + Tile._get_date(p).strftime("%Y%m%d") + '_QL_latest.jpg')
+            outfullpath.parent.mkdir(parents=True, exist_ok=True)
+            old_ql = list((l2a.path.parent / "QL").glob('*_QL_latest.jpg*'))
+            liste=[a for a in old_ql if str(outfullpath) not in str(a)]
+            for f in liste:
+                f.unlink()
+            if outfullpath in old_ql:
+                logger.info("{} - Latest QL already done".format(self.name))
+                return
+            else:
+                l2a.process_ql(out_path = outfullpath, out_resolution=(750,750), jpg = True)
         else:
-            l2a.process_ql(out_path = outfullpath, out_resolution=(750,750), jpg = True)
+            logger.info("No L2A product available")
     
     def move_old_quicklooks(self):
         """
-- 
GitLab