def __init__(self, command_file, spool_dir):
        """Create writer and add it to the reactor.

        command_file is the path to the nagios pipe
        spool_dir is where to write large commands to
        """

        self.spool_dir = spool_dir
        # Create or cleanup the spool dir
        if os.path.isdir(spool_dir):
            self._cleanup_spool()
        else:
            assert not os.path.exists(spool_dir)
            try:
                os.makedirs(spool_dir)
            except __HOLE__, ex:
                raise errors.InitError(
                        "Cannot create directory %s: %s" % (spool_dir, ex))

        info = os.stat(command_file)
        if not stat.S_ISFIFO(info.st_mode):
            raise errors.InitError(
                    "Command file %s is not a fifo" % command_file)

        self.writer = NagiosWriter(command_file)
dataset/ETHPy150Open marineam/nagcat/python/nagcat/nagios_api.py/NagiosCommander.__init__