From 73cab6236ff404d98bab295e958ce21a7cf2b5c5 Mon Sep 17 00:00:00 2001 From: SRE Date: Fri, 2 Jun 2017 14:22:44 +0200 Subject: [PATCH] add a call to a file to the distene licence for SALOME pacakges --- commands/jobs.py | 17 +++++++++-------- commands/package.py | 41 +++++++++++++++++++++++++++++++++++++++++ src/fileEnviron.py | 12 ++---------- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/commands/jobs.py b/commands/jobs.py index 698b3c5..56f19d7 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -832,6 +832,15 @@ class Jobs(object): self.logger.flush() res_copy = machine.copy_sat(self.runner.cfg.VARS.salometoolsway, self.job_file_path) + + # set the local settings of sat on the remote machine using + # the init command + (__, __, __) = machine.exec_command( + os.path.join(machine.sat_path, + "sat init --base unknown --workdir unknown" + " --log_dir unknown"), + self.logger) + # get the remote machine distribution using a sat command (__, out_dist, __) = machine.exec_command( os.path.join(machine.sat_path, @@ -840,14 +849,6 @@ class Jobs(object): machine.distribution = out_dist.read().decode().replace("\n", "") - # set the local settings of sat on the remote machine using - # the init command - (__, __, __) = machine.exec_command( - os.path.join(machine.sat_path, - "sat init --base unknown --workdir unknown" - " --log_dir unknown"), - self.logger) - # Print the status of the copy if res_copy == 0: self.logger.write('\r%s' % diff --git a/commands/package.py b/commands/package.py index 593834b..89a8197 100644 --- a/commands/package.py +++ b/commands/package.py @@ -214,6 +214,10 @@ def produce_relative_launcher(config, # Little hack to put out_dir_Path outside the strings src.replace_in_file(filepath, 'r"out_dir_Path', 'out_dir_Path + r"' ) + # A hack to put a call to a file for distene licence. + # It does nothing to an application that has no distene product + hack_for_distene_licence(filepath) + # change the rights in order to make the file executable for everybody os.chmod(filepath, stat.S_IRUSR | @@ -226,6 +230,43 @@ def produce_relative_launcher(config, return filepath +def hack_for_distene_licence(filepath): + '''Replace the distene licence env variable by a call to a file. + + :param filepath Str: The path to the launcher to modify. + ''' + shutil.move(filepath, filepath + "_old") + fileout= filepath + filein = filepath + "_old" + fin = open(filein, "r") + fout = open(fileout, "w") + text = fin.readlines() + # Find the Distene section + num_line = -1 + for i,line in enumerate(text): + if "# Set DISTENE License" in line: + num_line = i + break + if num_line == -1: + # No distene product, there is nothing to do + fin.close() + fout.close() + return + del text[num_line +1] + del text[num_line +1] + text_to_insert =""" import imp + try: + distene = imp.load_source('distene_licence', '/data/tmpsalome/salome/prerequis/install/LICENSE/dlim8.var.py') + distene.set_distene_variables(context) + except: + pass\n""" + text.insert(num_line + 1, text_to_insert) + for line in text: + fout.write(line) + fin.close() + fout.close() + return + def produce_relative_env_files(config, logger, file_dir, diff --git a/src/fileEnviron.py b/src/fileEnviron.py index 27071d0..ab43f3c 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -539,17 +539,9 @@ class LauncherFileEnviron: self.prefix+ self.setVarEnv+ '(r"%s", r"%s", overwrite=True)\n' % - ('DISTENE_LICENCE_FILE_FOR_MGCLEANER', + ('DLIM8VAR', self.change_to_launcher( - ''))) - self.output.write(self.indent+ - "#"+ - self.prefix+ - self.setVarEnv+ - '(r"%s", r"%s", overwrite=True)\n' % - ('DISTENE_LICENCE_FILE_FOR_YAMS', - self.change_to_launcher( - ''))) + ''))) return if "setting environ for" in comment: self.output.write(self.indent+"#[%s]\n" % -- 2.39.2