def __init__(self, db=None, dbhost=None, dbport=None, dbname=None, whitelist=None, blacklist=None): self.tracers = [] self._trace_class = PyTracer if db: self.dbhost, self.dbport, self.dbname = conf.get_dbdetails(db) else: self.dbhost = dbhost or conf.DBHOST self.dbport = dbport or conf.DBPORT self.dbname = dbname or conf.DBNAME self.blacklist = conf.get_blacklist(blacklist) self.whitelist = conf.get_whitelist(whitelist) log.info('using: %r, %r, %r, %r, %r' % (self.dbhost, self.dbport, self.dbname, [x.pattern for x in self.whitelist], [x.pattern for x in self.blacklist]))
def sys_enable(db=None, dbhost=conf.DBHOST, dbport=conf.DBPORT, dbname=conf.DBNAME, whitelist=conf.WHITELIST, blacklist=conf.BLACKLIST): '''enable system-wide coverage stats collecting; requires permissions''' if db is not None: # convert to connection/port/name dbhost, dbport, dbname = conf.get_dbdetails(db) code = get_collecting_code(dbhost=dbhost, dbport=dbport, dbname=dbname, whitelist=whitelist, blacklist=blacklist) log.debug("code to use: %r" % code) import os from distutils import sysconfig import re # FIXME: implement with setup?? filename = os.path.join(sysconfig.get_python_lib(), SITE_FILENAME) try: with open(filename, 'w+') as fd: fd.write(code) except Exception as e: log.warning("couldn't dump code to %s: %r" % (filename, e)) else: log.info('written: %s' % filename)