def test_connection(self): try: Stats(config, test=True) db_conn = True except: db_conn = False self.assertTrue(db_conn)
def push_to_db(self, stats): try: db = Stats(self.config) db.insert(stats) log.util.info("stats pushed to database") except Exception, error: log.util.critical("thread unable to push stats: %s" % error)
def main(config=CONF): try: # Initialize the DB local.db = Stats(config) # Start the waskr server run(host=config['web_host'], port=config['web_port']) except Exception, e: print "Couldn't start the waskr server:\n%s" % e
def __init__(self, *args, **params): unittest.TestCase.__init__(self, *args, **params) self.db_name = config['db_location'] self.conn = sqlite3.connect(self.db_name) self.c = self.conn.cursor() print self.db_name self.db = Stats(config, test=True) self.single_stat = dict(time=9999, response=9999, url='/', application='foo', server_id=1)
def __init__(self, *args, **params): unittest.TestCase.__init__(self, *args, **params) connection = Connection( config['db_host'], config['db_port']) self.waskr = connection['test_waskr'] self.stats = self.waskr['stats'] self.users = self.waskr['user'] self.db = Stats(config, test=True) self.single_stat = dict( time = 9999, response = 9999, url = '/', application = 'foo', server_id = '1' )