예제 #1
0
def drop(db=None, host=conf.DBHOST, port=conf.DBPORT, name=conf.DBNAME):
    '''drop the coverage db'''
    try:
        if db is None:
            db = conf.get_db(host, port, name)
    except Exception as e:
        log.warning("couldn't get db %r, %r, %r: %r" % (host, port, name, e))
    else:
        try:
            db.flushdb()
        except Exception as e:
            log.warning('failed to drop %r: %r' % (db, e))
        else:
            log.info("dropped: %r" % db)
예제 #2
0
 def __init__(self, dbhost="localhost", dbport=6379, dbname=0, blacklist=[], whitelist=[]):
     self.blacklist = blacklist
     self.whitelist = whitelist
     self._should_process = getattr(sys.modules[__name__], '_SHOULD_TRACE')
     self.last_lineno = -1
     self.last_exc_back = None
     # contains a history of self.last_linenos
     self.stack = []
     try:
         import conf
         self.db = conf.get_db(dbhost, dbport, dbname)
         # create a redis pipeline. pipeline.execute() need not
         # be transactional --- all operations should be just increments
         self.pipeline = self.db.pipeline(transaction=False)
     except Exception as e:
         log.error("got: %r, disabling." % e)
         self.stop()
     else:
         self.enabled = True
         log.info('%r using: %r' % (self, self.pipeline))
예제 #3
0
def init(db=None, dbhost=conf.DBHOST, dbport=conf.DBPORT, dbname=conf.DBNAME):
    '''initialize necessary events collection'''
    if db is None:
        db = conf.get_db(dbhost=dbhost, dbport=dbport, dbname=dbname)
    return db