_("do not get sources from sample modules."))
def apply_patch(config, module_info, logger):
+ '''The method called to apply patches on a module
+
+ :param config Config: The global configuration
+ :param module_info Config: The configuration specific to
+ the module to be prepared
+ :param logger Logger: The logger instance to use for the display and logging
+ :return: (True if it succeed, else False, message to display)
+ :rtype: (boolean, str)
+ '''
+
if not "patches" in module_info or len(module_info.patches) == 0:
msg = _("No patch for the %s module") % module_info.name
logger.write(msg, 3)
logger.write(src.printcolors.printcWarning(msg), 1)
return False, ""
+ # At this point, there one or more patches and the source directory exists
retcode = []
res = []
+ # Loop on all the patches of the module
for patch in module_info.patches:
details = []
-
- if os.path.isfile(patch) and patch.endswith(".patch"):
+
+ # Check the existence and apply the patch
+ if os.path.isfile(patch):
#patch_exe = "patch" # old patch command (now replace by patch.py)
patch_exe = os.path.join(config.VARS.srcDir, "patching.py")
patch_cmd = "python %s -p1 -- < %s" % (patch_exe, patch)
for m in modules:
if m not in runner.cfg.APPLICATION.modules:
raise src.SatException(_("Module %(module)s "
- "not defined in appplication %(application)s") %
+ "not defined in application %(application)s") %
{ 'module': m, 'application': runner.cfg.VARS.application} )
# Construct the list of tuple containing
--- /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 src
+
+# Define all possible option for log command : sat log <options>
+parser = src.options.Options()
+parser.add_option('m', 'module', 'list2', 'modules',
+ _('modules to prepare. This option can be'
+ ' passed several time to prepare several modules.'))
+parser.add_option('', 'no_sample', 'boolean', 'no_sample',
+ _("do not prepare sample modules."))
+parser.add_option('f', 'force', 'boolean', 'force',
+ _("force to prepare the modules in development mode."))
+
+def description():
+ '''method that is called when salomeTools is called with --help option.
+
+ :return: The text to display for the prepare command description.
+ :rtype: str
+ '''
+ return _("The prepare command apply the patches on the sources of "
+ "the application modules if there is any")
+
+def run(args, runner, logger):
+ '''method that is called when salomeTools is called with prepare parameter.
+ '''
+
+ # Parse the options
+ (options, args) = parser.parse_args(args)
+
+ # check that the command has been called with an application
+ src.check_config_has_application( runner.cfg )
+
+ # Construct the option to pass to the source command
+ args_source = runner.cfg.VARS.application + ' '
+
+ if options.modules:
+ args_source += '--module ' + ','.join(options.modules)
+
+ if options.no_sample:
+ args_source += ' --no_sample'
+
+ if options.force:
+ args_source += ' --force'
+
+ # Call the source command that gets the source
+ msg = src.printcolors.printcHeader(
+ _('Get the sources of the desired modules\n'))
+ logger.write(msg)
+ res_source = runner.source(args_source)
+
+ # Construct the option to pass to the patch command
+ args_patch = args_source.replace(' --force', '')
+
+ # Call the source command that gets the source
+ msg = src.printcolors.printcHeader(
+ _('\nApply the patches to the sources of the modules\n'))
+ logger.write(msg)
+ res_patch = runner.patch(args_patch)
+
+ return res_source + res_patch
\ No newline at end of file
parser.add_option('f', 'force', 'boolean', 'force',
_("force to get the sources of the modules in development mode."))
-def prepare_for_dev(config, module_info, source_dir, force, logger, pad):
+def get_sources_for_dev(config, module_info, source_dir, force, logger, pad):
'''The method called if the module is in development mode
:param config Config: The global configuration
:rtype: boolean
'''
if not checkout and is_dev:
- return prepare_for_dev(config, module_info, source_dir, force, logger, pad)
+ return get_sources_for_dev(config,
+ module_info,
+ source_dir,
+ force,
+ logger,
+ pad)
if module_info.get_method == "git":
return get_sources_from_git(module_info, source_dir, logger, pad,
src.check_config_has_application( runner.cfg )
# Print some informations
- logger.write(_('Preparing sources of the application %s\n') %
+ logger.write(_('Getting sources of the application %s\n') %
src.printcolors.printcLabel(runner.cfg.VARS.application), 1)
src.printcolors.print_value(logger, 'out_dir',
runner.cfg.APPLICATION.out_dir, 2)
for m in modules:
if m not in runner.cfg.APPLICATION.modules:
raise src.SatException(_("Module %(module)s "
- "not defined in appplication %(application)s") %
+ "not defined in application %(application)s") %
{ 'module': m, 'application': runner.cfg.VARS.application} )
# Construct the list of tuple containing
# if the --no_sample option is invoked, suppress the sample modules from
# the list
if options.no_sample:
- modules_infos = filter(lambda l: not src.module.module_is_sample(l[1]),
- modules_infos)
-
+
+ lmodules_sample = [m for m in modules_infos if src.module.module_is_sample(m[1])]
+
+ modules_infos = [m for m in modules_infos if m not in lmodules_sample]
+
+ if len(lmodules_sample) > 0:
+ logger.write(src.printcolors.printcWarning(_("Ignoring the following sample modules:\n")), 1)
+ for i, module in enumerate(lmodules_sample):
+ end_text = ', '
+ if i+1 == len(lmodules_sample):
+ end_text = '\n'
+
+ logger.write(module[0] + end_text, 1)
+
# Call to the function that gets all the sources
good_result, results = get_all_module_sources(runner.cfg,
modules_infos,
details = []
logger.write("\n", 2, False)
- if good_result == len(modules):
+ if good_result == len(modules_infos):
res_count = "%d / %d" % (good_result, good_result)
else:
status = src.KO_STATUS
if results[module] == 0 or results[module] is None:
details.append(module)
- result = len(modules) - good_result
+ result = len(modules_infos) - good_result
# write results
logger.write(_("Getting sources of the application:"), 1)
:param args str: The directory path containing the commands
'''
argv = args.split(" ")
+ while "" in argv: argv.remove("")
# if it is provided by the command line, get the application
appliToLoad = None