Given a description, stub out a task dict.
764557
def _stub_task(self, description, tags=None, **kw):
        

        # If whitespace is not removed here, TW will do it when we pass the
        # task to it.
        task = {"description": description.strip()}

        # Allow passing "tags" in as part of kw.
        if 'tags' in kw and tags is None:
            task['tags'] = tags
            del(kw['tags'])

        if tags is not None:
            task['tags'] = tags

        task.update(kw)

        # Only UNIX timestamps are currently supported.
        if 'due' in kw:
            task['due'] = str(task['due'])

        return task
1295631
def _init_taskqueue_stub(self, **stub_kwargs):
        """"""
        task_args = {}
        # root_path is required so the stub can find 'queue.yaml' or 'queue.yml'
        if 'root_path' not in stub_kwargs:
            for p in self._app_path:
                # support --gae-application values that may be a .yaml file
                dir_ = os.path.dirname(p) if os.path.isfile(p) else p
                if os.path.isfile(os.path.join(dir_, 'queue.yaml')) or \
                        os.path.isfile(os.path.join(dir_, 'queue.yml')):
                    task_args['root_path'] = dir_
                    break
        task_args.update(stub_kwargs)
        self.testbed.init_taskqueue_stub(**task_args)
1236819
def get_task(self, name):
        """"""
        if name in self.tasks.keys():
            task = self.tasks[name]
        else:
            task = Task(name)
            self.tasks[name] = task
        return task
152348
def task_detail(job_id=None, task_name=None):
    
    jobs = get_jobs()
    job = [job for job in jobs if str(job['job_id']) == job_id][0]
    return render_template('task_detail.html',
                           job=job,
                           task_name=task_name,
                           task=[task for task in job['tasks']
                                 if task['name'] == task_name][0])
210667
def describe(self):
        
        return {
            "name": self.name,
            "params": self.params,
            "returns": self.returns,
            "description": self.description,
        }
548056
def _AbandonQueuedTasks(self):
    
    # Abandon all tasks after they're identified so as not to modify the
    # dict while iterating over it.
    tasks_to_abandon = []
    for task_identifier, task in iter(self._tasks_queued.items()):
      logger.debug('Abandoned queued task: {0:s}.'.format(task_identifier))
      tasks_to_abandon.append((task_identifier, task))

    for task_identifier, task in tasks_to_abandon:
      self._tasks_abandoned[task_identifier] = task
      del self._tasks_queued[task_identifier]
120156
def stub(self, obj, attr=None):
        '''
        
        '''
        s = stub(obj, attr)
        if s not in self._stubs:
            self._stubs.append(s)
        return s
1028220
function(name, description, action) {
      if (!action) {
        [action, description] = [description, action];
      }
      return tasks[name] = {name, description, action};
    }
398985
def _taskdict(task):
    '''
    
    '''
    if task is None:
        task = asyncio.current_task()

    assert task
    taskvars = getattr(task, '_syn_taskvars', None)

    if taskvars is None:
        taskvars = varinit(task)

    return taskvars
967139
def create_tasks_dict(self, ast):
        '''
        
        '''
        tasks = self.find_asts(ast, 'Task')
        for task in tasks:
            self.parse_task(task)
        return self.tasks_dictionary
300276
def to_dict(self):
        """"""
        import copy

        options = copy.deepcopy(self._options)

        if self._insert_tasks:
            options['insert_tasks'] = reference_to_path(self._insert_tasks)

        if self._persistence_engine:
            options['persistence_engine'] = reference_to_path(
                self._persistence_engine)

        options.update({
            '_tasks_inserted': self._tasks_inserted,
        })

        callbacks = self._options.get('callbacks')
        if callbacks:
            options['callbacks'] = encode_callbacks(callbacks)

        return options
642649
def clear_description(self):
        
        if (self.get_description_metadata().is_read_only() or
                self.get_description_metadata().is_required()):
            raise errors.NoAccess()
        self._my_map['description'] = dict(self._description_default)
526309
def make_ready(self):
        """"""
        SCons.Taskmaster.OutOfDateTask.make_ready(self)
        if self.out_of_date and self.options.debug_explain:
            explanation = self.out_of_date[0].explain()
            if explanation:
                sys.stdout.write("scons: " + explanation)
343771
def contents(self):
        
        return self._logged_dict.discard(TIMESTAMP_FIELD).discard(
            TASK_UUID_FIELD
        ).discard(TASK_LEVEL_FIELD)
512431
def _get_str(task_dict, extra_indent):
    
    summary_length = execution_summary().summary_length

    lines = []
    task_names = sorted(task_dict.keys())
    for task_family in task_names:
        tasks = task_dict[task_family]
        tasks = sorted(tasks, key=lambda x: str(x))
        prefix_size = 8 if extra_indent else 4
        prefix = ' ' * prefix_size

        line = None

        if summary_length > 0 and len(lines) >= summary_length:
            line = prefix + "..."
            lines.append(line)
            break
        if len(tasks[0].get_params()) == 0:
            line = prefix + '- {0} {1}()'.format(len(tasks), str(task_family))
        elif _get_len_of_params(tasks[0]) > 60 or len(str(tasks[0])) > 200 or \
                (len(tasks) == 2 and len(tasks[0].get_params()) > 1 and (_get_len_of_params(tasks[0]) > 40 or len(str(tasks[0])) > 100)):
            """
            This is to make sure that there is no really long task in the output
            """
            line = prefix + '- {0} {1}(...)'.format(len(tasks), task_family)
        elif len((tasks[0].get_params())) == 1:
            attributes = {getattr(task, tasks[0].get_params()[0][0]) for task in tasks}
            param_class = tasks[0].get_params()[0][1]
            first, last = _ranging_attributes(attributes, param_class)
            if first is not None and last is not None and len(attributes) > 3:
                param_str = '{0}...{1}'.format(param_class.serialize(first), param_class.serialize(last))
            else:
                param_str = '{0}'.format(_get_str_one_parameter(tasks))
            line = prefix + '- {0} {1}({2}={3})'.format(len(tasks), task_family, tasks[0].get_params()[0][0], param_str)
        else:
            ranging = False
            params = _get_set_of_params(tasks)
            unique_param_keys = list(_get_unique_param_keys(params))
            if len(unique_param_keys) == 1:
                unique_param, = unique_param_keys
                attributes = params[unique_param]
                param_class = unique_param[1]
                first, last = _ranging_attributes(attributes, param_class)
                if first is not None and last is not None and len(attributes) > 2:
                    ranging = True
                    line = prefix + '- {0} {1}({2}'.format(len(tasks), task_family, _get_str_ranging_multiple_parameters(first, last, tasks, unique_param))
            if not ranging:
                if len(tasks) == 1:
                    line = prefix + '- {0} {1}'.format(len(tasks), tasks[0])
                if len(tasks) == 2:
                    line = prefix + '- {0} {1} and {2}'.format(len(tasks), tasks[0], tasks[1])
                if len(tasks) > 2:
                    line = prefix + '- {0} {1} ...'.format(len(tasks), tasks[0])
        lines.append(line)
    return '\n'.join(lines)
1160099
def to_task(task):
        
        from sevenbridges.models.task import Task
        if not task:
            raise SbgError('Task is required!')
        elif isinstance(task, Task):
            return task.id
        elif isinstance(task, six.string_types):
            return task
        else:
            raise SbgError('Invalid task parameter!')
1001132
def get_task_output_description(task_output):
    '''
    
    '''
    output_description = "n/a"

    if isinstance(task_output, RemoteTarget):
        output_description = "[SSH] {0}:{1}".format(task_output._fs.remote_context.host, task_output.path)
    elif isinstance(task_output, S3Target):
        output_description = "[S3] {0}".format(task_output.path)
    elif isinstance(task_output, FileSystemTarget):
        output_description = "[FileSystem] {0}".format(task_output.path)
    elif isinstance(task_output, PostgresTarget):
        output_description = "[DB] {0}:{1}".format(task_output.host, task_output.table)
    else:
        output_description = "to be determined"

    return output_description