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


import logging
from HPCStats.Exceptions import HPCStatsRuntimeError, HPCStatsDBIntegrityError
               self.nb_cpu == other.nb_cpu and \
               self.start_datetime == other.start_datetime and \
               self.end_datetime == other.end_datetime and \
               self.event_type == other.event_type and \
               self.reason == other.reason

    def find(self, db):
        """Search the Event in the database based on the node, the cluster,
           the start and the end datetime. If exactly one event matches in
           database, set event_id attribute properly and returns its value.
           If more than one event matches, raises HPCStatsDBIntegrityError.
           If no event is found, returns None.
        """

        req = """
                SELECT Event.event_id
                  FROM Event
                 WHERE Event.node_id = %s
                   AND Event.cluster_id = %s
                   AND Event.event_start = %s
              """
        params = ( self.node.node_id,
                   self.cluster.cluster_id,
                   self.start_datetime )
        db.execute(req, params)
        nb_events = db.cur.rowcount
        if nb_events == 0:
            logger.debug("event %s not found in DB", str(self))
            return None
        elif nb_events > 1:

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


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

               self.nb_cpu == other.nb_cpu and \
               self.start_datetime == other.start_datetime and \
               self.end_datetime == other.end_datetime and \
               self.event_type == other.event_type and \
               self.reason == other.reason

    def find(self, db):
        """Search the Event in the database based on the node, the cluster,
           the start and the end datetime. If exactly one event matches in
           database, set event_id attribute properly and returns its value.
           If more than one event matches, raises HPCStatsDBIntegrityError.
           If no event is found, returns None.
        """

        req = """
                SELECT Event.event_id
                  FROM Event
                 WHERE Event.node_id = %s
                   AND Event.cluster_id = %s
                   AND Event.event_start = %s
              """
        params = ( self.node.node_id,
                   self.cluster.cluster_id,
                   self.start_datetime )
        db.execute(req, params)
        nb_events = db.cur.rowcount
        if nb_events == 0:
            logger.debug("event %s not found in DB", str(self))
            return None
        elif nb_events > 1:

            raise HPCStatsDBIntegrityError(