Salome HOME
sat jobs: remove the empty columns from the boards.
[tools/sat.git] / commands / jobs.py
index fa1db0894d34b560bcd025cf9eb874e43beb9224..3c0e17a5e4ebb6eae82a4d080264e850cd93f970 100644 (file)
@@ -318,13 +318,16 @@ class Job(object):
         :return: (the output of the kill, the error of the kill)
         :rtype: (str, str)
         '''
-        
-        pids = self.get_pids()
+        try:
+            pids = self.get_pids()
+        except:
+            return ("Unable to get the pid of the command.", "")
+            
         cmd_kill = " ; ".join([("kill -2 " + pid) for pid in pids])
         (_, out_kill, err_kill) = self.machine.exec_command(cmd_kill, 
                                                             self.logger)
         time.sleep(wait)
-        return (out_kill, err_kill)
+        return (out_kill.read().decode(), err_kill.read().decode())
             
     def has_begun(self):
         '''Returns True if the job has already begun
@@ -509,14 +512,24 @@ class Job(object):
             self._has_finished = True
             self._has_timouted = True
             self._Tf = time.time()
-            self.get_pids()
             (out_kill, _) = self.kill_remote_process()
-            self.out += "TIMEOUT \n" + out_kill.read().decode()
+            self.out += "TIMEOUT \n" + out_kill
             self.err += "TIMEOUT : %s seconds elapsed\n" % str(self.timeout)
             try:
                 self.get_log_files()
             except Exception as e:
-                self.err += _("Unable to get remote log files: %s" % e)
+                # The 2 following lines must be suppressed after the bug is fixed
+                print("The error type: ")
+                print(type(e))
+                print("The error: ")
+                print(e)
+                print("Local scope:")
+                print(dir())
+                print("The str type: ")
+                print(type(str))
+                print("str: ")
+                print(str)
+                self.err += _("Unable to get remote log files!")
             
     def total_duration(self):
         """Give the total duration of the job
@@ -764,8 +777,11 @@ class Jobs(object):
                     msg = _("WARNING: The job \"%(job_name)s\" requires the "
                             "machine \"%(machine_name)s\" but this machine "
                             "is not defined in the configuration file.\n"
-                            "The job will not be launched")
-                    self.logger.write(src.printcolors.printcWarning(msg))
+                            "The job will not be launched\n")
+                    self.logger.write(src.printcolors.printcWarning(
+                                        msg % {"job_name" : job_def.name,
+                                               "machine_name" : name_machine}))
+                    continue
                                   
             a_job = self.define_job(job_def, a_machine)
                 
@@ -1174,7 +1190,8 @@ class Gui(object):
                 continue
             for board in self.d_xml_board_files:
                 if board_job == board:
-                    if distrib is not None and distrib not in d_dist[board]:
+                    if (distrib not in [None, ''] and 
+                                            distrib not in d_dist[board]):
                         d_dist[board].append(distrib)
                         src.xmlManager.add_simple_node(
                             self.d_xml_board_files[board].xmlroot.find(
@@ -1183,7 +1200,7 @@ class Gui(object):
                                                    attrib={"name" : distrib})
                     
                 if board_job == board:
-                    if (application is not None and 
+                    if (application not in [None, ''] and 
                                     application not in d_application[board]):
                         d_application[board].append(application)
                         src.xmlManager.add_simple_node(
@@ -1315,7 +1332,6 @@ class Gui(object):
                     self.logger.write("%s\n" % src.printcolors.printcWarning(
                                                                         msg), 5)
                     
-
         # Construct the dictionnary self.history 
         for job in l_jobs + l_jobs_not_today:
             l_links = []
@@ -1681,10 +1697,10 @@ def run(args, runner, logger):
     for config_file in options.jobs_cfg:
         found, file_jobs_cfg = get_config_file_path(config_file, l_cfg_dir)
         if not found:
-            msg = _("The file configuration %(name_file)s was not found."
+            msg = _("The file configuration %s was not found."
                     "\nUse the --list option to get the "
                     "possible files." % config_file)
-            src.printcolors.printcError(msg)
+            logger.write("%s\n" % src.printcolors.printcError(msg), 1)
             return 1
         l_conf_files_path.append(file_jobs_cfg)
         # Read the config that is in the file
@@ -1714,6 +1730,12 @@ def run(args, runner, logger):
     f = file( path_pyconf , 'w')
     config_jobs.__save__(f)
     
+    # log the paramiko problems
+    paramiko_log_dir_path = os.path.join(runner.cfg.USER.log_dir, "JOBS")
+    src.ensure_path_exists(paramiko_log_dir_path)
+    paramiko.util.log_to_file(os.path.join(paramiko_log_dir_path,
+                                           logger.txtFileName))
+    
     # Initialization
     today_jobs = Jobs(runner,
                       logger,