--- /dev/null
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+# Copyright (C) 2010-2012 CEA/DEN
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import subprocess
+
+import src
+
+# Define all possible option for the make command : sat make <options>
+parser = src.options.Options()
+parser.add_option('s', 'sat', 'string', 'sat',
+ _('The salomeTools path to use for the command.'))
+parser.add_option('c', 'command', 'string', 'command',
+ _('The shell command to execute.'), "")
+
+def description():
+ '''method that is called when salomeTools is called with --help option.
+
+ :return: The text to display for the shell command description.
+ :rtype: str
+ '''
+ return _("Executes the shell command passed as argument")
+
+def run(args, runner, logger):
+ '''method that is called when salomeTools is called with shell parameter.
+ '''
+
+ # Parse the options
+ (options, args) = parser.parse_args(args)
+
+ res = subprocess.call(options.command,
+ shell=True,
+ stdout=logger.logTxtFile,
+ stderr=subprocess.STDOUT)
+
+ # Format the result to be 0 (success) or 1 (fail)
+ if res != 0:
+ res = 1
+
+ return res
\ No newline at end of file
# first argument => show available commands
if [[ ${argc} == 1 ]]
then
- opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs --help"
+ opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs shell --help"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
+ shell)
+ opts="--command --sat"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
*) return 0 ;;
esac
gettext.install('salomeTools', os.path.join(satdir, 'src', 'i18n'))
# Get the arguments in a list and remove the empty elements
- argv = args.split(" ")
- if argv != ['']:
- while "" in argv: argv.remove("")
-
+ argv_0 = args.split(" ")
+ if argv_0 != ['']:
+ while "" in argv_0: argv_0.remove("")
+
+ # Format the argv list in order to prevent strings
+ # that contain a blank to be separated
+ argv = []
+ elem_old = ""
+ for elem in argv_0:
+ if argv == [] or elem_old.startswith("-") or elem.startswith("-"):
+ argv.append(elem)
+ else:
+ argv[-1] += " " + elem
+ elem_old = elem
+
# if it is provided by the command line, get the application
appliToLoad = None
if argv != [''] and argv[0][0] != "-":