# Path: HPCStats/Exceptions.py
# class HPCStatsDBIntegrityError(HPCStatsException):
# 
#     """Class for DB intregrity errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsDBIntegrityError, self).__init__(msg)
# 
# class HPCStatsRuntimeError(HPCStatsException):
# 
#     """Class for runtime errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsRuntimeError, self).__init__(msg)


import logging
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError
                 WHERE cluster_id = %s
                   AND job_batch_id = %s
              """
        params = ( self.account.cluster.cluster_id,
                   self.batch_id )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("job %s not found in DB", str(self))
            return None
        elif nb_rows > 1:
            raise HPCStatsDBIntegrityError(
                    "several job_id found in DB for job %s" \
                      % (str(self)))
        else:
            self.job_id = db.cur.fetchone()[0]
            logger.debug("job %s found in DB with id %d",
                          str(self),
                          self.job_id )
            return self.job_id

    def save(self, db):
        """Insert Job in database. You must make sure that the Job does not
           already exist in database yet (typically using Job.find() method
           else there is a risk of future integrity errors because of
           duplicated jobs. If job_id attribute is set, it raises
           HPCStatsRuntimeError.
        """

        if self.job_id is not None:

# Path: HPCStats/Exceptions.py
# class HPCStatsDBIntegrityError(HPCStatsException):
# 
#     """Class for DB intregrity errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsDBIntegrityError, self).__init__(msg)
# 
# class HPCStatsRuntimeError(HPCStatsException):
# 
#     """Class for runtime errors exceptions in HPCStats"""
# 
#     def __init__(self, msg):
# 
#         super(HPCStatsRuntimeError, self).__init__(msg)


# Path: HPCStats/Model/Job.py
import logging
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError

                 WHERE cluster_id = %s
                   AND job_batch_id = %s
              """
        params = ( self.account.cluster.cluster_id,
                   self.batch_id )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("job %s not found in DB", str(self))
            return None
        elif nb_rows > 1:
            raise HPCStatsDBIntegrityError(
                    "several job_id found in DB for job %s" \
                      % (str(self)))
        else:
            self.job_id = db.cur.fetchone()[0]
            logger.debug("job %s found in DB with id %d",
                          str(self),
                          self.job_id )
            return self.job_id

    def save(self, db):
        """Insert Job in database. You must make sure that the Job does not
           already exist in database yet (typically using Job.find() method
           else there is a risk of future integrity errors because of
           duplicated jobs. If job_id attribute is set, it raises
           HPCStatsRuntimeError.
        """

        if self.job_id is not None:

            raise HPCStatsRuntimeError(