Skip to content
Snippets Groups Projects
Commit 39a9162b authored by Arthur Le Bars's avatar Arthur Le Bars
Browse files

Fix tripal page organism picture

parent e72f99c6
No related branches found
No related tags found
2 merge requests!18Release v2.1.0,!14Add a picture in Tripal home page
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
......@@ -7,6 +7,7 @@ ORG_PARAM_DESC_SEX = "sex"
ORG_PARAM_DESC_STRAIN = "strain"
ORG_PARAM_DESC_COMMON_NAME = "common_name"
ORG_PARAM_DESC_ORIGIN = "origin"
ORG_PARAM_DESC_PICTURE_PATH = "tripal_species_picture"
ORG_PARAM_DESC_MAIN_SPECIES = "main_species"
ORG_PARAM_DATA = "data"
ORG_PARAM_DATA_GENOME_PATH = "genome_path"
......@@ -23,6 +24,7 @@ ORG_PARAM_DATA_PERFORMED_BY = "performed_by"
ORG_PARAM_SERVICES = "services"
ORG_PARAM_SERVICES_BLAST = "blast"
# Constants used in the config yaml file
CONF_ALL_HOSTNAME = "hostname"
CONF_ALL_HTTP_PORT = "http_port"
......
......@@ -76,6 +76,21 @@ class DeploySpeciesStack(speciesData.SpeciesData):
logging.debug("Using default banner for Tripal pages")
self.config.pop(constants.CONF_TRIPAL_BANNER_PATH, None)
# Copy the organism picture for tripal if one was specified in the input species
if self.tripal_species_picture is not None:
if self.tripal_species_picture.endswith("png"):
species_picture_dest_path = os.path.join(self.species_dir, os.path.abspath("species.png"))
try:
os.symlink(os.path.abspath(self.tripal_species_picture, species_picture_dest_path))
except FileNotFoundError:
logging.info("Specified organism picture ({0}) not found for {1}".format(self.tripal_species_picture, self.genus_upper + " " + self.species))
elif self.tripal_species_picture.endswith("jpg"):
species_picture_dest_path = os.path.join(self.species_dir, os.path.abspath("species.jpg"))
try:
os.symlink(os.path.abspath(self.tripal_species_picture, species_picture_dest_path))
except FileNotFoundError:
logging.info("Specified organism picture ({0}) not found for {1}".format(self.tripal_species_picture, self.genus_upper + " " + self.species))
# Create nginx dirs and write/re-write nginx conf
make_dirs(dir_paths_li=["./nginx", "./nginx/conf"])
try:
......@@ -111,11 +126,20 @@ class DeploySpeciesStack(speciesData.SpeciesData):
# We need a dict holding all key (variables) - values that needs to be replaced in the template as our rendering dict
# To do so we need both input file vars and config vars
# Create input file vars dict
input_vars = {"genus": self.genus_lowercase, "Genus": self.genus_uppercase, "species": self.species,
"genus_species": self.genus_species, "genus_species_strain_sex": self.species_folder_name,
"genus_species_sex": "{0}_{1}_{2}".format(self.genus_lowercase, self.species.lower(), self.sex),
"strain": self.strain, "sex": self.sex, "Genus_species": self.genus_species[0].upper() + self.genus_species[1:],
"blast": self.blast}
input_vars = {}
if self.tripal_species_picture is not None:
input_vars = {"genus": self.genus_lowercase, "Genus": self.genus_uppercase, "species": self.species,
"genus_species": self.genus_species, "genus_species_strain_sex": self.species_folder_name,
"genus_species_sex": "{0}_{1}_{2}".format(self.genus_lowercase, self.species.lower(), self.sex),
"strain": self.strain, "sex": self.sex, "Genus_species": self.genus_species[0].upper() + self.genus_species[1:],
"blast": self.blast, "tripal_species_picture": self.tripal_species_picture}
else:
input_vars = {"genus": self.genus_lowercase, "Genus": self.genus_uppercase, "species": self.species,
"genus_species": self.genus_species, "genus_species_strain_sex": self.species_folder_name,
"genus_species_sex": "{0}_{1}_{2}".format(self.genus_lowercase, self.species.lower(), self.sex),
"strain": self.strain, "sex": self.sex, "Genus_species": self.genus_species[0].upper() + self.genus_species[1:],
"blast": self.blast}
if (len(self.config.keys()) == 0):
logging.error("Empty config dictionary")
# Merge the two dicts
......
......@@ -91,7 +91,7 @@ class SpeciesData:
if constants.ORG_PARAM_DESC_PICTURE_PATH in parameters_dictionary_description.keys():
self.tripal_species_picture = parameters_dictionary_services[constants.ORG_PARAM_DESC_PICTURE_PATH]
else:
self.tripal_species_picture = ""
self.tripal_species_picture = None
self.genus_lowercase = self.genus[0].lower() + self.genus[1:]
self.genus_uppercase = self.genus[0].upper() + self.genus[1:]
......
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