parser.add_option('e', 'exe', 'string', 'path_exe', _('Use this option to generate a launcher which sets'
' the environment and call the executable given as argument'
' (its relative path to application workdir, or an exe name present in appli PATH)'))
+parser.add_option('p', 'products', 'list2', 'products',
+ _("Optional: Includes only the specified products."))
parser.add_option('c', 'catalog', 'string', 'catalog',
_('Optional: The resources catalog to use'))
parser.add_option('', 'gencat', 'string', 'gencat',
launcher_name,
pathlauncher,
path_exe,
+ env_info,
display=True,
additional_env={},
no_path_init=False):
:param display boolean: If False, do not print anything in the terminal
:param additional_env dict: The dict giving additional
environment variables
+ :param env_info str: The list of products to add in the files.
:return: The launcher file path.
:rtype: str
'''
for prod_name, prod_info in l_product_info:
# look for a salome application
if src.get_property_in_product_cfg(prod_info, "is_salome_application") == "yes":
- salome_application_name=prod_info.install_dir
+ # if user choose -p option (env_info not None), the set appli name only if product was selected.
+ if env_info == None or ( prod_name in env_info):
+ salome_application_name=prod_info.install_dir
continue
# if the application contains an application module, we set ABSOLUTE_APPLI_PATH to it.
writer = src.environment.FileEnvWriter(config,
logger,
pathlauncher,
- src_root=None,
- env_info=None)
+ None,
+ env_info)
# Display some information
if display:
# Create the catalog path
catfile = src.get_tmp_filename(config, "CatalogResources.xml")
- catalog = file(catfile, "w")
-
- # Write into it
- catalog.write("<!DOCTYPE ResourcesCatalog>\n<resources>\n")
- for k in machines:
- if not src.architecture.is_windows():
- logger.write(" ssh %s " % (k + " ").ljust(20, '.'), 4)
- logger.flush()
-
- # Verify that the machine is accessible
- ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
- p = subprocess.Popen(ssh_cmd, shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- p.wait()
-
- machine_access = (p.returncode == 0)
- if not machine_access: # The machine is not accessible
- logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4)
- logger.write(" " +
- src.printcolors.printcWarning(p.stderr.read()), 2)
- else:
- # The machine is accessible, write the corresponding section on
- # the xml file
- logger.write(src.printcolors.printc(src.OK_STATUS) + "\n", 4)
- lines = p.stdout.readlines()
- freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
- nb_proc = len(lines) -1
- memory = lines[-1].split(':')[-1].split()[0].strip()
- memory = int(memory) / 1000
-
- catalog.write(" <machine\n")
- catalog.write(" protocol=\"ssh\"\n")
- catalog.write(" nbOfNodes=\"1\"\n")
- catalog.write(" mode=\"interactif\"\n")
- catalog.write(" OS=\"LINUX\"\n")
-
- if (not src.architecture.is_windows()) and machine_access :
- catalog.write(" CPUFreqMHz=\"%s\"\n" % freq)
- catalog.write(" nbOfProcPerNode=\"%s\"\n" % nb_proc)
- catalog.write(" memInMB=\"%s\"\n" % memory)
-
- catalog.write(" userName=\"%s\"\n" % user)
- catalog.write(" name=\"%s\"\n" % k)
- catalog.write(" hostname=\"%s\"\n" % k)
- catalog.write(" >\n")
- catalog.write(" </machine>\n")
-
- catalog.write("</resources>\n")
- catalog.close()
+ with open(catfile, 'w') as catalog:
+ # Write into it
+ catalog.write("<!DOCTYPE ResourcesCatalog>\n<resources>\n")
+ for k in machines:
+ if not src.architecture.is_windows():
+ logger.write(" ssh %s " % (k + " ").ljust(20, '.'), 4)
+ logger.flush()
+
+ # Verify that the machine is accessible
+ ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
+ p = subprocess.Popen(ssh_cmd, shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ p.wait()
+
+ machine_access = (p.returncode == 0)
+ if not machine_access: # The machine is not accessible
+ logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4)
+ logger.write(" " +
+ src.printcolors.printcWarning(p.stderr.read()), 2)
+ else:
+ # The machine is accessible, write the corresponding section on
+ # the xml file
+ logger.write(src.printcolors.printc(src.OK_STATUS) + "\n", 4)
+ lines = p.stdout.readlines()
+ freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
+ nb_proc = len(lines) -1
+ memory = lines[-1].split(':')[-1].split()[0].strip()
+ memory = int(memory) / 1000
+
+ catalog.write(" <machine\n")
+ catalog.write(" protocol=\"ssh\"\n")
+ catalog.write(" nbOfNodes=\"1\"\n")
+ catalog.write(" mode=\"interactif\"\n")
+ catalog.write(" OS=\"LINUX\"\n")
+
+ if (not src.architecture.is_windows()) and machine_access :
+ catalog.write(" CPUFreqMHz=\"%s\"\n" % freq)
+ catalog.write(" nbOfProcPerNode=\"%s\"\n" % nb_proc)
+ catalog.write(" memInMB=\"%s\"\n" % memory)
+
+ catalog.write(" userName=\"%s\"\n" % user)
+ catalog.write(" name=\"%s\"\n" % k)
+ catalog.write(" hostname=\"%s\"\n" % k)
+ catalog.write(" >\n")
+ catalog.write(" </machine>\n")
+
+ catalog.write("</resources>\n")
return catfile
def copy_catalog(config, catalog_path):
src.check_config_has_application( runner.cfg )
# Determine the launcher name (from option, profile section or by default "salome")
+ if options.products is None:
+ environ_info = None
+ else:
+ # add products specified by user (only products
+ # included in the application)
+ environ_info = filter(lambda l:
+ l in runner.cfg.APPLICATION.products.keys(),
+ options.products)
if options.name:
launcher_name = options.name
else:
launcher_path,
options.path_exe,
additional_env = additional_environ,
+ env_info=environ_info,
no_path_init = no_path_initialisation )
return 0