# 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
                   AND node_id = %s
                   AND job_id = %s
              """
        params = ( self.cluster.cluster_id,
                   self.node.node_id,
                   self.job.job_id )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("run %s not found in DB", str(self))
            self.exists = False
        elif nb_rows > 1:
            raise HPCStatsDBIntegrityError(
                    "several run found in DB for run %s" \
                      % (str(self)))
        else:
            logger.debug("run %s found in DB", str(self))
            self.exists = True
        return self.exists

    def save(self, db):
        """Insert Run in database. It first makes sure that the Run does not
           already exist in database yet by calling Run.existing() method if
           needed. If the Run already exists in database, it raises
           HPCStatsRuntimeError.
        """

        if self.exists is None: # not checked yet
            self.existing(db)
        if self.exists is True:

# 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/Run.py
import logging
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError

                   AND node_id = %s
                   AND job_id = %s
              """
        params = ( self.cluster.cluster_id,
                   self.node.node_id,
                   self.job.job_id )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("run %s not found in DB", str(self))
            self.exists = False
        elif nb_rows > 1:
            raise HPCStatsDBIntegrityError(
                    "several run found in DB for run %s" \
                      % (str(self)))
        else:
            logger.debug("run %s found in DB", str(self))
            self.exists = True
        return self.exists

    def save(self, db):
        """Insert Run in database. It first makes sure that the Run does not
           already exist in database yet by calling Run.existing() method if
           needed. If the Run already exists in database, it raises
           HPCStatsRuntimeError.
        """

        if self.exists is None: # not checked yet
            self.existing(db)
        if self.exists is True:

            raise HPCStatsRuntimeError(