def __init__(self, rradir, rrdcache=None):
        if rrdtool is None:
            raise errors.InitError(
                    "The python module 'rrdtool' is not installed")

        if not os.path.exists(rradir):
            try:
                os.makedirs(rradir)
            except __HOLE__, ex:
                raise errors.InitError("Cannot create %r: %s" % (rradir, ex))
        elif not os.path.isdir(rradir):
            raise errors.InitError("%r is not a directory!" % rradir)
        elif not os.access(rradir, os.R_OK | os.W_OK | os.X_OK):
            raise errors.InitError(
                    "%r is not readable and/or writeable!" % rradir)

        def opened_ok(result):
            log.info("Connected to rrdcached on %s", rrdcache)

        def opened_fail(result):
            log.error("Failed to connect to rrdcached: %s" % result)

        self._rradir = rradir
        self._rrdapi = RRDTwistedAPI()
        if rrdcache:
            d = self._rrdapi.open(rrdcache)
            d.addCallback(opened_ok)
            d.addErrback(opened_fail)
        else:
            log.info("No rrdcached, updates will be direct.")
dataset/ETHPy150Open marineam/nagcat/python/nagcat/trend.py/TrendMaster.__init__