]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
fix sat#13081 'sat package -t'
authorChristian Van Wambeke <christian.van-wambeke@cea.fr>
Tue, 18 Dec 2018 10:00:52 +0000 (11:00 +0100)
committerChristian Van Wambeke <christian.van-wambeke@cea.fr>
Tue, 18 Dec 2018 10:00:52 +0000 (11:00 +0100)
commands/package.py
src/pyconf.py
src/salomeTools.py

index 64da2bd3b72755ef07f1786a881a87f1d93ebd5c..a54408bd6308e607d8d4f7f0b32d55a46b05b598 100644 (file)
@@ -134,7 +134,7 @@ def add_files(tar, name_archive, d_content, logger, f_exclude=None):
 
     for name in names:
         # display information
-        len_points = max_len - len(name)
+        len_points = max_len - len(name) + 3
         local_path, archive_path = d_content[name]
         in_archive = os.path.join(name_archive, archive_path)
         logger.write(name + " " + len_points * "." + " "+ in_archive + " ", 3)
@@ -197,8 +197,7 @@ def produce_relative_launcher(config,
         bin_kernel_install_dir = os.path.join(kernel_root_dir,"bin","salome") 
 
     # check if the application contains an application module
-    l_product_info = src.product.get_products_infos(config.APPLICATION.products.keys(),
-                                                    config)
+    l_product_info = src.product.get_products_infos(config.APPLICATION.products.keys(), config)
     salome_application_name="Not defined" 
     for prod_name, prod_info in l_product_info:
         # look for a salome application
@@ -1278,8 +1277,7 @@ def run(args, runner, logger):
                                                     runner.cfg.VARS.application), 1)
         
         # Get the default directory where to put the packages
-        package_default_path = os.path.join(runner.cfg.APPLICATION.workdir,
-                                            "PACKAGE")
+        package_default_path = os.path.join(runner.cfg.APPLICATION.workdir, "PACKAGE")
         src.ensure_path_exists(package_default_path)
         
     # if the package contains a project:
@@ -1294,9 +1292,7 @@ def run(args, runner, logger):
                 break
 
         if foundProject is None:
-            local_path = os.path.join(runner.cfg.VARS.salometoolsway,
-                                     "data",
-                                     "local.pyconf")
+            local_path = os.path.join(runner.cfg.VARS.salometoolsway, "data", "local.pyconf")
             msg = _("""ERROR: the project %(1)s is not visible by salomeTools.
 known projects are:
 %(2)s
@@ -1454,9 +1450,9 @@ Please add it in file:
             d_files_to_add[file_name] = (file_path, file_name)
 
     logger.write("\n", 2)
-
     logger.write(src.printcolors.printcLabel(_("Actually do the package")), 2)
     logger.write("\n", 2)
+    logger.write("\nfiles and directories to add:\n%s\n\n" % PP.pformat(d_files_to_add), 5)
 
     res = 0
     try:
@@ -1478,10 +1474,17 @@ Please add it in file:
         logger.write(_("\n"), 1)
         return 1
     
+    # case if no application, only package sat as 'sat package -t'
+    try:
+        app = runner.cfg.APPLICATION
+    except:
+        app = None
+
     # unconditionaly remove the tmp_local_working_dir
-    tmp_local_working_dir = os.path.join(runner.cfg.APPLICATION.workdir, "tmp_package")
-    if os.path.isdir(tmp_local_working_dir):
-      shutil.rmtree(tmp_local_working_dir)
+    if app is not None:
+        tmp_local_working_dir = os.path.join(app.workdir, "tmp_package")
+        if os.path.isdir(tmp_local_working_dir):
+            shutil.rmtree(tmp_local_working_dir)
 
     # have to decide some time
     DBG.tofix("make shutil.rmtree('%s') effective" % tmp_working_dir, "", DBG.isDeveloper())
index 2a655ca5162d54c9d1b16093fac615ec8d0b034e..5957d6ddcf8a12cbe2d5d971bf3eac266ca50ada 100644 (file)
@@ -481,7 +481,7 @@ class Mapping(Container):
     def __getitem__(self, key):
         data = object.__getattribute__(self, 'data')
         if key not in data:
-            raise AttributeError(key)
+            raise AttributeError("Unknown pyconf key: '%s'" % key)
         rv = data[key]
         return self.evaluate(rv)
 
@@ -817,7 +817,7 @@ class Sequence(Container):
         try:
             rv = data[index]
         except (IndexError, KeyError, TypeError):
-            raise ConfigResolutionError('%r is not a valid index for %r' % (index, object.__getattribute__(self, 'path')))
+            raise ConfigResolutionError('Invalid pyconf index %r for %r' % (index, object.__getattribute__(self, 'path')))
         if not isinstance(rv, list):
             rv = self.evaluate(rv)
         else:
index ec06a1ae1131a51edab21bdda6997e6cf6ae2f98..d83d1d81797770f7646012f4951de1af993f0a41 100755 (executable)
@@ -481,8 +481,7 @@ class Sat(object):
                 except Exception as e:
                     # Get error
                     logger_command.write("\n***** ", 1)
-                    logger_command.write(src.printcolors.printcError(
-                                                       "salomeTools ERROR:"), 1)
+                    logger_command.write(src.printcolors.printcError( "salomeTools ERROR: sat %s" % __nameCmd__), 1)
                     logger_command.write("\n" + str(e) + "\n\n", 1)
                     # get stack
                     __, __, exc_traceback = sys.exc_info()
@@ -493,8 +492,7 @@ class Sat(object):
                     verbosity = 5
                     if self.options.debug_mode:
                         verbosity = 1
-                    logger_command.write("TRACEBACK: %s" % stack.replace('"',"'"),
-                                         verbosity)
+                    logger_command.write("TRACEBACK: %s" % stack.replace('"',"'"), verbosity)
                 finally:
                     # set res if it is not set in the command
                     if res is None: