Salome HOME
See the product pyconf path and used section for a given product when launching the...
[tools/sat.git] / src / product.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 '''In this file are implemented the methods 
19    relative to the product notion of salomeTools
20 '''
21
22 import os
23 import re
24
25 import src
26
27 AVAILABLE_VCS = ['git', 'svn', 'cvs']
28 config_expression = "^config-\d+$"
29 VERSION_DELIMITER = "_to_"
30
31 def get_product_config(config, product_name, with_install_dir=True):
32     '''Get the specific configuration of a product from the global configuration
33     
34     :param config Config: The global configuration
35     :param product_name str: The name of the product
36     :param with_install_dir boolean: If false, do not provide an install 
37                                      directory (at false only for internal use 
38                                      of the function check_config_exists)
39     :return: the specific configuration of the product
40     :rtype: Config
41     '''
42     
43     # Get the version of the product from the application definition
44     version = config.APPLICATION.products[product_name]
45     # if no version, then take the default one defined in the application
46     if isinstance(version, bool): 
47         version = config.APPLICATION.tag      
48     
49     # Define debug and dev modes
50     # Get the tag if a dictionary is given in APPLICATION.products for the
51     # current product 
52     debug = 'no'
53     dev = 'no'
54     base = 'maybe'
55     section = None
56     if isinstance(version, src.pyconf.Mapping):
57         dic_version = version
58         # Get the version/tag
59         if not 'tag' in dic_version:
60             version = config.APPLICATION.tag
61         else:
62             version = dic_version.tag
63         
64         # Get the debug if any
65         if 'debug' in dic_version:
66             debug = dic_version.debug
67         
68         # Get the dev if any
69         if 'dev' in dic_version:
70             dev = dic_version.dev
71         
72         # Get the base if any
73         if 'base' in dic_version:
74             base = dic_version.base
75
76         # Get the section if any
77         if 'section' in dic_version:
78             section = dic_version.section
79     
80     vv = version
81     # substitute some character with _ in order to get the correct definition
82     # in config.PRODUCTS. This is done because the pyconf tool does not handle
83     # the . and - characters 
84     for c in ".-": vv = vv.replace(c, "_")
85     
86     prod_info = None
87     if product_name in config.PRODUCTS:
88         # Search for the product description in the configuration
89         prod_info = get_product_section(config, product_name, vv, section)
90         
91         # merge opt_depend in depend
92         if prod_info is not None and 'opt_depend' in prod_info:
93             for depend in prod_info.opt_depend:
94                 if depend in config.APPLICATION.products:
95                     prod_info.depend.append(depend,'')
96         
97         # In case of a product get with a vcs, 
98         # put the tag (equal to the version)
99         if prod_info is not None and prod_info.get_source in AVAILABLE_VCS:
100             
101             if prod_info.get_source == 'git':
102                 prod_info.git_info.tag = version
103             
104             if prod_info.get_source == 'svn':
105                 prod_info.svn_info.tag = version
106             
107             if prod_info.get_source == 'cvs':
108                 prod_info.cvs_info.tag = version
109         
110         # In case of a fixed product, 
111         # define the install_dir (equal to the version)
112         if prod_info is not None and os.path.isdir(version):
113             prod_info.install_dir = version
114             prod_info.get_source = "fixed"
115         
116         # Check if the product is defined as native in the application
117         if prod_info is not None:
118             if version == "native":
119                 prod_info.get_source = "native"
120             elif prod_info.get_source == "native":
121                 msg = _("The product %(prod)s has version %(ver)s but is "
122                         "declared as native in its definition" %
123                         { 'prod': prod_info.name, 'ver': version})
124                 raise src.SatException(msg)
125
126     # If there is no definition but the product is declared as native,
127     # construct a new definition containing only the get_source key
128     if prod_info is None and version == "native":
129         prod_info = src.pyconf.Config()
130         prod_info.name = product_name
131         prod_info.get_source = "native"
132
133     # If there is no definition but the product is fixed,
134     # construct a new definition containing only the product name
135     if prod_info is None and os.path.isdir(version):
136         prod_info = src.pyconf.Config()
137         prod_info.name = product_name
138         prod_info.get_source = "fixed"
139         prod_info.addMapping("environ", src.pyconf.Mapping(prod_info), "")
140
141
142     # If prod_info is still None, it means that there is no product definition
143     # in the config. The user has to provide it.
144     if prod_info is None:
145         prod_pyconf_path = src.find_file_in_lpath(product_name + ".pyconf",
146                                                   config.PATHS.PRODUCTPATH)
147         if not prod_pyconf_path:
148             msg = _("No definition found for the product %s\n"
149                "Please create a %s.pyconf file." % (product_name, product_name))
150         else:
151             msg = _("No definition corresponding to the version %(version)s was"
152                     " found in the file %(prod_file_path)s.\nPlease add a "
153                     "section in it." % {"version" : vv,
154                                         "prod_file_path" : prod_pyconf_path} )
155         raise src.SatException(msg)
156     
157     # Set the debug, dev and version keys
158     prod_info.debug = debug
159     prod_info.dev = dev
160     prod_info.version = version
161     
162     # Set the archive_info if the product is get in archive mode
163     if prod_info.get_source == "archive":
164         if not "archive_info" in prod_info:
165             prod_info.addMapping("archive_info",
166                                  src.pyconf.Mapping(prod_info),
167                                  "")
168         if "archive_name" not in prod_info.archive_info: 
169             arch_name = product_name + "-" + version + ".tar.gz"
170             arch_path = src.find_file_in_lpath(arch_name,
171                                                config.PATHS.ARCHIVEPATH)
172             if not arch_path:
173                 msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
174                             "\n" % {"arch_name" : arch_name,
175                                      "prod_name" : prod_info.name}) 
176                 raise src.SatException(msg)
177             prod_info.archive_info.archive_name = arch_path
178         else:
179             if (os.path.basename(prod_info.archive_info.archive_name) == 
180                                         prod_info.archive_info.archive_name):
181                 arch_name = prod_info.archive_info.archive_name
182                 arch_path = src.find_file_in_lpath(
183                                             arch_name,
184                                             config.PATHS.ARCHIVEPATH)
185                 if not arch_path:
186                     msg = _("Archive %(arch_name)s for %(prod_name)s not found:"
187                                 "\n" % {"arch_name" : arch_name,
188                                          "prod_name" : prod_info.name}) 
189                     raise src.SatException(msg)
190                 prod_info.archive_info.archive_name = arch_path
191         
192     # If the product compiles with a script, check the script existence
193     # and if it is executable
194     if product_has_script(prod_info):
195         # Check the compil_script key existence
196         if "compil_script" not in prod_info:
197             msg = _("No compilation script found for the product %s\n"
198                 "Please provide a \"compil_script\" key in its definition." 
199                 % (product_name))
200             raise src.SatException(msg)
201         
202         # Get the path of the script
203         script = prod_info.compil_script
204         script_name = os.path.basename(script)
205         if script == script_name:
206             # Only a name is given. Search in the default directory
207             script_path = src.find_file_in_lpath(script_name,
208                                                  config.PATHS.PRODUCTPATH,
209                                                  "compil_scripts")
210             if not script_path:
211                 raise src.SatException(_("Compilation script not found: %s") % 
212                                    script_name)
213             prod_info.compil_script = script_path
214             if src.architecture.is_windows():
215                 prod_info.compil_script = prod_info.compil_script[:-len(".sh")] + ".bat"
216        
217         # Check that the script is executable
218         if not os.access(prod_info.compil_script, os.X_OK):
219             raise src.SatException(
220                     _("Compilation script cannot be executed: %s") % 
221                     prod_info.compil_script)
222     
223     # Get the full paths of all the patches
224     if product_has_patches(prod_info):
225         patches = []
226         for patch in prod_info.patches:
227             patch_path = patch
228             # If only a filename, then search for the patch in the PRODUCTPATH
229             if os.path.basename(patch_path) == patch_path:
230                 # Search in the PRODUCTPATH/patches
231                 patch_path = src.find_file_in_lpath(patch,
232                                                     config.PATHS.PRODUCTPATH,
233                                                     "patches")
234                 if not patch_path:
235                     msg = _("Patch %(patch_name)s for %(prod_name)s not found:"
236                             "\n" % {"patch_name" : patch,
237                                      "prod_name" : prod_info.name}) 
238                     raise src.SatException(msg)
239             patches.append(patch_path)
240         prod_info.patches = patches
241
242     # Get the full paths of the environment scripts
243     if product_has_env_script(prod_info):
244         env_script_path = prod_info.environ.env_script
245         # If only a filename, then search for the environment script 
246         # in the PRODUCTPATH/env_scripts
247         if os.path.basename(env_script_path) == env_script_path:
248             # Search in the PRODUCTPATH/env_scripts
249             env_script_path = src.find_file_in_lpath(
250                                             prod_info.environ.env_script,
251                                             config.PATHS.PRODUCTPATH,
252                                             "env_scripts")
253             if not env_script_path:
254                 msg = _("Environment script %(env_name)s for %(prod_name)s not "
255                         "found.\n" % {"env_name" : env_script_path,
256                                        "prod_name" : prod_info.name}) 
257                 raise src.SatException(msg)
258
259         prod_info.environ.env_script = env_script_path
260     
261     if with_install_dir: 
262         # The variable with_install_dir is at false only for internal use 
263         # of the function get_install_dir
264         
265         # Save the install_dir key if there is any
266         if "install_dir" in prod_info and not "install_dir_save" in prod_info:
267             prod_info.install_dir_save = prod_info.install_dir
268         
269         # if it is not the first time the install_dir is computed, it means
270         # that install_dir_save exists and it has to be taken into account.
271         if "install_dir_save" in prod_info:
272             prod_info.install_dir = prod_info.install_dir_save
273         
274         # Set the install_dir key
275         prod_info.install_dir = get_install_dir(config, base, version, prod_info)
276                 
277     return prod_info
278
279 def get_product_section(config, product_name, version, section=None):
280     '''Get the product description from the configuration
281     
282     :param config Config: The global configuration
283     :param product_name str: The product name
284     :param version str: The version of the product
285     :param section str: The searched section (if not None, the section is 
286                         explicitly given
287     :return: The product description
288     :rtype: Config
289     '''
290
291     # if section is not None, try to get the corresponding section
292     if section:
293         if section not in config.PRODUCTS[product_name]:
294             return None
295         # returns specific information for the given version
296         prod_info = config.PRODUCTS[product_name][section]
297         prod_info.section = section
298         prod_info.from_file = config.PRODUCTS[product_name].from_file
299         return prod_info
300
301     # If it exists, get the information of the product_version
302     if "version_" + version in config.PRODUCTS[product_name]:
303         # returns specific information for the given version
304         prod_info = config.PRODUCTS[product_name]["version_" + version]
305         prod_info.section = "version_" + version
306         prod_info.from_file = config.PRODUCTS[product_name].from_file
307         return prod_info
308     
309     # Else, check if there is a description for multiple versions
310     l_section_name = config.PRODUCTS[product_name].keys()
311     l_section_ranges = [section_name for section_name in l_section_name 
312                         if VERSION_DELIMITER in section_name]
313     for section_range in l_section_ranges:
314         minimum, maximum = section_range.split(VERSION_DELIMITER)
315         if (src.only_numbers(version) >= src.only_numbers(minimum)
316                     and src.only_numbers(version) <= src.only_numbers(maximum)):
317             # returns specific information for the versions
318             prod_info = config.PRODUCTS[product_name][section_range]
319             prod_info.section = section_range
320             prod_info.from_file = config.PRODUCTS[product_name].from_file
321             return prod_info
322     
323     # Else, get the standard informations
324     if "default" in config.PRODUCTS[product_name]:
325         # returns the generic information (given version not found)
326         prod_info = config.PRODUCTS[product_name].default
327         prod_info.section = "default"
328         prod_info.from_file = config.PRODUCTS[product_name].from_file
329         return prod_info
330     
331     # if noting was found, return None
332     return None
333     
334 def get_install_dir(config, base, version, prod_info):
335     '''Compute the installation directory of a given product 
336     
337     :param config Config: The global configuration
338     :param base str: This corresponds to the value given by user in its 
339                      application.pyconf for the specific product. If "yes", the
340                     user wants the product to be in base. If "no", he wants the
341                     product to be in the application workdir
342     :param version str: The version of the product
343     :param product_info Config: The configuration specific to 
344                                the product
345     
346     :return: The path of the product installation
347     :rtype: str
348     '''
349     install_dir = ""
350     in_base = False
351     if (("install_dir" in prod_info and prod_info.install_dir == "base") 
352                                                             or base == "yes"):
353         in_base = True
354     if (base == "no" or ("no_base" in config.APPLICATION 
355                          and config.APPLICATION.no_base == "yes")):
356         in_base = False
357     
358     if in_base:
359         install_dir = get_base_install_dir(config, prod_info, version)
360     else:
361         if "install_dir" not in prod_info or prod_info.install_dir == "base":
362             # Set it to the default value (in application directory)
363             install_dir = os.path.join(config.APPLICATION.workdir,
364                                                 "INSTALL",
365                                                 prod_info.name)
366         else:
367             install_dir = prod_info.install_dir
368
369     return install_dir
370
371 def get_base_install_dir(config, prod_info, version):
372     '''Compute the installation directory of a product in base 
373     
374     :param config Config: The global configuration
375     :param product_info Config: The configuration specific to 
376                                the product
377     :param version str: The version of the product    
378     :return: The path of the product installation
379     :rtype: str
380     '''    
381     base_path = src.get_base_path(config) 
382     prod_dir = os.path.join(base_path, prod_info.name + "-" + version)
383     if not os.path.exists(prod_dir):
384         return os.path.join(prod_dir, "config-1")
385     
386     exists, install_dir = check_config_exists(config, prod_dir, prod_info)
387     if exists:
388         return install_dir
389     
390     # Find the first config-<i> directory that is available in the product
391     # directory
392     found = False 
393     label = 1
394     while not found:
395         install_dir = os.path.join(prod_dir, "config-%i" % label)
396         if os.path.exists(install_dir):
397             label+=1
398         else:
399             found = True
400             
401     return install_dir
402
403 def check_config_exists(config, prod_dir, prod_info):
404     '''Verify that the installation directory of a product in a base exists
405        Check all the config-<i> directory and verify the sat-config.pyconf file
406        that is in it 
407     
408     :param config Config: The global configuration
409     :param prod_dir str: The product installation directory path 
410                          (without config-<i>)
411     :param product_info Config: The configuration specific to 
412                                the product
413     :return: True or false is the installation is found or not 
414              and if it is found, the path of the found installation
415     :rtype: (boolean, str)
416     '''   
417     # check if the directories or files of the directory corresponds to the 
418     # directory installation of the product
419     l_dir_and_files = os.listdir(prod_dir)
420     for dir_or_file in l_dir_and_files:
421         oExpr = re.compile(config_expression)
422         if not(oExpr.search(dir_or_file)):
423             # not config-<i>, not interesting
424             continue
425         # check if there is the file sat-config.pyconf file in the installation
426         # directory    
427         config_file = os.path.join(prod_dir, dir_or_file, src.CONFIG_FILENAME)
428         if not os.path.exists(config_file):
429             continue
430         
431         # If there is no dependency, it is the right path
432         if len(prod_info.depend)==0:
433             compile_cfg = src.pyconf.Config(config_file)
434             if len(compile_cfg) == 0:
435                 return True, os.path.join(prod_dir, dir_or_file)
436             continue
437         
438         # check if there is the config described in the file corresponds the 
439         # dependencies of the product
440         config_corresponds = True    
441         compile_cfg = src.pyconf.Config(config_file)
442         for prod_dep in prod_info.depend:
443             # if the dependency is not in the config, 
444             # the config does not correspond
445             if prod_dep not in compile_cfg:
446                 config_corresponds = False
447                 break
448             else:
449                 prod_dep_info = get_product_config(config, prod_dep, False)
450                 # If the version of the dependency does not correspond, 
451                 # the config does not correspond
452                 if prod_dep_info.version != compile_cfg[prod_dep]:
453                     config_corresponds = False
454                     break
455         
456         for prod_name in compile_cfg:
457             if prod_name not in prod_info.depend:
458                 config_corresponds = False
459                 break
460         
461         if config_corresponds:
462             return True, os.path.join(prod_dir, dir_or_file)
463     
464     return False, None
465             
466             
467     
468 def get_products_infos(lproducts, config):
469     '''Get the specific configuration of a list of products
470     
471     :param lproducts List: The list of product names
472     :param config Config: The global configuration
473     :return: the list of tuples 
474              (product name, specific configuration of the product)
475     :rtype: [(str, Config)]
476     '''
477     products_infos = []
478     # Loop on product names
479     for prod in lproducts:       
480         # Get the specific configuration of the product
481         prod_info = get_product_config(config, prod)
482         if prod_info is not None:
483             products_infos.append((prod, prod_info))
484         else:
485             msg = _("The %s product has no definition "
486                     "in the configuration.") % prod
487             raise src.SatException(msg)
488     return products_infos
489
490 def get_product_dependencies(config, product_info):
491     '''Get recursively the list of products that are 
492        in the product_info dependencies
493     
494     :param config Config: The global configuration
495     :param product_info Config: The configuration specific to 
496                                the product
497     :return: the list of products in dependence
498     :rtype: list
499     '''
500     if "depend" not in product_info or product_info.depend == []:
501         return []
502     res = []
503     for prod in product_info.depend:
504         if prod == product_info.name:
505             continue
506         if prod not in res:
507             res.append(prod)
508         prod_info = get_product_config(config, prod)
509         dep_prod = get_product_dependencies(config, prod_info)
510         for prod_in_dep in dep_prod:
511             if prod_in_dep not in res:
512                 res.append(prod_in_dep)
513     return res
514
515 def check_installation(product_info):
516     '''Verify if a product is well installed. Checks install directory presence
517        and some additional files if it is defined in the config 
518     
519     :param product_info Config: The configuration specific to 
520                                the product
521     :return: True if it is well installed
522     :rtype: boolean
523     '''
524     if not product_compiles(product_info):
525         return True
526     install_dir = product_info.install_dir
527     if not os.path.exists(install_dir):
528         return False
529     if ("present_files" in product_info and 
530         "install" in product_info.present_files):
531         for file_relative_path in product_info.present_files.install:
532             file_path = os.path.join(install_dir, file_relative_path)
533             if not os.path.exists(file_path):
534                 return False
535     return True
536
537 def product_is_sample(product_info):
538     '''Know if a product has the sample type
539     
540     :param product_info Config: The configuration specific to 
541                                the product
542     :return: True if the product has the sample type, else False
543     :rtype: boolean
544     '''
545     if 'type' in product_info:
546         ptype = product_info.type
547         return ptype.lower() == 'sample'
548     else:
549         return False
550
551 def product_is_salome(product_info):
552     '''Know if a product is of type salome
553     
554     :param product_info Config: The configuration specific to 
555                                the product
556     :return: True if the product is salome, else False
557     :rtype: boolean
558     '''
559     if 'type' in product_info:
560         ptype = product_info.type
561         return ptype.lower() == 'salome'
562     else:
563         return False
564
565 def product_is_fixed(product_info):
566     '''Know if a product is fixed
567     
568     :param product_info Config: The configuration specific to 
569                                the product
570     :return: True if the product is fixed, else False
571     :rtype: boolean
572     '''
573     get_src = product_info.get_source
574     return get_src.lower() == 'fixed'
575
576 def product_is_native(product_info):
577     '''Know if a product is native
578     
579     :param product_info Config: The configuration specific to 
580                                the product
581     :return: True if the product is native, else False
582     :rtype: boolean
583     '''
584     get_src = product_info.get_source
585     return get_src.lower() == 'native'
586
587 def product_is_dev(product_info):
588     '''Know if a product is in dev mode
589     
590     :param product_info Config: The configuration specific to 
591                                the product
592     :return: True if the product is in dev mode, else False
593     :rtype: boolean
594     '''
595     dev = product_info.dev
596     return dev.lower() == 'yes'
597
598 def product_is_debug(product_info):
599     '''Know if a product is in debug mode
600     
601     :param product_info Config: The configuration specific to 
602                                the product
603     :return: True if the product is in debug mode, else False
604     :rtype: boolean
605     '''
606     debug = product_info.debug
607     return debug.lower() == 'yes'
608
609 def product_is_autotools(product_info):
610     '''Know if a product is compiled using the autotools
611     
612     :param product_info Config: The configuration specific to 
613                                the product
614     :return: True if the product is autotools, else False
615     :rtype: boolean
616     '''
617     build_src = product_info.build_source
618     return build_src.lower() == 'autotools'
619
620 def product_is_cmake(product_info):
621     '''Know if a product is compiled using the cmake
622     
623     :param product_info Config: The configuration specific to 
624                                the product
625     :return: True if the product is cmake, else False
626     :rtype: boolean
627     '''
628     build_src = product_info.build_source
629     return build_src.lower() == 'cmake'
630
631 def product_is_vcs(product_info):
632     '''Know if a product is download using git, svn or cvs (not archive)
633     
634     :param product_info Config: The configuration specific to 
635                                the product
636     :return: True if the product is vcs, else False
637     :rtype: boolean
638     '''
639     return product_info.get_source in AVAILABLE_VCS
640
641 def product_is_SALOME(product_info):
642     '''Know if a product is a SALOME module
643     
644     :param product_info Config: The configuration specific to 
645                                the product
646     :return: True if the product is a SALOME module, else False
647     :rtype: boolean
648     '''
649     return ("properties" in product_info and
650             "is_SALOME_module" in product_info.properties and
651             product_info.properties.is_SALOME_module == "yes")
652
653 def product_is_smesh_plugin(product_info):
654     '''Know if a product is a SMESH plugin
655     
656     :param product_info Config: The configuration specific to 
657                                the product
658     :return: True if the product is a SMESH plugin, else False
659     :rtype: boolean
660     '''
661     return ("properties" in product_info and
662             "smesh_plugin" in product_info.properties and
663             product_info.properties.smesh_plugin == "yes")
664
665 def product_is_cpp(product_info):
666     '''Know if a product is cpp
667     
668     :param product_info Config: The configuration specific to 
669                                the product
670     :return: True if the product is a cpp, else False
671     :rtype: boolean
672     '''
673     return ("properties" in product_info and
674             "cpp" in product_info.properties and
675             product_info.properties.cpp == "yes")
676
677 def product_compiles(product_info):
678     '''Know if a product compiles or not (some products do not have a 
679        compilation procedure)
680     
681     :param product_info Config: The configuration specific to 
682                                the product
683     :return: True if the product compiles, else False
684     :rtype: boolean
685     '''
686     return not("properties" in product_info and
687             "compilation" in product_info.properties and
688             product_info.properties.compilation == "no")
689
690 def product_has_script(product_info):
691     '''Know if a product has a compilation script
692     
693     :param product_info Config: The configuration specific to 
694                                the product
695     :return: True if the product it has a compilation script, else False
696     :rtype: boolean
697     '''
698     if "build_source" not in product_info:
699         # Native case
700         return False
701     build_src = product_info.build_source
702     return build_src.lower() == 'script'
703
704 def product_has_env_script(product_info):
705     '''Know if a product has an environment script
706     
707     :param product_info Config: The configuration specific to 
708                                the product
709     :return: True if the product it has an environment script, else False
710     :rtype: boolean
711     '''
712     return "environ" in product_info and "env_script" in product_info.environ
713
714 def product_has_patches(product_info):
715     '''Know if a product has one or more patches
716     
717     :param product_info Config: The configuration specific to 
718                                the product
719     :return: True if the product has one or more patches
720     :rtype: boolean
721     '''
722     return "patches" in product_info and len(product_info.patches) > 0
723
724 def product_has_logo(product_info):
725     '''Know if a product has a logo (YACSGEN generate)
726     
727     :param product_info Config: The configuration specific to 
728                                the product
729     :return: The path of the logo if the product has a logo, else False
730     :rtype: Str
731     '''
732     if ("properties" in product_info and
733             "logo" in product_info.properties):
734         return product_info.properties.logo
735     else:
736         return False
737
738 def product_has_salome_gui(product_info):
739     '''Know if a product has a SALOME gui
740     
741     :param product_info Config: The configuration specific to 
742                                the product
743     :return: True if the product has a SALOME gui, else False
744     :rtype: Boolean
745     '''
746     return ("properties" in product_info and
747             "has_salome_gui" in product_info.properties and
748             product_info.properties.has_salome_gui == "yes")
749
750 def product_is_mpi(product_info):
751     '''Know if a product has openmpi in its dependencies
752     
753     :param product_info Config: The configuration specific to 
754                                the product
755     :return: True if the product has openmpi inits dependencies
756     :rtype: boolean
757     '''
758     return "openmpi" in product_info.depend
759
760 def product_is_generated(product_info):
761     '''Know if a product is generated (YACSGEN)
762     
763     :param product_info Config: The configuration specific to 
764                                the product
765     :return: True if the product is generated
766     :rtype: boolean
767     '''
768     return ("properties" in product_info and
769             "generate" in product_info.properties and
770             product_info.properties.generate == "yes")
771
772 def get_product_components(product_info):
773     '''Get the component list to generate with the product
774     
775     :param product_info Config: The configuration specific to 
776                                the product
777     :return: The list of names of the components
778     :rtype: List
779     
780     '''
781     if not product_is_generated(product_info):
782         return []
783     
784     compo_list = []
785     if "component_name" in product_info:
786         compo_list = product_info.component_name
787     
788         if isinstance(compo_list, str):
789             compo_list = [ compo_list ]
790
791     return compo_list