""" """ # $Header: /cvsroot/dbagg2/lib/dbagg2/config.py,v 1.5 2004/04/15 04:43:36 deusx Exp $ import sys, os, time, logging, logging.config, ConfigParser from mx.DateTime import * import mx.DateTime.ISO from SQLObject import * import TimeRotatingFileHandler logging.getLogger("simpleTAL").setLevel(logging.ERROR) logging.getLogger("simpleTALES").setLevel(logging.ERROR) conf = ConfigParser.ConfigParser() conf.read(os.path.join('conf', 'global.conf')) def iso8601_now(): return mx.DateTime.ISO.str(gmtime(time.time())) #def epoch_to_iso8601(t): return iso8601.ctime(int(t)) #def now(): return str(int(time.time())) # Set up database connection if conf.get('data', 'driver') == 'mysql': so_conn = MySQLConnection(host=conf.get('data_mysql', 'host'), user=conf.get('data_mysql', 'user'), passwd=conf.get('data_mysql', 'passwd'), db=conf.get('data_mysql', 'db')) elif conf.get('data', 'driver') == 'sqlite': so_conn = SQLiteConnection(conf.get('data_sqlite', 'file')) so_conn.supportTransactions = False conn = so_conn.getConnection() #conn.create_function("iso8601_to_epoch", 1, iso8601.parse) #conn.create_function("epoch_to_iso8601", 1, epoch_to_iso8601) #conn.create_function("iso8601_now", 0, iso8601_now) conn.create_function("now", 0, iso8601_now) # Get scan config options update_ramp_up = conf.getfloat('scan', 'update_ramp_up') update_back_off = conf.getfloat('scan', 'update_back_off') min_update_period = conf.getfloat('scan', 'min_update_period') max_update_period = conf.getfloat('scan', 'max_update_period') # Set up logging logging.config.fileConfig(os.path.join('conf', 'global.conf')) main_log = logging.getLogger("") main_log.info("Starting up %s." % (sys.argv[0]))