def start(self, task_name):
        """ Starts a new task matching the provided name.

            `task_name`
                Name of existing task to start.

            Returns boolean.

            * Raises a ``TaskNotFound`` exception if task doesn't exist, an
              ``InvalidTaskConfig` exception if task config file is invalid, or
              ``DaemonFailStart`` exception if task daemons failed to fork.
            """

        self._clean_prior()

        if self._loaded:
            raise errors.ActiveTask

        # get paths
        task_dir = os.path.join(self._paths['base_dir'], 'tasks', task_name)
        task_config = os.path.join(task_dir, 'task.cfg')

        if not os.path.isdir(task_dir):
            raise errors.TaskNotFound(task_name)

        try:
            # raise if task config is missing
            if not os.path.isfile(task_config):
                reason = u"Config file could not be found."
                raise errors.InvalidTaskConfig(task_config, reason=reason)

            # parse task config and send its options to registered plugins
            _parser = parser.parse_config(task_config, self.HEADER_TASK_CONFIG)
            registration.run_option_hooks(_parser)

        except parser.ParseError as exc:
            raise errors.InvalidTaskConfig(task_config,
                                           reason=unicode(exc))

        # populate task info
        self._name = common.from_utf8(task_name)
        self._start_time = datetime.datetime.now()
        self._owner = os.getuid()
        self._paths['task_dir'] = task_dir
        self._paths['task_config'] = task_config
        self._loaded = True

        # task is setup, save active file
        # note, order is *important*; this is needed first
        # for the daemon to load
        self._save_active_file()

        # shell the focusd daemon
        try:
            started = daemon.shell_focusd(self._paths['base_dir'])

        # user cancelled or passwords failed?
        except (KeyboardInterrupt, ValueError):
            self._clean()
            return False

        # no event plugins registered, carry on
        except errors.NoPluginsRegistered:
            return True

        # failed, cleanup our mess
        if not started:
            self._clean()
            raise errors.DaemonFailStart

        return True
def start ( self , task_name ) : self . _clean_prior ( ) if self . _loaded : raise errors . ActiveTask task_dir = os . path . join ( self . _paths [ 'base_dir' ] , 'tasks' , task_name ) task_config = os . path . join ( task_dir , 'task.cfg' ) if not os . path . isdir ( task_dir ) : raise errors . TaskNotFound ( task_name ) try : if not os . path . isfile ( task_config ) : reason = u"Config file could not be found." raise errors . InvalidTaskConfig ( task_config , reason = reason ) _parser = parser . parse_config ( task_config , self . HEADER_TASK_CONFIG ) registration . run_option_hooks ( _parser ) except parser . ParseError as exc : raise errors . InvalidTaskConfig ( task_config , reason = unicode ( exc ) ) self . _name = common . from_utf8 ( task_name ) self . _start_time = datetime . datetime . now ( ) self . _owner = os . getuid ( ) self . _paths [ 'task_dir' ] = task_dir self . _paths [ 'task_config' ] = task_config self . _loaded = True self . _save_active_file ( ) try : started = daemon . shell_focusd ( self . _paths [ 'base_dir' ] ) except ( KeyboardInterrupt , ValueError ) : self . _clean ( ) return False except errors . NoPluginsRegistered : return True if not started : self . _clean ( ) raise errors . DaemonFailStart return True
Starts a new task matching the provided name.

            `task_name`
                Name of existing task to start.

            Returns boolean.

            * Raises a ``TaskNotFound`` exception if task doesn't exist, an
              ``InvalidTaskConfig` exception if task config file is invalid, or
              ``DaemonFailStart`` exception if task daemons failed to fork.