X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=commands%2Fapplication.py;h=f700febbbbcf18cb47877603205b146a6e2179f6;hb=620d5d2e941088d41984043bb7fae889da5a52b1;hp=ddb3bb7617006f91fd6302bca8f701d1e7890116;hpb=fc5d1238d59d8ca3b07275512cecf58bd3d8224a;p=tools%2Fsat.git diff --git a/commands/application.py b/commands/application.py index ddb3bb7..f700feb 100644 --- a/commands/application.py +++ b/commands/application.py @@ -42,6 +42,9 @@ parser.add_option('', 'gencat', 'string', 'gencat', parser.add_option('m', 'module', 'list2', 'modules', _("Optional: the restricted list of module(s) to include in the " "application")) +parser.add_option('', 'use_mesa', 'boolean', 'use_mesa', + _("Optional: Create a launcher that will use mesa products\n\t" + "It can be usefull whan salome is used on a remote machine through ssh")) ## # Creates an alias for runAppli. @@ -69,7 +72,7 @@ def add_module_to_appli(out, module, has_gui, module_path, logger, flagline): ## # Creates the config file to create an application with the list of modules. -def create_config_file(config, modules, env_file, logger): +def create_config_file(config, modules, env_files, logger): samples = "" if 'SAMPLES' in config.APPLICATION.products: @@ -79,16 +82,25 @@ def create_config_file(config, modules, env_file, logger): f = open(config_file, "w") f.write('\n') - if env_file.endswith("cfg"): - f.write('\n' % env_file) - else: - f.write('\n' % env_file) + for env_file in env_files: + if env_file.endswith("cfg"): + f.write('\n' % env_file) + else: + f.write('\n' % env_file) + f.write('\n') f.write('\n') flagline = False for m in modules: mm = src.product.get_product_config(config, m) + # do not include in virtual application application module! + if src.get_property_in_product_cfg(mm, "is_salome_application") == "yes": + continue + # do not include products that do not compile + if not src.product.product_compiles(mm): + continue + #obsolete? if src.product.product_is_smesh_plugin(mm): continue @@ -234,7 +246,7 @@ def create_application(config, appli_dir, catalog, logger, display=True): SALOME_modules) if retcode == 0: - cmd = src.printcolors.printcLabel("%s/runAppli" % appli_dir) + cmd = src.printcolors.printcLabel("%s/salome" % appli_dir) if display: logger.write("\n", 3, False) @@ -247,7 +259,7 @@ def get_SALOME_modules(config): l_modules = [] for product in config.APPLICATION.products: product_info = src.product.get_product_config(config, product) - if (src.product.product_is_SALOME(product_info) or + if (src.product.product_is_salome(product_info) or src.product.product_is_generated(product_info)): l_modules.append(product) return l_modules @@ -263,6 +275,18 @@ def generate_launch_file(config, appli_dir, catalog, logger, l_SALOME_modules): write_step(logger, _("Creating environment files")) status = src.KO_STATUS + + # build the application (the name depends upon salome version + env_file = os.path.join(config.APPLICATION.workdir, "env_launch") + VersionSalome = src.get_salome_version(config) + if VersionSalome>=820: + # for salome 8+ we use a salome context file for the virtual app + app_shell=["cfg", "bash"] + env_files=[env_file+".cfg", env_file+".sh"] + else: + app_shell=["bash"] + env_files=[env_file+".sh"] + try: import environ # generate only shells the user wants (by default bash, csh, batch) @@ -270,19 +294,15 @@ def generate_launch_file(config, appli_dir, catalog, logger, l_SALOME_modules): # with the current system. environ.write_all_source_files(config, logger, + shells=app_shell, silent=True) status = src.OK_STATUS finally: logger.write(src.printcolors.printc(status) + "\n", 2, False) - # build the application (the name depends upon salome version - # for salome 8 we use a salome context file - VersionSalome = src.get_salome_version(config) - env_ext="cfg" if VersionSalome>=820 else "sh" - env_file = os.path.join(config.APPLICATION.workdir, "env_launch.cfg") write_step(logger, _("Building application"), level=2) - cf = create_config_file(config, l_SALOME_modules, env_file, logger) + cf = create_config_file(config, l_SALOME_modules, env_files, logger) # create the application directory os.makedirs(appli_dir) @@ -322,36 +342,41 @@ def generate_catalog(machines, config, logger): catalog = file(catfile, "w") catalog.write("\n\n") for k in machines: - logger.write(" ssh %s " % (k + " ").ljust(20, '.'), 4) - logger.flush() - - 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() - - if p.returncode != 0: - logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4) - logger.write(" " + src.printcolors.printcWarning(p.stderr.read()), - 2) - else: - 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 + if not src.architecture.is_windows(): + logger.write(" ssh %s " % (k + " ").ljust(20, '.'), 4) + logger.flush() + + 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: + logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4) + logger.write(" " + src.printcolors.printcWarning(p.stderr.read()), + 2) + else: + 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("