# 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
                     self.memory / 1024**3 )

    def __eq__(self, other):

        return other.name == self.name and \
               other.cluster == self.cluster

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

        req = """
                SELECT node_id
                  FROM Node
                 WHERE node_name = %s
                   AND cluster_id = %s
              """
        params = ( self.name,
                   self.cluster.cluster_id )

        db.execute(req, params)
        nb_rows = db.cur.rowcount

        if nb_rows == 0:
            logger.debug("node %s not found in DB", str(self))
            return None
        elif nb_rows > 1:

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

                     self.memory / 1024**3 )

    def __eq__(self, other):

        return other.name == self.name and \
               other.cluster == self.cluster

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

        req = """
                SELECT node_id
                  FROM Node
                 WHERE node_name = %s
                   AND cluster_id = %s
              """
        params = ( self.name,
                   self.cluster.cluster_id )

        db.execute(req, params)
        nb_rows = db.cur.rowcount

        if nb_rows == 0:
            logger.debug("node %s not found in DB", str(self))
            return None
        elif nb_rows > 1:

            raise HPCStatsDBIntegrityError(