Salome HOME
add a call to a file to the distene licence for SALOME pacakges
authorSRE <serge.rehbinder@cea.fr>
Fri, 2 Jun 2017 12:22:44 +0000 (14:22 +0200)
committerSRE <serge.rehbinder@cea.fr>
Fri, 2 Jun 2017 12:22:44 +0000 (14:22 +0200)
commands/jobs.py
commands/package.py
src/fileEnviron.py

index 698b3c5cfb1426e72ef2c5afa185563c0588fa51..56f19d78d3229da8c01f7371f460b99235718bf0 100644 (file)
@@ -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' % 
index 593834bfa7acfaf1b1171a7b75c5a9896ea6b30b..89a8197510a04959516fc594bc8a20b7983eeac0 100644 (file)
@@ -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,
index 27071d0be384cb81a79dc4356d38a78cf30fca78..ab43f3cbc42af9019b9add3f48af26b683d3bad5 100644 (file)
@@ -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(
-                                                '<path to your license>')))
-            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(
-                                                    '<path to your license>')))
+                                                '<your licence>')))
             return
         if "setting environ for" in comment:
             self.output.write(self.indent+"#[%s]\n" %