From a5b49d71f35b43941b17684f196e47f76430f3bd Mon Sep 17 00:00:00 2001
From: pmouquet <pascal.mouquet@ird.fr>
Date: Tue, 16 Apr 2024 11:22:21 +0400
Subject: [PATCH] updated scripts according to thomas changes

---
 sen2chain/cloud_mask.py |  2 +-
 sen2chain/config.py     |  1 +
 sen2chain/jobs.py       | 23 ++++++++++++++---------
 sen2chain/products.py   | 25 +++++++++++++++++++++++++
 4 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/sen2chain/cloud_mask.py b/sen2chain/cloud_mask.py
index b161526..26ed50b 100755
--- a/sen2chain/cloud_mask.py
+++ b/sen2chain/cloud_mask.py
@@ -458,7 +458,7 @@ def create_cloud_mask_v003(
     probability: int = 1,
     iterations: int = 5,
 ) -> None:
-	
+    
     """
     Create cloud mask version cm003. This cloudmask uses a simple thresholding
     and dilatations over the 20m cloud_probability band from Sen2Cor. The
diff --git a/sen2chain/config.py b/sen2chain/config.py
index 4d3471d..1056549 100644
--- a/sen2chain/config.py
+++ b/sen2chain/config.py
@@ -151,6 +151,7 @@ class Config:
                 logging.error(
                     "Make sure the path to the sen2cor Bashrc file is valid: {}".format(item)
                 )
+                raise ValueError("Invalid sen2cor Bashrc")
         
     def get(self, param: str) -> str:
         """Returns a parameter value.
diff --git a/sen2chain/jobs.py b/sen2chain/jobs.py
index 03d8325..a704373 100644
--- a/sen2chain/jobs.py
+++ b/sen2chain/jobs.py
@@ -43,7 +43,7 @@ class Jobs:
     Class to list and remove existing jobs. Returns a list of existing job and job status when instanciated.
     
     Usage:
-		>>> Jobs()
+        >>> Jobs()
     """
 
     def __init__(self):
@@ -117,13 +117,18 @@ class Jobs:
 
 
 class Job:
-    """ Class to create, edit, save and launch job routines. A job allows you to download L1C, process L2A, cloudmasks and radiometric indices at once, for 1 or more Tile. Jobs can be set in cron, and a logging option is available.
-    
-	:param jid: Job identifier. If identifier already exists, load job configuration. If it does not exist, creates a job with the default configuration.
-	:type jid: str
-	
-	Usage:
-		>>> Job(jid='abc')
+    """
+    Class to create, edit, save and launch job routines. A job allows you to download L1C, process L2A, cloudmasks and radiometric indices at once, for 1 or more Tile.
+    Jobs can be set in cron, and a logging option is available.
+
+    A job is made of :
+    - a configuration file, located in sen2chain_data/config/jobs/
+    - a .py file if job is set in cron. This .py launches the run() command
+
+    Job config file contains global job parameters and tasks.
+    A task only targets a single Tile, meaning if you want to download and process multiple tile products you need to have the equal number of task lines in your configuration file.
+    We recommend manually editing the configuration file if you plan to set up a job with multiple Tiles, as editing with the command line is only for 1 task at a time.
+
     """
 
     # logger.propagate = False
@@ -641,7 +646,7 @@ class Job:
         clean_after: bool = False,
     ):
         """
-        Runs job. Job needs to be saved first.
+        Runs job immediatly. Job needs to be saved first.
         Tasks are performed line by line.
         
         :param clean_before: When True, clean the library of every tile in tasks before launching job.
diff --git a/sen2chain/products.py b/sen2chain/products.py
index 6c36adb..b4aa734 100755
--- a/sen2chain/products.py
+++ b/sen2chain/products.py
@@ -1863,6 +1863,31 @@ class NewCloudMaskProduct:
             sen2chain_processing_version=sen2chain_processing_version,
             sen2cor_version=sen2cor_version,
         )
+        
+############################"""""" ICI !!
+ +    def remove(self):
++        """
++        Remove CM Product.
++
++        """
++
++        if self.path.exists():
++            if self.path.is_symlink():
++                cm_path = os.readlink(str(self.path))
++                path_xml = os.readlink(str(self._info_path))
++                logger.info("Removing: {}".format(cm_path))
++                shutil.rmtree(cm_path)
++                logger.info("Removing symlink: {}".format(self.path))
++                self.path.unlink()
++                self.path_xml.unlink()
++            else:
++                os.remove(str(self.path))
++                os.remove(str(self._info_path))
++                logger.info("Removing: {}".format(self.path))
++        else:
++            logger.info("CM product not on disk")
+   
+    
 
 
 class IndiceProduct:
-- 
GitLab