Add a task from vObject to Taskwarrior
        vtodo -- the iCalendar to add
        project -- the project to add (see get_filesnames() as well)
963235
def append_vobject(self, vtodo, project=None):
        
        if project:
            project = basename(project)
        return self.to_task(vtodo.vtodo, project)
1003706
def add_task_file_manager(self, task_file_manager):
        
        if not self._loaded:
            raise PluginManagerNotLoadedException()
        self._task_factory.add_custom_task_file_manager(task_file_manager)
30259
def vnic_add_new_to_vm_task(vm, network, logger):
        

        nicspes = VNicService.vnic_new_attached_to_network(network)
        task = VNicService.vnic_add_to_vm_task(nicspes, vm, logger)
        return task
1196337
def load_task(module, task_name, params_str):
    
    if module is not None:
        __import__(module)
    task_cls = Register.get_task_cls(task_name)
    return task_cls.from_str_params(params_str)
996587
def add(self, task_cls):
		

		registry_tag = task_cls.__registry_tag__
		if registry_tag not in self.__registry.keys():
			self.__registry[registry_tag] = [task_cls]
		elif self.__multiple_tasks_per_tag__ is True:
			self.__registry[registry_tag].append(task_cls)
		else:
			raise RuntimeError('Multiple tasks with same tag appended')
747995
def add(self, target, args=None, kwargs=None, **options):
        
        from furious.async import Async
        from furious.batcher import Message

        if self._tasks_inserted:
            raise errors.ContextAlreadyStartedError(
                "This Context has already had its tasks inserted.")

        if not isinstance(target, (Async, Message)):
            target = Async(target, args, kwargs, **options)

        target.update_options(_context_id=self.id)

        if self.persist_async_results:
            target.update_options(persist_result=True)

        self._tasks.append(target)
        self._options['_task_ids'].append(target.id)

        return target
716655
def module_add(self, ev, path=None):
        
        log = self._params.get('log', self._discard)
        key = ev.get_key()
        if key is None:
            raise TaskError(name, "Attempt to register python module event with no key available")
        log.debug("Adding path %r for task %r, action %s", path, ev.get_name(), ev._handler_name)
        self._watch_modules.add(key, command_path=path)
        self._module_event_map[key] = ev
1082116
async def insert(self, task: Task) -> None:
        ''''''

        if not isinstance(task, Task):
            task = task()

        if task.name not in self.all_tasks:
            task.tasky = self
            self.all_tasks[task.name] = task

            await task.init()

        elif task != self.all_tasks[task.name]:
            raise Exception('Duplicate task %s' % task.name)

        if task.enabled:
            task.task = asyncio.ensure_future(self.start_task(task))
            self.running_tasks.add(task)
        else:
            task.task = None

        return task
1049518
def add_task(self, task_id=None, status=PENDING, runnable=True,
                 deps=None, new_deps=None, expl=None, resources=None,
                 priority=0, family='', module=None, params=None, param_visibilities=None, accepts_messages=False,
                 assistant=False, tracking_url=None, worker=None, batchable=None,
                 batch_id=None, retry_policy_dict=None, owners=None, **kwargs):
        
        assert worker is not None
        worker_id = worker
        worker = self._update_worker(worker_id)

        resources = {} if resources is None else resources.copy()

        if retry_policy_dict is None:
            retry_policy_dict = {}

        retry_policy = self._generate_retry_policy(retry_policy_dict)

        if worker.enabled:
            _default_task = self._make_task(
                task_id=task_id, status=PENDING, deps=deps, resources=resources,
                priority=priority, family=family, module=module, params=params, param_visibilities=param_visibilities,
            )
        else:
            _default_task = None

        task = self._state.get_task(task_id, setdefault=_default_task)

        if task is None or (task.status != RUNNING and not worker.enabled):
            return

        # for setting priority, we'll sometimes create tasks with unset family and params
        if not task.family:
            task.family = family
        if not getattr(task, 'module', None):
            task.module = module
        if not getattr(task, 'param_visibilities', None):
            task.param_visibilities = _get_default(param_visibilities, {})
        if not task.params:
            task.set_params(params)

        if batch_id is not None:
            task.batch_id = batch_id
        if status == RUNNING and not task.worker_running:
            task.worker_running = worker_id
            if batch_id:
                # copy resources_running of the first batch task
                batch_tasks = self._state.get_batch_running_tasks(batch_id)
                task.resources_running = batch_tasks[0].resources_running.copy()
            task.time_running = time.time()

        if accepts_messages is not None:
            task.accepts_messages = accepts_messages

        if tracking_url is not None or task.status != RUNNING:
            task.tracking_url = tracking_url
            if task.batch_id is not None:
                for batch_task in self._state.get_batch_running_tasks(task.batch_id):
                    batch_task.tracking_url = tracking_url

        if batchable is not None:
            task.batchable = batchable

        if task.remove is not None:
            task.remove = None  # unmark task for removal so it isn't removed after being added

        if expl is not None:
            task.expl = expl
            if task.batch_id is not None:
                for batch_task in self._state.get_batch_running_tasks(task.batch_id):
                    batch_task.expl = expl

        task_is_not_running = task.status not in (RUNNING, BATCH_RUNNING)
        task_started_a_run = status in (DONE, FAILED, RUNNING)
        running_on_this_worker = task.worker_running == worker_id
        if task_is_not_running or (task_started_a_run and running_on_this_worker) or new_deps:
            # don't allow re-scheduling of task while it is running, it must either fail or succeed on the worker actually running it
            if status != task.status or status == PENDING:
                # Update the DB only if there was a acctual change, to prevent noise.
                # We also check for status == PENDING b/c that's the default value
                # (so checking for status != task.status woule lie)
                self._update_task_history(task, status)
            self._state.set_status(task, PENDING if status == SUSPENDED else status, self._config)

        if status == FAILED and self._config.batch_emails:
            batched_params, _ = self._state.get_batcher(worker_id, family)
            if batched_params:
                unbatched_params = {
                    param: value
                    for param, value in six.iteritems(task.params)
                    if param not in batched_params
                }
            else:
                unbatched_params = task.params
            try:
                expl_raw = json.loads(expl)
            except ValueError:
                expl_raw = expl

            self._email_batcher.add_failure(
                task.pretty_id, task.family, unbatched_params, expl_raw, owners)
            if task.status == DISABLED:
                self._email_batcher.add_disable(
                    task.pretty_id, task.family, unbatched_params, owners)

        if deps is not None:
            task.deps = set(deps)

        if new_deps is not None:
            task.deps.update(new_deps)

        if resources is not None:
            task.resources = resources

        if worker.enabled and not assistant:
            task.stakeholders.add(worker_id)

            # Task dependencies might not exist yet. Let's create dummy tasks for them for now.
            # Otherwise the task dependencies might end up being pruned if scheduling takes a long time
            for dep in task.deps or []:
                t = self._state.get_task(dep, setdefault=self._make_task(task_id=dep, status=UNKNOWN, deps=None, priority=priority))
                t.stakeholders.add(worker_id)

        self._update_priority(task, priority, worker_id)

        # Because some tasks (non-dynamic dependencies) are `_make_task`ed
        # before we know their retry_policy, we always set it here
        task.retry_policy = retry_policy

        if runnable and status != FAILED and worker.enabled:
            task.workers.add(worker_id)
            self._state.get_worker(worker_id).tasks.add(task)
            task.runnable = runnable
283619
def add_task(self, task, func=None, **kwargs):
        '''  '''
        if not self.__tasks:
            raise Exception("Tasks subparsers is disabled")
        if 'help' not in kwargs:
            if func.__doc__:
                kwargs['help'] = func.__doc__
        task_parser = self.__tasks.add_parser(task, **kwargs)
        if self.__add_vq:
            self.add_vq(task_parser)
        if func is not None:
            task_parser.set_defaults(func=func)
        return task_parser
1197752
def replace_vobject(self, uuid, vtodo, project=None):
        
        self._update()
        uuid = uuid.split('@')[0]
        if project:
            project = basename(project)
        return self.to_task(vtodo.vtodo, project, uuid)
1053940
def add_task(self, func, *args, **kargs):
        
        self.tasks.put((func, args, kargs))
169918
def task_add_user(self, *args, **kwargs):
        
        if not self.cur_task:
            return

        dialog = UserAdderDialog(task=self.cur_task)
        dialog.exec_()
        users = dialog.users
        for user in users:
            userdata = djitemdata.UserItemData(user)
            treemodel.TreeItem(userdata, self.task_user_model.root)
379940
def task(name, options = {}, &block)
      AvoDeploy::Deployment.instance.log.debug "registering task #{name}..."
      AvoDeploy::Deployment.instance.task_manager.add_task(name, options, &block)
    end
108722
def add(self, task, multiprocess=False, processes=0):
        
        if self._first_task is None and hasattr(task, 'task_id'):
            self._first_task = task.task_id
        self.add_succeeded = True
        if multiprocess:
            queue = multiprocessing.Manager().Queue()
            pool = multiprocessing.Pool(processes=processes if processes > 0 else None)
        else:
            queue = DequeQueue()
            pool = SingleProcessPool()
        self._validate_task(task)
        pool.apply_async(check_complete, [task, queue])

        # we track queue size ourselves because len(queue) won't work for multiprocessing
        queue_size = 1
        try:
            seen = {task.task_id}
            while queue_size:
                current = queue.get()
                queue_size -= 1
                item, is_complete = current
                for next in self._add(item, is_complete):
                    if next.task_id not in seen:
                        self._validate_task(next)
                        seen.add(next.task_id)
                        pool.apply_async(check_complete, [next, queue])
                        queue_size += 1
        except (KeyboardInterrupt, TaskException):
            raise
        except Exception as ex:
            self.add_succeeded = False
            formatted_traceback = traceback.format_exc()
            self._log_unexpected_error(task)
            task.trigger_event(Event.BROKEN_TASK, task, ex)
            self._email_unexpected_error(task, formatted_traceback)
            raise
        finally:
            pool.close()
            pool.join()
        return self.add_succeeded
1101362
def to_task(self, vtodo, project=None, uuid=None):
        
        task = {}

        if project and project != 'all_projects' and project != 'unaffiliated':
            task['project'] = project

        if uuid:
            task['uuid'] = uuid

        if hasattr(vtodo, 'dtstamp'):
            task['entry'] = self._tw_timestamp(vtodo.dtstamp.value)

        if hasattr(vtodo, 'last_modified'):
            task['modified'] = self._tw_timestamp(vtodo.last_modified.value)

        if hasattr(vtodo, 'dtstart'):
            task['start'] = self._tw_timestamp(vtodo.dtstart.value)

        if hasattr(vtodo, 'due'):
            task['due'] = self._tw_timestamp(vtodo.due.value)

        if hasattr(vtodo, 'completed'):
            task['end'] = self._tw_timestamp(vtodo.completed.value)

        task['description'] = vtodo.summary.value

        if hasattr(vtodo, 'categories'):
            task['tags'] = vtodo.categories.value

        if hasattr(vtodo, 'priority'):
            priority = int(vtodo.priority.value)
            if priority < 3:
                task['priority'] = 'H'
            elif 3 < priority < 7:
                task['priority'] = 'M'
            else:
                task['priority'] = 'L'

        if hasattr(vtodo, 'description'):
            task['annotations'] = []
            for delta, comment in enumerate(vtodo.description.value.split('\n')):
                # Hack because Taskwarrior import doesn't accept multiple annotations with the same timestamp
                stamp = self._tw_timestamp(vtodo.dtstamp.value + timedelta(seconds=delta))
                if uuid in self._tasks.get(project, {}) and 'annotations' in self._tasks[project][uuid]:
                    for annotation in self._tasks[project][uuid]['annotations']:
                        if annotation['description'] == comment:
                            stamp = annotation['entry']
                            break
                task['annotations'].append({'entry': stamp, 'description': comment})

        if hasattr(vtodo, 'status'):
            if vtodo.status.value == 'IN-PROCESS':
                task['status'] = 'pending'
                if 'start' not in task:
                    task['start'] = self._tw_timestamp(vtodo.dtstamp.value)
            elif vtodo.status.value == 'NEEDS-ACTION':
                task['status'] = 'pending'
            elif vtodo.status.value == 'COMPLETED':
                task['status'] = 'completed'
                if 'end' not in task:
                    task['end'] = self._tw_timestamp(vtodo.dtstamp.value)
            elif vtodo.status.value == 'CANCELLED':
                task['status'] = 'deleted'
                if 'end' not in task:
                    task['end'] = self._tw_timestamp(vtodo.dtstamp.value)

        json = dumps(task, separators=(',', ':'), sort_keys=True)
        with self._lock:
            p = run(['task', 'rc.verbose=nothing', 'rc.recurrence.confirmation=no', 'rc.data.location={self._data_location}'.format(**locals()), 'import', '-'], input=json, encoding='utf-8', stdout=PIPE)
        uuid = findall('(?:add|mod)  ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}) ', p.stdout)[0]
        self._update()
        return self._gen_uid(uuid)
304813
def add_tag(self, task, params={}, **options): 
        
        path = "/tasks/%s/addTag" % (task)
        return self.client.post(path, params, **options)