3 # Copyright (C) 2010-2013 CEA/DEN
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.
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.
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
26 '''method that is called when salomeTools is called with --help option.
28 :return: The text to display for the run command description.
31 return _("This command runs the application launcher"
32 " with the given arguments.\n\nexample:\nsat run SALOME-master")
34 def run(args, runner, logger):
35 '''method that is called when salomeTools is called with run parameter.
39 src.check_config_has_application(runner.cfg)
41 # Determine launcher path
42 launcher_name = src.get_launcher_name(runner.cfg)
43 launcher_dir = runner.cfg.APPLICATION.workdir
45 # Check the launcher existence
46 if launcher_name not in os.listdir(launcher_dir):
47 message = _("The launcher %s was not found in directory %s!\nDid you run the"
48 " command 'sat launcher' ?\n") % (launcher_name, launcher_dir)
49 raise src.SatException(message)
51 launcher_path = os.path.join(launcher_dir, launcher_name)
53 if not os.path.exists(launcher_path):
54 message = _("The launcher at path %s is missing.\nDid you run the"
55 " command 'sat launcher' ?\n") % launcher_path
56 raise src.SatException(message)
58 # Determine the command to launch (add the additional arguments)
59 command = launcher_path + " " + " ".join(args)
62 src.printcolors.print_value(logger, _("Executed command"), command, 2)
63 logger.write(_("Launching ...\n"))
67 subprocess.call(command,
69 stdout=logger.logTxtFile,
70 stderr=subprocess.STDOUT)
72 # Display information : how to get the logs
73 messageFirstPart = _("\nEnd of execution. To see the traces, "
74 "please tap the following command :\n")
75 messageSecondPart = src.printcolors.printcLabel(
76 runner.cfg.VARS.salometoolsway +
79 runner.cfg.VARS.application + "\n")
80 logger.write(" %s\n" %(messageFirstPart + messageSecondPart), 2)