# 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.cluster.name )

    def __eq__(self, other):

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

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

        req = """
                SELECT filesystem_id
                  FROM filesystem
                 WHERE filesystem_name = %s
                   AND cluster_id = %s
              """
        params = ( self.mountpoint,
                   self.cluster.cluster_id )

        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("filesystem %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/Filesystem.py
import logging
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError

                     self.cluster.name )

    def __eq__(self, other):

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

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

        req = """
                SELECT filesystem_id
                  FROM filesystem
                 WHERE filesystem_name = %s
                   AND cluster_id = %s
              """
        params = ( self.mountpoint,
                   self.cluster.cluster_id )

        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("filesystem %s not found in DB", str(self))
            return None
        elif nb_rows > 1:

            raise HPCStatsDBIntegrityError(