From 2633b7d301f60d56c165aa26568809454f616631 Mon Sep 17 00:00:00 2001
From: Loraine Gueguen <loraine.gueguen@sb-roscoff.fr>
Date: Thu, 20 May 2021 21:59:31 +0200
Subject: [PATCH] fix picture_path

---
 gga_init.py                       | 18 +++++++++---------
 speciesData.py                    |  1 -
 templates/gspecies_compose.yml.j2 |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/gga_init.py b/gga_init.py
index 1025efa..b87f3f6 100755
--- a/gga_init.py
+++ b/gga_init.py
@@ -38,7 +38,7 @@ class DeploySpeciesStack(speciesData.SpeciesData):
 
     """
 
-    def make_directory_tree(self, picture_path):
+    def make_directory_tree(self):
         """
         Generate the directory tree for an organism
 
@@ -77,18 +77,18 @@ class DeploySpeciesStack(speciesData.SpeciesData):
             self.config.pop(constants.CONF_TRIPAL_BANNER_PATH, None)
 
         # Copy the organism picture for tripal
-        if picture_path is not None:
-            if os.path.isfile(picture_path):
-                picture_path_basename = os.path.basename(picture_path)
+        if self.picture_path is not None:
+            if os.path.isfile(self.picture_path):
+                picture_path_basename = os.path.basename(self.picture_path)
                 picture_path_filename, picture_path_extension = os.path.splitext(picture_path_basename)
                 if picture_path_extension == ".png" or picture_path_extension == ".jpg":
                     picture_dest_name = "species%s" % picture_path_extension
                     picture_dest_path = os.path.join(self.species_dir, picture_dest_name)
-                    shutil.copy(picture_path, picture_dest_path)
+                    shutil.copy(self.picture_path, picture_dest_path)
                 else:
-                    logging.error("Specified organism picture has wrong extension (must be '.png' or '.jpg'): {0}".format(picture_path))
+                    logging.error("Specified organism picture has wrong extension (must be '.png' or '.jpg'): {0}".format(self.picture_path))
             else:
-                logging.error("Specified organism picture not found {0} for {1}".format(picture_path, self.genus_uppercase + " " + self.species))
+                logging.error("Specified organism picture not found {0} for {1}".format(self.picture_path, self.genus_uppercase + " " + self.species))
                 
         # Create nginx dirs and write/re-write nginx conf
         make_dirs(dir_paths_li=["./nginx", "./nginx/conf"])
@@ -423,8 +423,8 @@ if __name__ == "__main__":
         logging.info("gga_init.py called for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species)
 
         # Make/update directory tree
-        picture_path = sp_picture_dict[deploy_stack_for_current_organism.genus_species]
-        deploy_stack_for_current_organism.make_directory_tree(picture_path)
+        deploy_stack_for_current_organism.picture_path = sp_picture_dict[deploy_stack_for_current_organism.genus_species]
+        deploy_stack_for_current_organism.make_directory_tree()
         logging.info("Successfully generated the directory tree for %s %s", deploy_stack_for_current_organism.genus, deploy_stack_for_current_organism.species)
 
         # Make compose files
diff --git a/speciesData.py b/speciesData.py
index 9020e2c..b0d6190 100755
--- a/speciesData.py
+++ b/speciesData.py
@@ -69,7 +69,6 @@ class SpeciesData:
         self.date = datetime.today().strftime("%Y-%m-%d")
         self.origin = parameters_dictionary_description[constants.ORG_PARAM_DESC_ORIGIN]
         self.performed = parameters_dictionary_data[constants.ORG_PARAM_DATA_PERFORMED_BY]
-        self.picture_path = parameters_dictionary_description[constants.ORG_PARAM_DESC_PICTURE_PATH]
 
         if parameters_dictionary_data[constants.ORG_PARAM_DATA_GENOME_VERSION] == "":
             self.genome_version = "1.0"
diff --git a/templates/gspecies_compose.yml.j2 b/templates/gspecies_compose.yml.j2
index b8c9e1b..1b1e8f8 100644
--- a/templates/gspecies_compose.yml.j2
+++ b/templates/gspecies_compose.yml.j2
@@ -42,7 +42,7 @@ services:
             - ./banner.png:/var/www/html/banner.png:ro
             {% endif %}
             #- /groups/XXX/:/groups/XXX/:ro  # We do this when we have symlinks in src_data pointing to /groups/XXX/...
-            {% if 'picture_path' is defined and 'picture_path' != ''  %}
+            {% if 'picture_path' is defined %}
                 {% if 'png' in picture_path %}
             - ./species.png:/var/www/html/species.png:ro
                 {% endif %}
-- 
GitLab