From: Christian Van Wambeke Date: Tue, 18 Dec 2018 10:00:52 +0000 (+0100) Subject: fix sat#13081 'sat package -t' X-Git-Tag: 5.3.0~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4f84485a534ccc2161fbcb42705bb4acfc1db372;p=tools%2Fsat.git fix sat#13081 'sat package -t' --- diff --git a/commands/package.py b/commands/package.py index 64da2bd..a54408b 100644 --- a/commands/package.py +++ b/commands/package.py @@ -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()) diff --git a/src/pyconf.py b/src/pyconf.py index 2a655ca..5957d6d 100644 --- a/src/pyconf.py +++ b/src/pyconf.py @@ -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: diff --git a/src/salomeTools.py b/src/salomeTools.py index ec06a1a..d83d1d8 100755 --- a/src/salomeTools.py +++ b/src/salomeTools.py @@ -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: