]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
changing some keys name, factorizing dome code
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 11 Mar 2016 14:57:39 +0000 (15:57 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 11 Mar 2016 14:57:39 +0000 (15:57 +0100)
19 files changed:
commands/patch.py
commands/prepare.py
commands/source.py
complete_sat.sh
data/modules/KERNEL.pyconf
data/modules/MODULE_ARCHIVE.pyconf
data/modules/MODULE_CVS.pyconf
data/modules/MODULE_DEFAULTVERSION.pyconf [new file with mode: 0644]
data/modules/MODULE_DIR.pyconf
data/modules/MODULE_FIXED.pyconf [new file with mode: 0644]
data/modules/MODULE_NATIVE.pyconf [new file with mode: 0644]
data/modules/MODULE_SVN.pyconf
data/modules/softA.pyconf
data/modules/softB.pyconf
src/module.py
test/log/launch_browser.py
test/prepare/res.html [new file with mode: 0644]
test/prepare/test_prepare.py [new file with mode: 0644]
test/run_all.sh

index 589d9ccc0ad04c3b1a4d86374b7723f08cdbe945..721ed1b25fbc2bf1f25b18d811e3a6e199e0578c 100644 (file)
@@ -20,6 +20,7 @@ import os
 import subprocess
 
 import src
+import prepare
 
 # Define all possible option for log command :  sat log <options>
 parser = src.options.Options()
@@ -122,29 +123,8 @@ def run(args, runner, logger):
                                 runner.cfg.APPLICATION.out_dir, 2)
     logger.write("\n", 2, False)
 
-    # Get the modules to be prepared, regarding the options
-    if options.modules is None:
-        # No options, get all modules sources
-        modules = runner.cfg.APPLICATION.modules
-    else:
-        # if option --modules, check that all modules of the command line
-        # are present in the application.
-        modules = options.modules
-        for m in modules:
-            if m not in runner.cfg.APPLICATION.modules:
-                raise src.SatException(_("Module %(module)s "
-                            "not defined in application %(application)s") %
-                { 'module': m, 'application': runner.cfg.VARS.application} )
-    
-    # Construct the list of tuple containing 
-    # the modules name and their definition
-    modules_infos = src.module.get_modules_infos(modules, runner.cfg)
-
-    # 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)
+    # Get the modules list with modules informations reagrding the options
+    modules_infos = prepare.get_modules_list(options, runner.cfg, logger)
     
     # Get the maximum name length in order to format the terminal display
     max_module_name_len = 1
@@ -171,7 +151,7 @@ def run(args, runner, logger):
         res_count = "%d / %d" % (good_result, good_result)
     else:
         status = src.KO_STATUS
-        res_count = "%d / %d" % (good_result, len(modules))
+        res_count = "%d / %d" % (good_result, len(modules_infos))
     
     # write results
     logger.write("Patching sources of the application:", 1)
index 4db0527f30222854203249463a191ca98879321d..abb14cbe3a99e1b6e784a74f9756f82eac9bf10f 100644 (file)
@@ -28,6 +28,54 @@ parser.add_option('', 'no_sample', 'boolean', 'no_sample',
 parser.add_option('f', 'force', 'boolean', 'force', 
     _("force to prepare the modules in development mode."))
 
+def get_modules_list(options, cfg, logger):
+    '''method that gives the module list with their informations from 
+       configuration regarding the passed options.
+    
+    :param options Options: The Options instance that stores the commands 
+                            arguments
+    :param config Config: The global configuration
+    :param logger Logger: The logger instance to use for the display and logging
+    :return: The list of (module name, module_infomrmations).
+    :rtype: List
+    '''
+    # Get the modules to be prepared, regarding the options
+    if options.modules is None:
+        # No options, get all modules sources
+        modules = cfg.APPLICATION.modules
+    else:
+        # if option --modules, check that all modules of the command line
+        # are present in the application.
+        modules = options.modules
+        for m in modules:
+            if m not in cfg.APPLICATION.modules:
+                raise src.SatException(_("Module %(module)s "
+                            "not defined in application %(application)s") %
+                { 'module': m, 'application': cfg.VARS.application} )
+    
+    # Construct the list of tuple containing 
+    # the modules name and their definition
+    modules_infos = src.module.get_modules_infos(modules, cfg)
+
+    # if the --no_sample option is invoked, suppress the sample modules from 
+    # the list
+    if options.no_sample:
+        
+        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)
+    
+    return modules_infos
+
 def description():
     '''method that is called when salomeTools is called with --help option.
     
index 18feada59be6df2fff761c79fd442809ebc41d59..4103f037f674bcc6ce8c25ebd337a6081474b137 100644 (file)
@@ -20,6 +20,7 @@ import os
 import shutil
 
 import src
+import prepare
 
 # Define all possible option for log command :  sat log <options>
 parser = src.options.Options()
@@ -240,41 +241,6 @@ def get_sources_from_svn(user, module_info, source_dir, checkout, logger):
                                      checkout)
     return retcode
 
-def get_sources_from_dir(module_info, source_dir, logger):
-    '''The method called if the module is to be get in dir mode
-    
-    :param module_info Config: The configuration specific to 
-                               the module to be prepared
-    :param source_dir Path: The Path instance corresponding to the 
-                            directory where to put the sources
-    :param logger Logger: The logger instance to use for the display and logging
-    :return: True if it succeed, else False
-    :rtype: boolean
-    '''
-    # Check if it is a symlink?
-    use_link = ('symlink' in module_info.dir_info and 
-                module_info.dir_info.symlink)
-    dirflag = 'dir'
-    if use_link: dirflag = 'lnk'
-
-    # check that source exists if it is not a symlink
-    if (not use_link) and (not os.path.exists(module_info.dir_info.dir)):
-        raise src.SatException(_("Source directory not found: '%s'") % 
-                               module_info.dir_info.dir)
-
-    logger.write('%s:%s ... ' % 
-                 (dirflag, src.printcolors.printcInfo(module_info.dir_info.dir)),
-                 3, 
-                 False)
-    logger.flush()
-
-    if use_link:
-        retcode = src.Path(source_dir).symlink(module_info.dir_info.dir)
-    else:
-        retcode = src.Path(module_info.dir_info.dir).copy(source_dir)
-
-    return retcode
-
 def get_module_sources(config, 
                        module_info, 
                        is_dev, 
@@ -306,14 +272,14 @@ def get_module_sources(config,
                                    logger, 
                                    pad)
 
-    if module_info.get_method == "git":
+    if module_info.get_sources == "git":
         return get_sources_from_git(module_info, source_dir, logger, pad, 
                                     is_dev)
 
-    if module_info.get_method == "archive":
+    if module_info.get_sources == "archive":
         return get_sources_from_archive(module_info, source_dir, logger)
     
-    if module_info.get_method == "cvs":
+    if module_info.get_sources == "cvs":
         cvs_user = config.USER.cvs_user
         return get_sources_from_cvs(cvs_user, 
                                     module_info, 
@@ -322,23 +288,30 @@ def get_module_sources(config,
                                     logger,
                                     pad)
 
-    if module_info.get_method == "svn":
+    if module_info.get_sources == "svn":
         svn_user = config.USER.svn_user
         return get_sources_from_svn(svn_user, module_info, source_dir, 
                                     checkout,
                                     logger)
-   
-    if module_info.get_method == "dir":
-        return get_sources_from_dir(module_info, source_dir, logger)
+
+    if module_info.get_sources == "native":
+        # skip
+        logger.write('%s ...' % _("native (ignored)"), 3, False)
+        return True        
+
+    if module_info.get_sources == "fixed":
+        # skip
+        logger.write('%s ...' % _("fixed (ignored)"), 3, False)
+        return True  
     
-    if len(module_info.get_method) == 0:
+    if len(module_info.get_sources) == 0:
         # skip
         logger.write('%s ...' % _("ignored"), 3, False)
         return True
 
-    # if the get_method is not in [git, archive, cvs, svn, dir]
+    # if the get_sources is not in [git, archive, cvs, svn, dir]
     logger.write(_("Unknown get_mehtod %(get)s for module %(module)s") % \
-        { 'get': module_info.get_method, 'module': module_info.name }, 3, False)
+        { 'get': module_info.get_sources, 'module': module_info.name }, 3, False)
     logger.write(" ... ", 3, False)
     logger.flush()
     return False
@@ -367,7 +340,10 @@ def get_all_module_sources(config, modules, force, logger):
     for module_name, module_info in modules:
         # get module name, module informations and the directory where to put
         # the sources
-        source_dir = src.Path(module_info.source_dir)
+        if not src.module.module_is_fixed(module_info):
+            source_dir = src.Path(module_info.source_dir)
+        else:
+            source_dir = src.Path('')
 
         # display and log
         logger.write('%s: ' % src.printcolors.printcLabel(module_name), 3)
@@ -453,41 +429,9 @@ def run(args, runner, logger):
                 "on modules in development mode\n\n")
         logger.write(src.printcolors.printcWarning(msg))
     
-    # Get the modules to be prepared, regarding the options
-    if options.modules is None:
-        # No options, get all modules sources
-        modules = runner.cfg.APPLICATION.modules
-    else:
-        # if option --modules, check that all modules of the command line
-        # are present in the application.
-        modules = options.modules
-        for m in modules:
-            if m not in runner.cfg.APPLICATION.modules:
-                raise src.SatException(_("Module %(module)s "
-                            "not defined in application %(application)s") %
-                { 'module': m, 'application': runner.cfg.VARS.application} )
+    # Get the modules list with modules informations reagrding the options
+    modules_infos = prepare.get_modules_list(options, runner.cfg, logger)
     
-    # Construct the list of tuple containing 
-    # the modules name and their definition
-    modules_infos = src.module.get_modules_infos(modules, runner.cfg)
-
-    # if the --no_sample option is invoked, suppress the sample modules from 
-    # the list
-    if options.no_sample:
-        
-        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,
index c78ce059fd8332d859ae3874b8109a1b3eaa1a2e..257ec4b58a3be621ce9bcc10898c89522061da03 100755 (executable)
@@ -140,7 +140,12 @@ _salomeTools_complete()
             return 0
             ;;
         source)
-            opts="--modules --no_sample --force"
+            opts="--module --no_sample --force"
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+        patch)
+            opts="--module --no_sample"
             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
             return 0
             ;;
index bb3c00a108572225dbb2a3e3e7d60b9b6af1a215..06396f4d664cb9550d7b449df3411dc88efa1fdf 100644 (file)
@@ -1,14 +1,12 @@
-KERNEL_7_7_1 :
+KERNEL_V7_7_1 :
 {
        name : "KERNEL"
-    has_gui : "no"
-    compile_method : "cmake"
-    get_method : "git"
+    build_sources : "cmake"
+    get_sources : "git"
     git_info:
     {
         repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : 'V7_7_1'
     }
     environ :
     {
@@ -19,7 +17,7 @@ KERNEL_7_7_1 :
     }
     depend : []
     opt_depend : []
-    module_type : "sample"
+    type : "sample"
     source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
     build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
 }
index 5152d107e283d7b860a8f59f137f63bd3d85a427..5e59cee6c09f23570b765aeb433c5de7305b7ea8 100644 (file)
@@ -1,14 +1,12 @@
 MODULE_ARCHIVE :
 {
        name : "MODULE_ARCHIVE"
-    has_gui : "no"
     compile_method : "cmake"
-    get_method : "archive"
+    get_sources : "archive"
     git_info:
     {
         repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : 'V7_7_1'
     }
     archive_info:
     {
@@ -23,7 +21,7 @@ MODULE_ARCHIVE :
     }
     depend : []
     opt_depend : []
-    module_type : "sample"
+    type : "sample"
     source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
     build_dir : $APPLICATION.out_dir + $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']
index c8c75fc8fecbbe10289e7aa0da369ec952245a16..9ce25295f65c4b71a825d98299fe8dd265955d41 100644 (file)
@@ -1,14 +1,12 @@
-MODULE_CVS_6_7_0 :
+MODULE_CVS_V6_7_0 :
 {
        name : "MODULE_CVS"
-    has_gui : "no"
-    compile_method : "cmake"
-    get_method : "cvs"
+    build_sources : "cmake"
+    get_sources : "cvs"
     git_info:
     {
         repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : 'V7_7_1'
     }
     archive_info:
     {
@@ -19,7 +17,6 @@ MODULE_CVS_6_7_0 :
         server : "cvs.opencascade.com"
         module_base : "/home/server/cvs/KERNEL"
         source : 'KERNEL_SRC'
-        tag : "V6_7_0"
     }
     environ :
     {
@@ -30,7 +27,7 @@ MODULE_CVS_6_7_0 :
     }
     depend : []
     opt_depend : []
-    module_type : "sample"
+    type : "sample"
     source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
     build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
 }
\ No newline at end of file
diff --git a/data/modules/MODULE_DEFAULTVERSION.pyconf b/data/modules/MODULE_DEFAULTVERSION.pyconf
new file mode 100644 (file)
index 0000000..561e047
--- /dev/null
@@ -0,0 +1,33 @@
+MODULE_DEFAULTVERSION :
+{
+       name : "MODULE_DEFAULTVERSION"
+    build_sources : "cmake"
+    get_sources : "git"
+    git_info:
+    {
+        repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
+        repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
+    }
+    archive_info:
+    {
+               archive_name : ''
+    }
+    cvs_info:
+    {
+        server : "cvs.opencascade.com"
+        module_base : "/home/server/cvs/KERNEL"
+        source : 'KERNEL_SRC'
+    }
+    environ :
+    {
+        "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+        "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+            "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+            "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
+    }
+    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
+}
\ No newline at end of file
index bd5e5e6aace6162fbe684be6448698d0adfbd4ce..f51e1e045475fa414eb47d4e2c9af4c869315283 100644 (file)
@@ -1,14 +1,12 @@
 MODULE_DIR :
 {
        name : "MODULE_DIR"
-    has_gui : "no"
     compile_method : "cmake"
-    get_method : "dir"
+    get_sources : "dir"
     git_info:
     {
         repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : 'V7_7_1'
     }
     archive_info:
     {
@@ -21,7 +19,6 @@ MODULE_DIR :
     svn_info:
     {
                repo: 'https://www-svn-corpus.cea.fr/corpus/CORPUS'
-               tag: 'master'
     }
     environ :
     {
@@ -32,7 +29,7 @@ MODULE_DIR :
     }
     depend : []
     opt_depend : []
-    module_type : "sample"
+    type : "sample"
     source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
     build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
 }
\ No newline at end of file
diff --git a/data/modules/MODULE_FIXED.pyconf b/data/modules/MODULE_FIXED.pyconf
new file mode 100644 (file)
index 0000000..80d90f3
--- /dev/null
@@ -0,0 +1,13 @@
+MODULE_FIXED :
+{
+       name : "MODULE_FIXED"
+       get_sources : "fixed"
+    environ :
+    {
+        "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+        "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+            "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+            "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
+    }
+    type : "sample"
+}
\ No newline at end of file
diff --git a/data/modules/MODULE_NATIVE.pyconf b/data/modules/MODULE_NATIVE.pyconf
new file mode 100644 (file)
index 0000000..9d853e1
--- /dev/null
@@ -0,0 +1,31 @@
+MODULE_NATIVE :
+{
+       name : "MODULE_NATIVE"
+    compile_method : "cmake"
+    get_sources : "native"
+    git_info:
+    {
+        repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
+        repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
+    }
+    archive_info:
+    {
+               archive_name : '/data/tmpsalome/salome/prerequis/archives/tclx8.4.tar.bz2'
+    }
+    svn_info:
+    {
+               repo: 'https://www-svn-corpus.cea.fr/corpus/CORPUS'
+    }
+    environ :
+    {
+        "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+        "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+            "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+            "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
+    }
+    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
+}
\ No newline at end of file
index 228f0e4770bd8af75e52e0c50b854c4ce8de1ff4..a7a45b48ee92e1847fd263c66e0d3e7aa288f502 100644 (file)
@@ -1,14 +1,12 @@
 MODULE_SVN :
 {
        name : "MODULE_SVN"
-    has_gui : "no"
-    compile_method : "cmake"
-    get_method : "svn"
+    build_sources : "cmake"
+    get_sources : "svn"
     git_info:
     {
         repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : 'V7_7_1'
     }
     archive_info:
     {
@@ -17,7 +15,6 @@ MODULE_SVN :
     svn_info:
     {
                repo: 'https://www-svn-corpus.cea.fr/corpus/CORPUS'
-               tag: 'master'
     }
     environ :
     {
@@ -28,7 +25,7 @@ MODULE_SVN :
     }
     depend : []
     opt_depend : []
-    module_type : "sample"
+    type : "sample"
     source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
     build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
 }
\ No newline at end of file
index c1b66bcd573fb89994ecf2f5b26035ccd98b8027..f7c0f9bdbdeca2be6b721f1eac0c5f89edc4e326 100644 (file)
@@ -1,21 +1,18 @@
 softA :
 {
        name : "softA"
-    has_gui : "no"
-    compile_method : "cmake" # ou autotools, ou script
+    get_sources : "cmake" # ou autotools, ou script
     get_method : "git" # "archive", embedded", "native" "fixed"
     cvs_info:
     {
         server : $SITE.prepare.default_cvs_server
         module_base : $SITE.prepare.cvs_dir + $name
         source : 'softA_SRC'
-        tag : ''
     }
     git_info:
     {
         repo : $SITE.prepare.default_git_server + $VARS.sep + $name
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : $APPLICATION.default_version_to_download
     }
     archive_info:
     {
index e433544689535d8d28b847f0ae89ac95e0451d4b..31e195dec003c1d2df3b717783ac623d77438ad4 100644 (file)
@@ -1,21 +1,18 @@
 softB :
 {
        name : "softB"
-    has_gui : "no"
-    compile_method : "cmake" # ou autotools, ou script
+    get_sources : "cmake" # ou autotools, ou script
     get_method : "git" # "archive", embedded", "native" "fixed"
     cvs_info:
     {
         server : $SITE.prepare.default_cvs_server
         module_base : $SITE.prepare.cvs_dir + $name
         source : 'softB_SRC'
-        tag : ''
     }
     git_info:
     {
         repo : $SITE.prepare.default_git_server + $VARS.sep + $name
         repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
-        tag : $APPLICATION.default_version_to_download
     }
     archive_info:
     {
index ada190d355ae6cfb2fb8bee10b71252fc65adfa8..c2a4b5f654b54242964902637f731125cb04180c 100644 (file)
 #  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
-'''In this file are implemented the classes and method 
+'''In this file are implemented the classes and methods 
    relative to the module notion of salomeTools
 '''
 
 import src
 
+AVAILABLE_VCS = ['git', 'svn', 'cvs']
+
 def get_module_config(config, module_name, version):
     '''Get the specific configuration of a module from the global configuration
     
@@ -50,6 +52,26 @@ def get_module_config(config, module_name, version):
         for depend in mod_info.opt_depend:
             if depend in config.MODULES:
                 mod_info.depend.append(depend,'')
+                
+    # Check if the module is defined as native in the application
+    pass # to be done
+    
+    # In case of a module get with a vcs, put the tag (equal to the version)
+    if mod_info is not None and mod_info.get_sources in AVAILABLE_VCS:
+        
+        if mod_info.get_sources == 'git':
+            mod_info.git_info.tag = version
+        
+        if mod_info.get_sources == 'svn':
+            mod_info.svn_info.tag = version
+        
+        if mod_info.get_sources == 'cvs':
+            mod_info.cvs_info.tag = version
+    
+    # In case of a fixed module, define the install_dir (equal to the version)
+    if mod_info is not None and mod_info.get_sources=="fixed":
+        mod_info.install_dir = version
+    
     return mod_info
 
 def get_modules_infos(lmodules, config):
@@ -65,7 +87,11 @@ def get_modules_infos(lmodules, config):
     # Loop on module names
     for mod in lmodules:
         # Get the version of the module from the application definition
-        version_mod = config.APPLICATION.modules[mod][0]
+        version_mod = config.APPLICATION.modules[mod]
+        # if no version, then take the default one defined in the application
+        if isinstance(version_mod, bool): 
+            version_mod = config.APPLICATION.tag
+        
         # Get the specific configuration of the module
         mod_info = get_module_config(config, mod, version_mod)
         if mod_info is not None:
@@ -80,9 +106,20 @@ def module_is_sample(module_info):
     '''Know if a module has the sample type
     
     :param module_info Config: The configuration specific to 
-                               the module to be prepared
+                               the module
     :return: True if the module has the sample type, else False
     :rtype: boolean
     '''
-    mtype = module_info.module_type
-    return mtype.lower() == 'sample'
\ No newline at end of file
+    mtype = module_info.type
+    return mtype.lower() == 'sample'
+
+def module_is_fixed(module_info):
+    '''Know if a module is fixed
+    
+    :param module_info Config: The configuration specific to 
+                               the module
+    :return: True if the module is fixed, else False
+    :rtype: boolean
+    '''
+    get_src = module_info.get_sources
+    return get_src.lower() == 'fixed'
\ No newline at end of file
index 369deef01bb664ba08b93511fb7c672d32281adc..2eb9698a722d9f8e8800d7664b7a30f73cfaddad 100644 (file)
@@ -36,7 +36,7 @@ from tools import outRedirection
 import HTMLTestRunner
 import src.xmlManager
 
-sleep_time = 3
+sleep_time = 2
 
 class TestLog(unittest.TestCase):
     '''Test of log command: launch of browser
@@ -49,6 +49,7 @@ class TestLog(unittest.TestCase):
         OK = "KO"
 
         sat = Sat("-oUSER.browser='konqueror'")
+        time.sleep(sleep_time)
         cmd_log = threading.Thread(target=sat.log, args=('',))
         cmd_log.start()
 
@@ -100,7 +101,7 @@ class TestLog(unittest.TestCase):
             OK = "OK"
             sys.stdin = sys.__stdin__
         except:
-            pass
+            sys.stdin = sys.__stdin__
         
         # pyunit method to compare 2 str
         self.assertEqual(OK, "OK")
@@ -120,7 +121,7 @@ class TestLog(unittest.TestCase):
         sys.stdin = io.StringIO(one)
         
         try:
-            sat.log('appli-test --last')
+            sat.log('appli-test -t --last')
             OK = "OK"
             sys.stdin = sys.__stdin__
         except:
@@ -252,6 +253,8 @@ class TestLog(unittest.TestCase):
               
         sat.config('appli-test -v VARS.python')
         
+        
+        time.sleep(sleep_time)
         cmd_log = threading.Thread(target=sat.log, args=('appli-test --last',))
         cmd_log.start()
         
@@ -326,6 +329,7 @@ class TestLog(unittest.TestCase):
         OK = "KO"
 
         sat = Sat("-oUSER.browser='konqueror'")
+        time.sleep(sleep_time)
         cmd_log = threading.Thread(target=sat.log, args=('--full',))
         cmd_log.start()
 
diff --git a/test/prepare/res.html b/test/prepare/res.html
new file mode 100644 (file)
index 0000000..42ebed3
--- /dev/null
@@ -0,0 +1,298 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <title>Unit Test Report</title>
+    <meta name="generator" content="HTMLTestRunner 0.8.2"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    
+<style type="text/css" media="screen">
+body        { font-family: verdana, arial, helvetica, sans-serif; font-size: 80%; }
+table       { font-size: 100%; }
+pre         { }
+
+/* -- heading ---------------------------------------------------------------------- */
+h1 {
+       font-size: 16pt;
+       color: gray;
+}
+.heading {
+    margin-top: 0ex;
+    margin-bottom: 1ex;
+}
+
+.heading .attribute {
+    margin-top: 1ex;
+    margin-bottom: 0;
+}
+
+.heading .description {
+    margin-top: 4ex;
+    margin-bottom: 6ex;
+}
+
+/* -- css div popup ------------------------------------------------------------------------ */
+a.popup_link {
+}
+
+a.popup_link:hover {
+    color: red;
+}
+
+.popup_window {
+    display: none;
+    position: relative;
+    left: 0px;
+    top: 0px;
+    /*border: solid #627173 1px; */
+    padding: 10px;
+    background-color: #E6E6D6;
+    font-family: "Lucida Console", "Courier New", Courier, monospace;
+    text-align: left;
+    font-size: 8pt;
+    width: 500px;
+}
+
+}
+/* -- report ------------------------------------------------------------------------ */
+#show_detail_line {
+    margin-top: 3ex;
+    margin-bottom: 1ex;
+}
+#result_table {
+    width: 80%;
+    border-collapse: collapse;
+    border: 1px solid #777;
+}
+#header_row {
+    font-weight: bold;
+    color: white;
+    background-color: #777;
+}
+#result_table td {
+    border: 1px solid #777;
+    padding: 2px;
+}
+#total_row  { font-weight: bold; }
+.passClass  { background-color: #6c6; }
+.failClass  { background-color: #c60; }
+.errorClass { background-color: #c00; }
+.passCase   { color: #6c6; }
+.failCase   { color: #c60; font-weight: bold; }
+.errorCase  { color: #c00; font-weight: bold; }
+.hiddenRow  { display: none; }
+.testcase   { margin-left: 2em; }
+
+
+/* -- ending ---------------------------------------------------------------------- */
+#ending {
+}
+
+</style>
+
+</head>
+<body>
+<script language="javascript" type="text/javascript"><!--
+output_list = Array();
+
+/* level - 0:Summary; 1:Failed; 2:All */
+function showCase(level) {
+    trs = document.getElementsByTagName("tr");
+    for (var i = 0; i < trs.length; i++) {
+        tr = trs[i];
+        id = tr.id;
+        if (id.substr(0,2) == 'ft') {
+            if (level < 1) {
+                tr.className = 'hiddenRow';
+            }
+            else {
+                tr.className = '';
+            }
+        }
+        if (id.substr(0,2) == 'pt') {
+            if (level > 1) {
+                tr.className = '';
+            }
+            else {
+                tr.className = 'hiddenRow';
+            }
+        }
+    }
+}
+
+
+function showClassDetail(cid, count) {
+    var id_list = Array(count);
+    var toHide = 1;
+    for (var i = 0; i < count; i++) {
+        tid0 = 't' + cid.substr(1) + '.' + (i+1);
+        tid = 'f' + tid0;
+        tr = document.getElementById(tid);
+        if (!tr) {
+            tid = 'p' + tid0;
+            tr = document.getElementById(tid);
+        }
+        id_list[i] = tid;
+        if (tr.className) {
+            toHide = 0;
+        }
+    }
+    for (var i = 0; i < count; i++) {
+        tid = id_list[i];
+        if (toHide) {
+            document.getElementById('div_'+tid).style.display = 'none'
+            document.getElementById(tid).className = 'hiddenRow';
+        }
+        else {
+            document.getElementById(tid).className = '';
+        }
+    }
+}
+
+
+function showTestDetail(div_id){
+    var details_div = document.getElementById(div_id)
+    var displayState = details_div.style.display
+    // alert(displayState)
+    if (displayState != 'block' ) {
+        displayState = 'block'
+        details_div.style.display = 'block'
+    }
+    else {
+        details_div.style.display = 'none'
+    }
+}
+
+
+function html_escape(s) {
+    s = s.replace(/&/g,'&amp;');
+    s = s.replace(/</g,'&lt;');
+    s = s.replace(/>/g,'&gt;');
+    return s;
+}
+
+/* obsoleted by detail in <div>
+function showOutput(id, name) {
+    var w = window.open("", //url
+                    name,
+                    "resizable,scrollbars,status,width=800,height=450");
+    d = w.document;
+    d.write("<pre>");
+    d.write(html_escape(output_list[id]));
+    d.write("\n");
+    d.write("<a href='javascript:window.close()'>close</a>\n");
+    d.write("</pre>\n");
+    d.close();
+}
+*/
+--></script>
+
+<div class='heading'>
+<h1>Unit Test Report</h1>
+<p class='attribute'><strong>Start Time:</strong> 2016-03-11 15:04:07</p>
+<p class='attribute'><strong>Duration:</strong> 0:01:32.373196</p>
+<p class='attribute'><strong>Status:</strong> Pass 1</p>
+
+<p class='description'></p>
+</div>
+
+
+
+<p id='show_detail_line'>Show
+<a href='javascript:showCase(0)'>Summary</a>
+<a href='javascript:showCase(1)'>Failed</a>
+<a href='javascript:showCase(2)'>All</a>
+</p>
+<table id='result_table'>
+<colgroup>
+<col align='left' />
+<col align='right' />
+<col align='right' />
+<col align='right' />
+<col align='right' />
+<col align='right' />
+</colgroup>
+<tr id='header_row'>
+    <td>Test Group/Test case</td>
+    <td>Count</td>
+    <td>Pass</td>
+    <td>Fail</td>
+    <td>Error</td>
+    <td>View</td>
+</tr>
+
+<tr class='passClass'>
+    <td>TestLog: Test of log command: launch of browser</td>
+    <td>1</td>
+    <td>1</td>
+    <td>0</td>
+    <td>0</td>
+    <td><a href="javascript:showClassDetail('c1',1)">Detail</a></td>
+</tr>
+
+<tr id='pt1.1' class='hiddenRow'>
+    <td class='none'><div class='testcase'>test_prepare_all: Test the prepare command with many ways to prepare</div></td>
+    <td colspan='5' align='center'>
+
+    <!--css div popup start-->
+    <a class="popup_link" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.1')" >
+        pass</a>
+
+    <div id='div_pt1.1' class="popup_window">
+        <div style='text-align: right; color:red;cursor:pointer'>
+        <a onfocus='this.blur();' onclick="document.getElementById('div_pt1.1').style.display = 'none' " >
+           [x]</a>
+        </div>
+        <pre>
+        
+pt1.1: Get the sources of the desired modules
+Getting sources of the application appli-test
+  out_dir = /export/home/serioja/APPLI-TEST-MG05 
+
+KERNEL:         git:http://git.salome-platform.org/gitpub/modules/kernel.git         tag:V7_7_1 ..... OK
+MODULE_ARCHIVE: arc:/data/tmpsalome/salome/prerequis/archives/tclx8.4.tar.bz2 ... OK
+MODULE_CVS:     dev: /export/home/serioja/APPLI-TEST-MG05/SOURCES/MODULE_CVS ... OK source directory already exists
+MODULE_SVN:     svn:https://www-svn-corpus.cea.fr/corpus/CORPUS ... OK
+MODULE_NATIVE:  native (ignored) ...OK
+MODULE_DEFAULTVERSION: git:http://git.salome-platform.org/gitpub/modules/kernel.git         tag:V7_7_1 ..... OK
+MODULE_FIXED:   fixed (ignored) ...OK
+
+Getting sources of the application: OK (7 / 7)
+
+Apply the patches to the sources of the modules
+Patching sources of the application appli-test
+  out_dir = /export/home/serioja/APPLI-TEST-MG05 
+
+KERNEL:         No patch for the KERNEL module
+MODULE_ARCHIVE:   Failed to apply patch /home/salome/salomeTools-4.3.7/data/compil_scripts/patches/scipy.patch
+  Apply patch /export/home/serioja/MODULE_ARCHIVE.patch
+MODULE_CVS:     No patch for the MODULE_CVS module
+MODULE_SVN:     No patch for the MODULE_SVN module
+MODULE_NATIVE:  No patch for the MODULE_NATIVE module
+MODULE_DEFAULTVERSION: No patch for the MODULE_DEFAULTVERSION module
+MODULE_FIXED:   No patch for the MODULE_FIXED module
+
+Patching sources of the application: KO (6 / 7)
+
+
+        </pre>
+    </div>
+    <!--css div popup end-->
+
+    </td>
+</tr>
+
+<tr id='total_row'>
+    <td>Total</td>
+    <td>1</td>
+    <td>1</td>
+    <td>0</td>
+    <td>0</td>
+    <td>&nbsp;</td>
+</tr>
+</table>
+
+<div id='ending'>&nbsp;</div>
+
+</body>
+</html>
diff --git a/test/prepare/test_prepare.py b/test/prepare/test_prepare.py
new file mode 100644 (file)
index 0000000..00d8e97
--- /dev/null
@@ -0,0 +1,63 @@
+#!/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 unittest
+import os
+import sys
+import io
+
+# get execution path
+testdir = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(testdir, '..', '..'))
+sys.path.append(os.path.join(testdir, '..', '_testTools'))
+sys.path.append(os.path.join(testdir, '..', '..','commands'))
+
+from salomeTools import Sat
+from tools import check_proc_existence_and_kill
+from tools import outRedirection
+import HTMLTestRunner
+import src.xmlManager
+
+sleep_time = 3
+
+class TestLog(unittest.TestCase):
+    '''Test of the prepare command
+    '''
+    
+    def test_prepare_all(self):
+        '''Test the prepare command with many ways to prepare
+        '''
+       
+        OK = "KO"
+
+        sat = Sat()
+
+        try:
+            sat.prepare('appli-test')
+            OK = "OK"
+        except:
+            pass
+        
+
+        # pyunit method to compare 2 str
+        self.assertEqual(OK, "OK")
+        
+
+# test launch
+if __name__ == '__main__':
+    HTMLTestRunner.main()
index b9bed1a4a2e6a3f1fbb958f42ab69010f7abbacd..bf13d1f109f532ba2a7cd0524f83db5b41c978d5 100755 (executable)
@@ -22,4 +22,5 @@ coverage run --source=../commands/config.py -a config/create_user_pyconf.py >> t
 coverage run --source=../commands/config.py -a config/option_copy.py >> test_res.html
 coverage run --source=../commands/config.py -a config/option_edit.py >> test_res.html
 coverage run --source=../commands/config.py,../commands/log.py,../src/xmlManager.py,../src/logger.py -a log/launch_browser.py >> test_res.html
+coverage run --source=../commands/config.py,../commands/source.py,../commands/patch.py,../commands/prepare.py,../src/module.py -a prepare/test_prepare.py >> test_res.html
 coverage html