def log_finish(self, host, user, crabid, command, status, stdout=None, stderr=None): """Inserts a job finish record into the database. The output will be passed to the write_job_output method, unless both stdout and stderr are empty.""" with self.lock as c: id_ = self._check_job(c, host, user, crabid, command) # Fetch the configuration so that we can check the status. config = self._get_job_config(c, id_) if config is not None: status = check_status_patterns( status, config, '\n'.join((x for x in (stdout, stderr) if x is not None))) finishid = self._log_finish(c, id_, command, status) if stdout or stderr: # If a crabid was not specified, check whether the job # actually has one. This is to avoid sending misleading # parameters to write_job_output, which can cause the # file-based output store to default to a numeric directory name. if crabid is None: info = self.get_job_info(id_) crabid = info['crabid'] self.write_job_output(finishid, host, user, id_, crabid, stdout, stderr)
def log_finish(self, host, user, crabid, command, status, stdout=None, stderr=None): """Inserts a job finish record into the database. The output will be passed to the write_job_output method, unless both stdout and stderr are empty.""" with self.lock: c = self.conn.cursor() try: id_ = self._check_job(host, user, crabid, command) # Fetch the configuration so that we can check the status. config = self._get_job_config(id_) if config is not None: status = check_status_patterns( status, config, '\n'.join((x for x in (stdout, stderr) if x is not None))) c.execute('INSERT INTO jobfinish (jobid, command, status) ' + 'VALUES (?, ?, ?)', [id_, command, status]) finishid = c.lastrowid except DatabaseError as err: raise CrabError('database error: ' + str(err)) finally: c.close() if stdout or stderr: # If a crabid was not specified, check whether the job # actually has one. This is to avoid sending misleading # parameters to write_job_output, which can cause the # file-based output store to default to a numeric directory name. if crabid is None: info = self.get_job_info(id_) crabid = info['crabid'] self.write_job_output(finishid, host, user, id_, crabid, stdout, stderr)