--- /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
+
+import prepare
+
+# Compatibility python 2/3 for input function
+# input stays input for python 3 and input = raw_input for python 2
+try:
+ input = raw_input
+except NameError:
+ pass
+
+# Define all possible option for the clean command : sat clean <options>
+parser = src.options.Options()
+parser.add_option('p', 'products', 'list2', 'products',
+ _('products to clean. This option can be'
+ ' passed several time to clean several products.'))
+parser.add_option('s', 'source', 'boolean', 'source',
+ _("Clean the product source directories."))
+parser.add_option('b', 'build', 'boolean', 'build',
+ _("Clean the product build directories."))
+parser.add_option('i', 'install', 'boolean', 'install',
+ _("Clean the product install directories."))
+parser.add_option('a', 'all', 'boolean', 'all',
+ _("Clean the product source, build and install directories."))
+parser.add_option('', 'sources_without_dev', 'boolean', 'sources_without_dev',
+ _("do not clean the products in development mode."))
+
+def get_source_directories(products_infos, without_dev):
+ '''Returns the list of directory source paths corresponding to the list of
+ product information given as input. If without_dev (bool), then
+ the dev products are ignored.
+
+ :param products_infos list: The list of (name, config) corresponding to one
+ product.
+ :param without_dev boolean: If True, then ignore the dev products.
+ :return: the list of source paths.
+ :rtype: list
+ '''
+ l_dir_source = []
+ for __, product_info in products_infos:
+ if product_has_dir(product_info, without_dev):
+ l_dir_source.append(src.Path(product_info.source_dir))
+ return l_dir_source
+
+def get_build_directories(products_infos):
+ '''Returns the list of directory build paths corresponding to the list of
+ product information given as input.
+
+ :param products_infos list: The list of (name, config) corresponding to one
+ product.
+ :return: the list of build paths.
+ :rtype: list
+ '''
+ l_dir_build = []
+ for __, product_info in products_infos:
+ if product_has_dir(product_info):
+ l_dir_build.append(src.Path(product_info.build_dir))
+ return l_dir_build
+
+def get_install_directories(products_infos):
+ '''Returns the list of directory install paths corresponding to the list of
+ product information given as input.
+
+ :param products_infos list: The list of (name, config) corresponding to one
+ product.
+ :return: the list of install paths.
+ :rtype: list
+ '''
+ l_dir_install = []
+ for __, product_info in products_infos:
+ if product_has_dir(product_info):
+ l_dir_install.append(src.Path(product_info.install_dir))
+ return l_dir_install
+
+def product_has_dir(product_info, without_dev=False):
+ '''Returns a boolean at True if there is a source, build and install
+ directory corresponding to the product described by product_info.
+
+ :param products_info Config: The config corresponding to the product.
+ :return: True if there is a source, build and install
+ directory corresponding to the product described by product_info.
+ :rtype: boolean
+ '''
+ if (src.product.product_is_native(product_info) or
+ src.product.product_is_fixed(product_info)):
+ return False
+ if without_dev:
+ if src.product.product_is_dev(product_info):
+ return False
+ return True
+
+def suppress_directories(l_paths, logger):
+ '''Suppress the paths given in the list in l_paths.
+
+ :param l_paths list: The list of Path to be suppressed
+ :param logger Logger: The logger instance to use for the display and
+ logging
+ '''
+ for path in l_paths:
+ if not path.isdir():
+ msg = _("Warning: the path %s does not "
+ "exists (or is not a directory)\n" % path.__str__())
+ logger.write(src.printcolors.printcWarning(msg), 1)
+ else:
+ logger.write(_("Removing %s ...") % path.__str__())
+ path.rm()
+ logger.write('%s\n' % src.printcolors.printc(src.OK_STATUS), 3)
+
+def description():
+ '''method that is called when salomeTools is called with --help option.
+
+ :return: The text to display for the clean command description.
+ :rtype: str
+ '''
+ return _("The clean command suppress the source, build, or install "
+ "directories of the application products.")
+
+def run(args, runner, logger):
+ '''method that is called when salomeTools is called with clean 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 )
+
+ products_infos = prepare.get_products_list(options, runner.cfg, logger)
+
+ # Construct the list of directories to suppress
+ l_dir_to_suppress = []
+ if options.all:
+ l_dir_to_suppress += (get_source_directories(products_infos,
+ options.sources_without_dev) +
+ get_build_directories(products_infos) +
+ get_install_directories(products_infos))
+ else:
+ if options.install:
+ l_dir_to_suppress += get_install_directories(products_infos)
+
+ if options.build:
+ l_dir_to_suppress += get_build_directories(products_infos)
+
+ if options.source:
+ l_dir_to_suppress += get_source_directories(products_infos,
+ options.sources_without_dev)
+
+ # Check with the user if he really wants to suppress the directories
+ if not runner.options.batch:
+ logger.write(_("Remove the following directories ?\n"), 1)
+ for directory in l_dir_to_suppress:
+ logger.write(" %s\n" % directory, 1)
+ rep = input(_("Are you sure you want to continue? [Yes/No] "))
+ if rep.upper() != _("YES"):
+ return
+
+ # Suppress the list of paths
+ suppress_directories(l_dir_to_suppress, logger)
+
+ return
\ No newline at end of file
import src
import prepare
-# Define all possible option for log command : sat log <options>
+# Define all possible option for patch command : sat patch <options>
parser = src.options.Options()
parser.add_option('p', 'product', 'list2', 'products',
_('products to get the sources. This option can be'
' passed several time to get the sources of several products.'))
-parser.add_option('', 'no_sample', 'boolean', 'no_sample',
- _("do not get sources from sample products."))
def apply_patch(config, product_info, logger):
'''The method called to apply patches on a product
logger.write('Patching 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)
+ src.printcolors.print_value(logger, 'workdir',
+ runner.cfg.APPLICATION.workdir, 2)
logger.write("\n", 2, False)
# Get the products list with products informations regarding the options
import src
-# Define all possible option for log command : sat log <options>
+# Define all possible option for prepare command : sat prepare <options>
parser = src.options.Options()
parser.add_option('p', 'product', 'list2', 'products',
_('products to prepare. This option can be'
' passed several time to prepare several products.'))
-parser.add_option('', 'no_sample', 'boolean', 'no_sample',
- _("do not prepare sample products."))
parser.add_option('f', 'force', 'boolean', 'force',
_("force to prepare the products in development mode."))
parser.add_option('f', 'force_patch', 'boolean', 'force_patch',
# Construct the list of tuple containing
# the products name and their definition
products_infos = src.product.get_products_infos(products, cfg)
-
- # if the --no_sample option is invoked, suppress the sample products from
- # the list
- if options.no_sample:
-
- lproducts_sample = [p for p in products_infos if src.product.product_is_sample(p[1])]
-
- products_infos = [p for p in products_infos if p not in lproducts_sample]
-
- if len(lproducts_sample) > 0:
- msg = "Ignoring the following sample products:\n"
- logger.write(src.printcolors.printcWarning(_(msg)), 1)
- for i, product in enumerate(lproducts_sample):
- end_text = ', '
- if i+1 == len(lproducts_sample):
- end_text = '\n'
-
- logger.write(product[0] + end_text, 1)
return products_infos
else:
for p_name, __ in products_infos:
args_product_opt += ',' + p_name
-
- args_sample = ''
- if options.no_sample:
- args_sample = ' --no_sample'
-
- args_source = args_appli + args_product_opt + args_sample
+
+ args_source = args_appli + args_product_opt
if options.force:
args_source += ' --force'
logger.write(msg)
res_patch = 0
else:
- args_patch = args_appli + args_product_opt + args_sample
+ args_patch = args_appli + args_product_opt
# Call the source command that gets the source
res_patch = runner.patch(args_patch)
import src
import prepare
-# Define all possible option for log command : sat log <options>
+# Define all possible option for patch command : sat patch <options>
parser = src.options.Options()
parser.add_option('p', 'product', 'list2', 'products',
_('products from which to get the sources. This option can be'
' passed several time to get the sources of several products.'))
-parser.add_option('', 'no_sample', 'boolean', 'no_sample',
- _("do not get sources from sample products."))
parser.add_option('f', 'force', 'boolean', 'force',
_("force to remove the sources before getting them (in development mode only)."))
# Print some informations
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)
+ src.printcolors.print_value(logger, 'workdir',
+ runner.cfg.APPLICATION.workdir, 2)
logger.write("\n", 2, False)
# Get the force option if it was passed
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ #install_dir : "base"
}
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
patches : ['/home/salome/salomeTools-4.3.7/data/compil_scripts/patches/scipy.patch', '/export/home/serioja/MODULE_ARCHIVE.patch']
}
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
patches : []
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
patches : [$VARS.salometoolsway + $VARS.sep + '..' + $VARS.sep + 'RESOURCES' + $VARS.sep + 'mypatch.patch']
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
patches : []
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
}
\ No newline at end of file
depend : []
opt_depend : []
type : "sample"
- source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
- build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ source_dir : $APPLICATION.workdir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.workdir + $VARS.sep + 'BUILD' + $VARS.sep + $name
}
\ No newline at end of file
_("run salomeTools in debug mode."))
parser.add_option('v', 'verbose', 'int', "output_verbose_level",
_("change output verbose level (default is 3)."))
+parser.add_option('b', 'batch', 'boolean', "batch",
+ _("batch mode (no question)."))
class Sat(object):
'''The main class that stores all the commands of salomeTools
relative to the product notion of salomeTools
'''
+import os
+
import src
AVAILABLE_VCS = ['git', 'svn', 'cvs']
if prod_info is not None:
prod_info.debug = debug
prod_info.dev = dev
-
+
+ # Set the install_dir key
+ if "install_dir" not in prod_info:
+ # Set it to the default value (in application directory)
+ prod_info.install_dir = os.path.join(config.APPLICATION.workdir,
+ "INSTALL",
+ prod_info.name)
+
return prod_info
def get_products_infos(lproducts, config):