# 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.key = key
        self.name = name

        self.exists = None

    def __str__(self):

        return "domain [%s] %s" % (self.key, self.name)

    def __eq__(self, domain):

        return domain.key == self.key

    def existing(self, db):
        """Returns True if the domain already exists in database (same key), or
           False if not.
        """

        req = """
                SELECT domain_id
                  FROM Domain
                 WHERE domain_id = %s
              """
        params = ( self.key, )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("domain %s not found in DB", str(self))
            self.exists = False
        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/Domain.py
import logging
from HPCStats.Exceptions import HPCStatsDBIntegrityError, HPCStatsRuntimeError

        self.key = key
        self.name = name

        self.exists = None

    def __str__(self):

        return "domain [%s] %s" % (self.key, self.name)

    def __eq__(self, domain):

        return domain.key == self.key

    def existing(self, db):
        """Returns True if the domain already exists in database (same key), or
           False if not.
        """

        req = """
                SELECT domain_id
                  FROM Domain
                 WHERE domain_id = %s
              """
        params = ( self.key, )
        db.execute(req, params)
        nb_rows = db.cur.rowcount
        if nb_rows == 0:
            logger.debug("domain %s not found in DB", str(self))
            self.exists = False
        elif nb_rows > 1:

            raise HPCStatsDBIntegrityError(