def db_init(self, schema ): """ function to initialize a database's table(s) in the event they have not already been initialized. """ #TODO: initialize the database schema try: pass except: raise Exceptions.ConfigFault("Couldn't initialize database")
def db_init(self, schema): """ function to initialize a database's table(s) in the event they have not already been initialized. schema here is the XML schema, filename, or open file handle, which gets turned into a DBSchema object """ #TODO: initialize the database schema try: pass except: raise Exceptions.ConfigFault("Couldn't initialize database")
def __init__(self, host, port, user, password, db, cursorclass="dict"): """ Class to use to connect to Mysql database. Must specify host, port, user, password and database. Default cursor is dict unless otherwise specified. """ self.host = host try: self.port = int(port) except ValueError, e: raise Exceptions.DatabaseConnectError(e)
def _validate_loglevel(self, level): _level = level if isinstance(_level, str): result = logging.getLevelName(_level) if isinstance(result, int): return result else: raise Exceptions.InvalidLogLevelType( "'%s' in not a valid log level" % _level) else: return _level
def _validate_syslogfacility(self, level): _level = level if isinstance(_level, str): result = logging.handlers.SysLogHandler.facility_names.get( _level.lower()) if result: return result else: raise Exceptions.InvalidSyslogFacilityType( "'%s' is not a valid Syslog facility level" % _level) else: return _level
def _check_dirpath(self, filename): try: _dirname = os.path.dirname(filename) if not _dirname: _dirname = os.path.curdir if all( [os.access(_dirname, os.R_OK), os.access(_dirname, os.W_OK)]): return filename else: raise Exceptions.DirectoryAccessError( "Unable to read or write to directory location '%s'" % _dirname) except AttributeError: # If original 'None' type is passed in return None
_ver = Version(int(cfg.get_value('version.major')), int(cfg.get_value('version.minor')), int(cfg.get_value('version.patch'))) loglevel = cfg.get_value('logging.loglevel') logcfg = LoggerConfig(loglevel, **cfg.config) logging.config.dictConfig(logcfg.config) log = logging.getLogger() """ Verify that the configuration file is defined and that our database type is defined. """ try: cfg except NameError: raise Exceptions.ConfigFault( "configuration file not defined as 'cfg', that's a no no.") #NOTE: this is optional for some projects. try: cfg.get_value('db.type') except Exception as e: print "database type not defined in configuration file" sys.exit(1) try: db = None if cfg.get_value(db.type): if cfg.get_value(db.type) == 'mysql': #TODO: attempt the database connection using the MySQL pass elif cfg.get_value(db.type) == 'sqlite3': try: