"""Errors raisable for the DW reader""" # Copyright 2005, 2006 EIAO Consoritum # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the European Internet Accessibility Observatory # (EIAO) # # EIAO is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # EIAO is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # 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 EIAO; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "Morten Goodwin Olsen" __maintainer__ = "Nils Ulltveit-Moe" __version__ = "$Id: DWError.py 2180 2006-06-19 11:22:34Z goodwin $" class DWReaderError(Exception): """Basic class for reporting Data Warehouse reader errors """ class DWNoCacheProvided(DWReaderError): """Exception when no cache is provided """ def __init__(self,key,dictionary,result,nameofdumpfile): """Throws a DWNoCacheProvided Keyword arguments: key -- Key for lookup dictionary -- dictionary for lookup result -- Result present earlier nameofdumpfile -- The name of the dump file """ msg = 'No cache file provided when reading cache:' + 'Key:%s\nDictionary:%s\nresult:%s\nName of cache file%s\n' %(str(key),str(dictionary),str(result),str(nameofdumpfile)) DWReaderError.__init__(self, msg + message) class DWWrongInputError(DWReaderError): """Exception when wrong input is passed to the DW model. """ def __init__(self,what,message): """Throws a DWWrongInputError Keyword arguments: what -- What inputs that are wrong message -- Additional messages """ msg = 'Wrong input in:' + ' '.join([str(a) for a in what]) + '\n' DWReaderError.__init__(self, msg + message) class DWEmptyInformationError(DWReaderError): """Exception when one of the statical data sets retrieved from the DW is empty """ def __init__(self,what,datalist): """Throws a DWEmptyInformationError Keyword argurments: what -- What is empty. datalist -- The empty dataset (list, string or similar). """ msg = 'Some data is empty that should not be:' DWReaderError.__init__(self,msg + ' '.join([what,str(datalist)])) class DWConnectionError(DWReaderError): """Exception when DW Reader is not able to connect to the Data Warehouse """ def __init__(self,username,database,host): """Throws an DWConnectionError exception. Keyword argumnts: username -- Database Username database -- Database Database host -- Host to connect to """ msg = 'Error connection to DW. Please verify username, password, database and host.\n' variablelist = ' '.join(['Username',str(username),'Password ******','Database',str(database),'Host',str(host)]) DWReaderError.__init__(self,msg + variablelist)