# Path: HPCStats/DB/HPCStatsDB.py
# class HPCStatsDB(object):
# 
#     def __init__(self, conf):
#         """This object is a singleton class, this means only one instance will
#            be created.
#         """
#         self.conf = conf
#         self.section = "hpcstatsdb"
#         self.database = {
#             'dbhostname': self.conf.get(self.section,"hostname"),
#             'dbport':     self.conf.get(self.section,"port"),
#             'dbname':     self.conf.get(self.section,"dbname"),
#             'dbuser':     self.conf.get(self.section,"user"),
#             'dbpassword': self.conf.get(self.section,"password"),
#         }
#         self.cur = None
#         self._conn = None
# 
#     def infos(self):
#         return ( self.database["dbhostname"],
#                  self.database["dbport"],
#                  self.database["dbname"],
#                  self.database["dbuser"],
#                  "XXXXXXXXXX" )
# 
#     def bind(self):
#         """ Connection to the database """
#         conn_str = "host = %(dbhostname)s " \
#                    "dbname= %(dbname)s " \
#                    "user= %(dbuser)s " \
#                    "password= %(dbpassword)s" \
#                      % (self.database)
#         try:
#             self._conn = psycopg2.connect(conn_str)
#         except psycopg2.OperationalError, err:
#             raise HPCStatsRuntimeError( \
#                     "Error while trying to connect on HPCStats DB: %s" \
#                       % (err))
#         self.cur = self._conn.cursor()
#         return self.cur, self._conn
# 
#     def execute(self, req, params):
#         """Execute SQL request req with params. Raises HPCStatsDBIntegrityError
#            in case of problem.
#         """
# 
#         try:
#             self.cur.execute(req, params)
#         except ( psycopg2.DataError,
#                  psycopg2.ProgrammingError,
#                  psycopg2.IntegrityError,
#                  psycopg2.OperationalError ), err:
#             raise HPCStatsDBIntegrityError( \
#                     "error while executing request '%s': %s" \
#                       % (self.cur.mogrify(req, params), err))
# 
#     def unbind(self):
#         """ Disconnect from the database """
#         self._conn.close()
# 
#     def commit(self):
#         self._conn.commit()


import logging
from HPCStats.DB.HPCStatsDB import HPCStatsDB
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with HPCStats. If not, see
# <http://www.gnu.org/licenses/>.
#
# On Calibre systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.

"""This module contains the HPCStatsApp class."""

logger = logging.getLogger(__name__)

class HPCStatsApp(object):

    """Abstract HPCStats application class, parent of all real application
       classes (Importer, Reporter).
    """

    def __init__(self, conf, cluster_name):

        self.conf = conf
        self.cluster_name = cluster_name
        self.cluster = None # Cluster object created later in apps run()

    def new_db(self):
        """Returns a new HPCStatsDB object."""

        # Instantiate connexion to db

# Path: HPCStats/DB/HPCStatsDB.py
# class HPCStatsDB(object):
# 
#     def __init__(self, conf):
#         """This object is a singleton class, this means only one instance will
#            be created.
#         """
#         self.conf = conf
#         self.section = "hpcstatsdb"
#         self.database = {
#             'dbhostname': self.conf.get(self.section,"hostname"),
#             'dbport':     self.conf.get(self.section,"port"),
#             'dbname':     self.conf.get(self.section,"dbname"),
#             'dbuser':     self.conf.get(self.section,"user"),
#             'dbpassword': self.conf.get(self.section,"password"),
#         }
#         self.cur = None
#         self._conn = None
# 
#     def infos(self):
#         return ( self.database["dbhostname"],
#                  self.database["dbport"],
#                  self.database["dbname"],
#                  self.database["dbuser"],
#                  "XXXXXXXXXX" )
# 
#     def bind(self):
#         """ Connection to the database """
#         conn_str = "host = %(dbhostname)s " \
#                    "dbname= %(dbname)s " \
#                    "user= %(dbuser)s " \
#                    "password= %(dbpassword)s" \
#                      % (self.database)
#         try:
#             self._conn = psycopg2.connect(conn_str)
#         except psycopg2.OperationalError, err:
#             raise HPCStatsRuntimeError( \
#                     "Error while trying to connect on HPCStats DB: %s" \
#                       % (err))
#         self.cur = self._conn.cursor()
#         return self.cur, self._conn
# 
#     def execute(self, req, params):
#         """Execute SQL request req with params. Raises HPCStatsDBIntegrityError
#            in case of problem.
#         """
# 
#         try:
#             self.cur.execute(req, params)
#         except ( psycopg2.DataError,
#                  psycopg2.ProgrammingError,
#                  psycopg2.IntegrityError,
#                  psycopg2.OperationalError ), err:
#             raise HPCStatsDBIntegrityError( \
#                     "error while executing request '%s': %s" \
#                       % (self.cur.mogrify(req, params), err))
# 
#     def unbind(self):
#         """ Disconnect from the database """
#         self._conn.close()
# 
#     def commit(self):
#         self._conn.commit()


# Path: HPCStats/CLI/HPCStatsApp.py
import logging
from HPCStats.DB.HPCStatsDB import HPCStatsDB

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with HPCStats. If not, see
# <http://www.gnu.org/licenses/>.
#
# On Calibre systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL'.

"""This module contains the HPCStatsApp class."""

logger = logging.getLogger(__name__)

class HPCStatsApp(object):

    """Abstract HPCStats application class, parent of all real application
       classes (Importer, Reporter).
    """

    def __init__(self, conf, cluster_name):

        self.conf = conf
        self.cluster_name = cluster_name
        self.cluster = None # Cluster object created later in apps run()

    def new_db(self):
        """Returns a new HPCStatsDB object."""

        # Instantiate connexion to db

        db = HPCStatsDB(self.conf)