# 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.department = department

    def __str__(self):

        return str(self.firstname) + " " + str(self.lastname) \
               + " [" + str(self.department) + "] " + str(self.login)

    def __eq__(self, other):

        return self.login == other.login

    def find(self, db):
        """Search the User in the database based on its login. If exactly
           one user matches in database, set user_id attribute properly
           and returns its value. If more than one user matches, raises
           HPCStatsDBIntegrityError. If no user is found, returns None.
        """

        req = """
                SELECT userhpc_id
                  FROM Userhpc
                 WHERE userhpc_login = %s
              """
        params = ( self.login, )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("user %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/User.py
import logging
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError

        self.department = department

    def __str__(self):

        return str(self.firstname) + " " + str(self.lastname) \
               + " [" + str(self.department) + "] " + str(self.login)

    def __eq__(self, other):

        return self.login == other.login

    def find(self, db):
        """Search the User in the database based on its login. If exactly
           one user matches in database, set user_id attribute properly
           and returns its value. If more than one user matches, raises
           HPCStatsDBIntegrityError. If no user is found, returns None.
        """

        req = """
                SELECT userhpc_id
                  FROM Userhpc
                 WHERE userhpc_login = %s
              """
        params = ( self.login, )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("user %s not found in DB", str(self))
            return None
        elif nb_rows > 1:

            raise HPCStatsDBIntegrityError(