+ def put_jobs_not_today(self, l_jobs_not_today, xml_node_jobs):
+ '''Get all the first information needed for each file and write the
+ first version of the files
+
+ :param xml_node_jobs etree.Element: the node corresponding to a job
+ :param l_jobs_not_today List: the list of jobs that do not run today
+ '''
+ for job in l_jobs_not_today:
+ xmlj = src.xmlManager.add_simple_node(xml_node_jobs,
+ "job",
+ attrib={"name" : job.name})
+ src.xmlManager.add_simple_node(xmlj, "application", job.application)
+ src.xmlManager.add_simple_node(xmlj,
+ "distribution",
+ job.machine.distribution)
+ src.xmlManager.add_simple_node(xmlj, "board", job.board)
+ src.xmlManager.add_simple_node(xmlj,
+ "commands", " ; ".join(job.commands))
+ src.xmlManager.add_simple_node(xmlj, "state", "Not today")
+ src.xmlManager.add_simple_node(xmlj, "machine", job.machine.name)
+ src.xmlManager.add_simple_node(xmlj, "host", job.machine.host)
+ src.xmlManager.add_simple_node(xmlj, "port", str(job.machine.port))
+ src.xmlManager.add_simple_node(xmlj, "user", job.machine.user)
+ src.xmlManager.add_simple_node(xmlj, "sat_path",
+ job.machine.sat_path)
+
+ def parse_csv_boards(self, today):
+ """ Parse the csv files that describes the boards to produce and fill
+ the dict d_input_boards that contain the csv file contain
+
+ :param today int: the current day of the week
+ """
+ # loop over each csv file and read its content
+ l_read = []
+ with open(self.file_boards, 'r') as f:
+ reader = csv.reader(f,delimiter=CSV_DELIMITER)
+ for row in reader:
+ l_read.append(row)
+ # get the delimiter for the boards (empty line)
+ boards_delimiter = [''] * len(l_read[0])
+ # Make the list of boards, by splitting with the delimiter
+ l_boards = [list(y) for x, y in itertools.groupby(l_read,
+ lambda z: z == boards_delimiter) if not x]
+
+ # loop over the csv lists of lines and get the rows, columns and jobs
+ d_boards = {}
+ for input_board in l_boards:
+ # get board name
+ board_name = input_board[0][0]
+
+ # Get columns list
+ columns = input_board[0][1:]
+
+ rows = []
+ columns_out = []
+ jobs = []
+ for line in input_board[1:]:
+ row = line[0]
+ for i, square in enumerate(line[1:]):
+ if square=='':
+ continue
+ days = square.split(DAYS_SEPARATOR)
+ days = [int(day) for day in days]
+ if today in days:
+ if row not in rows:
+ rows.append(row)
+ if columns[i] not in columns_out:
+ columns_out.append(columns[i])
+ job = (row, columns[i])
+ jobs.append(job)
+
+ d_boards[board_name] = {"rows" : rows,
+ "columns" : columns_out,
+ "jobs" : jobs}
+
+ self.d_input_boards = d_boards
+
+ def update_xml_files(self, l_jobs):
+ '''Write all the xml files with updated information about the jobs
+
+ :param l_jobs List: the list of jobs that run today
+ '''
+ for xml_file in [self.xml_global_file] + list(
+ self.d_xml_board_files.values()):
+ self.update_xml_file(l_jobs, xml_file)
+
+ # Write the file
+ self.write_xml_files()
+
+ def update_xml_file(self, l_jobs, xml_file):
+ '''update information about the jobs for the file xml_file
+
+ :param l_jobs List: the list of jobs that run today
+ :param xml_file xmlManager.XmlLogFile: the xml instance to update
+ '''
+
+ xml_node_jobs = xml_file.xmlroot.find('jobs')
+ # Update the job names and status node
+ for job in l_jobs:
+ # Find the node corresponding to the job and delete it
+ # in order to recreate it
+ for xmljob in xml_node_jobs.findall('job'):
+ if xmljob.attrib['name'] == job.name:
+ xml_node_jobs.remove(xmljob)
+
+ T0 = str(job._T0)
+ if T0 != "-1":
+ T0 = time.strftime('%Y-%m-%d %H:%M:%S',
+ time.localtime(job._T0))
+ Tf = str(job._Tf)
+ if Tf != "-1":
+ Tf = time.strftime('%Y-%m-%d %H:%M:%S',
+ time.localtime(job._Tf))
+
+ # recreate the job node
+ xmlj = src.xmlManager.add_simple_node(xml_node_jobs,
+ "job",
+ attrib={"name" : job.name})
+ src.xmlManager.add_simple_node(xmlj, "machine", job.machine.name)
+ src.xmlManager.add_simple_node(xmlj, "host", job.machine.host)
+ src.xmlManager.add_simple_node(xmlj, "port", str(job.machine.port))
+ src.xmlManager.add_simple_node(xmlj, "user", job.machine.user)
+ src.xmlManager.add_simple_node(xmlj, "sat_path",
+ job.machine.sat_path)
+ src.xmlManager.add_simple_node(xmlj, "application", job.application)
+ src.xmlManager.add_simple_node(xmlj, "distribution",
+ job.machine.distribution)
+ src.xmlManager.add_simple_node(xmlj, "board", job.board)
+ src.xmlManager.add_simple_node(xmlj, "timeout", str(job.timeout))
+ src.xmlManager.add_simple_node(xmlj, "commands",
+ " ; ".join(job.commands))
+ src.xmlManager.add_simple_node(xmlj, "state", job.get_status())
+ src.xmlManager.add_simple_node(xmlj, "begin", T0)
+ src.xmlManager.add_simple_node(xmlj, "end", Tf)
+ src.xmlManager.add_simple_node(xmlj, "out",
+ src.printcolors.cleancolor(job.out))
+ src.xmlManager.add_simple_node(xmlj, "err",
+ src.printcolors.cleancolor(job.err))
+ src.xmlManager.add_simple_node(xmlj, "res", str(job.res_job))
+ if len(job.remote_log_files) > 0:
+ src.xmlManager.add_simple_node(xmlj,
+ "remote_log_file_path",
+ job.remote_log_files[0])
+ else:
+ src.xmlManager.add_simple_node(xmlj,
+ "remote_log_file_path",
+ "nothing")
+
+ xmlafter = src.xmlManager.add_simple_node(xmlj, "after", job.after)
+ # get the job father
+ if job.after is not None:
+ job_father = None
+ for jb in l_jobs:
+ if jb.name == job.after:
+ job_father = jb
+
+ if (job_father is not None and
+ len(job_father.remote_log_files) > 0):
+ link = job_father.remote_log_files[0]
+ else:
+ link = "nothing"
+ src.xmlManager.append_node_attrib(xmlafter, {"link" : link})
+
+ # Verify that the job is to be done today regarding the input csv
+ # files
+ if job.board and job.board in self.d_input_boards.keys():
+ found = False
+ for dist, appli in self.d_input_boards[job.board]["jobs"]:
+ if (job.machine.distribution == dist
+ and job.application == appli):
+ found = True
+ src.xmlManager.add_simple_node(xmlj,
+ "extra_job",
+ "no")
+ break
+ if not found:
+ src.xmlManager.add_simple_node(xmlj,
+ "extra_job",
+ "yes")
+
+
+ # Update the date
+ xml_node_infos = xml_file.xmlroot.find('infos')
+ src.xmlManager.append_node_attrib(xml_node_infos,
+ attrib={"value" :
+ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")})
+
+