Read tasks representing activities.
352665
private void readActivities()
   {
      Map<String, ChildTaskContainer> parentMap = new HashMap<String, ChildTaskContainer>();
      for (MapRow row : m_tables.get("WBS"))
      {
         String activityID = row.getString("ACTIVITY_ID");
         m_wbsFormat.parseRawValue(row.getString("CODE_VALUE"));
         String parentWBS = m_wbsFormat.getFormattedValue();

         ChildTaskContainer parent = m_wbsMap.get(parentWBS);
         if (parent != null)
         {
            parentMap.put(activityID, parent);
         }
      }

      List<MapRow> items = new ArrayList<MapRow>();
      for (MapRow row : m_tables.get("ACT"))
      {
         items.add(row);
      }
      final AlphanumComparator comparator = new AlphanumComparator();
      Collections.sort(items, new Comparator<MapRow>()
      {
         @Override public int compare(MapRow o1, MapRow o2)
         {
            return comparator.compare(o1.getString("ACTIVITY_ID"), o2.getString("ACTIVITY_ID"));
         }
      });

      for (MapRow row : items)
      {
         String activityID = row.getString("ACTIVITY_ID");
         ChildTaskContainer parent = parentMap.get(activityID);
         if (parent == null)
         {
            parent = m_projectFile;
         }
         Task task = parent.addTask();
         setFields(TASK_FIELDS, row, task);
         task.setStart(task.getEarlyStart());
         task.setFinish(task.getEarlyFinish());
         task.setMilestone(task.getDuration().getDuration() == 0);
         if (parent instanceof Task)
         {
            task.setWBS(((Task) parent).getWBS());
         }

         int flag = row.getInteger("ACTUAL_START_OR_CONSTRAINT_FLAG").intValue();
         if (flag != 0)
         {
            Date date = row.getDate("AS_OR_ED_CONSTRAINT");
            switch (flag)
            {
               case 1:
               {
                  task.setConstraintType(ConstraintType.START_NO_EARLIER_THAN);
                  task.setConstraintDate(date);
                  break;
               }

               case 3:
               {
                  task.setConstraintType(ConstraintType.FINISH_NO_EARLIER_THAN);
                  task.setConstraintDate(date);
                  break;
               }

               case 99:
               {
                  task.setActualStart(date);
                  break;
               }
            }
         }

         flag = row.getInteger("ACTUAL_FINISH_OR_CONSTRAINT_FLAG").intValue();
         if (flag != 0)
         {
            Date date = row.getDate("AF_OR_LD_CONSTRAINT");
            switch (flag)
            {
               case 2:
               {
                  task.setConstraintType(ConstraintType.START_NO_LATER_THAN);
                  task.setConstraintDate(date);
                  break;
               }

               case 4:
               {
                  task.setConstraintType(ConstraintType.FINISH_NO_LATER_THAN);
                  task.setConstraintDate(date);
                  break;
               }

               case 99:
               {
                  task.setActualFinish(date);
                  break;
               }
            }
         }

         m_activityMap.put(activityID, task);
      }
   }
764125
def analyses(self):
        
        response = self._request("tasks/list")

        return json.loads(response.content.decode('utf-8'))['tasks']
1368267
def _read_services(self, services):
        """"""
        for service in services:
            parser = FritzSCDPParser(self.address, self.port, service)
            actions = parser.get_actions()
            service.actions = {action.name: action for action in actions}
            self.services[service.name] = service
788054
def group_tasks(self):
        """"""
        tasks = set()
        for node in walk_tree(self):
            for ctrl in node.controllers.values():
                tasks.update(ctrl.tasks)
        return tasks
530006
def list_tasks(self):
        
        from highton.models.task import Task

        return fields.ListField(
            name=self.ENDPOINT,
            init_class=Task
        ).decode(
            self.element_from_string(
                self._get_request(
                    endpoint=self.ENDPOINT + '/' + str(self.id) + '/' + Task.ENDPOINT,
                ).text
            )
        )
560659
def get_tasks(self):
        

        def predicate(item):
            return (inspect.isfunction(item) and
                    item.__name__ not in self._helper_names)
        return inspect.getmembers(self._tasks, predicate)
971630
def _get_avaliable_tasks(self):
        """"""
        base_task = posixpath.join(self._queue_path, self.TASK_PREFIX)
        tasks = self._client.kv.find(prefix=base_task)
        return sorted(tasks.items())
199045
def tasks(self):
        
        if not self.__tasks:
            self.__tasks = Tasks(self.__connection)
        return self.__tasks
455690
def _gen_tasks(self):
        """"""
        for filename in self.args:
            path = os.path.abspath(filename)
            yield {
                'name': path,
                # 'file_dep': [path],
                'actions': [(self.fun, (filename,))],
            }
982039
def tasks(self, **kwargs):
        
        tasks_result = self.service.tasks().list(**kwargs).execute()
        return [Task(task) for task in tasks_result.get("items", [])]
765997
private List<Task> receiveTasks() {
		synchronized (mutex) {
			if (tasks.isEmpty()) {
				return Collections.emptyList();
			} else {
				List<Task> currentTasks = tasks;
				tasks = new ArrayList<Task>();
				return currentTasks;
			}
		}
	}
819642
def _task_to_dict(task):
    """"""
    payload = task.payload
    if payload and task.content_type == 'application/json':
        payload = json.loads(payload)

    return dict(
        task_id=task.task_id,
        queue_name=task.queue_name,
        eta=_datetime_to_epoch_seconds(task.eta),
        source=task.source,
        created=_datetime_to_epoch_seconds(task.created),
        lease_attempts=task.lease_attempts,
        last_lease=_datetime_to_epoch_seconds(task.last_lease),
        payload=payload,
        content_type=task.content_type)
1109357
private void processActivity(Activity activity)
   {
      Task task = getParentTask(activity).addTask();
      task.setText(1, activity.getId());

      task.setActualDuration(activity.getActualDuration());
      task.setActualFinish(activity.getActualFinish());
      task.setActualStart(activity.getActualStart());
      //activity.getBaseunit()
      //activity.getBilled()
      //activity.getCalendar()
      //activity.getCostAccount()
      task.setCreateDate(activity.getCreationTime());
      task.setFinish(activity.getCurrentFinish());
      task.setStart(activity.getCurrentStart());
      task.setName(activity.getDescription());
      task.setDuration(activity.getDurationAtCompletion());
      task.setEarlyFinish(activity.getEarlyFinish());
      task.setEarlyStart(activity.getEarlyStart());
      task.setFreeSlack(activity.getFreeFloat());
      task.setLateFinish(activity.getLateFinish());
      task.setLateStart(activity.getLateStart());
      task.setNotes(activity.getNotes());
      task.setBaselineDuration(activity.getOriginalDuration());
      //activity.getPathFloat()
      task.setPhysicalPercentComplete(activity.getPhysicalPercentComplete());
      task.setRemainingDuration(activity.getRemainingDuration());
      task.setCost(activity.getTotalCost());
      task.setTotalSlack(activity.getTotalFloat());
      task.setMilestone(activityIsMilestone(activity));
      //activity.getUserDefined()
      task.setGUID(activity.getUuid());

      if (task.getMilestone())
      {
         if (activityIsStartMilestone(activity))
         {
            task.setFinish(task.getStart());
         }
         else
         {
            task.setStart(task.getFinish());
         }
      }

      if (task.getActualStart() == null)
      {
         task.setPercentageComplete(Integer.valueOf(0));
      }
      else
      {
         if (task.getActualFinish() != null)
         {
            task.setPercentageComplete(Integer.valueOf(100));
         }
         else
         {
            Duration remaining = activity.getRemainingDuration();
            Duration total = activity.getDurationAtCompletion();
            if (remaining != null && total != null && total.getDuration() != 0)
            {
               double percentComplete = ((total.getDuration() - remaining.getDuration()) * 100.0) / total.getDuration();
               task.setPercentageComplete(Double.valueOf(percentComplete));
            }
         }
      }

      m_activityMap.put(activity.getId(), task);
   }
759182
def view_task(self, task):
        
        log.debug('Viewing task %s', task.name)
        self.cur_task = None
        self.pages_tabw.setCurrentIndex(7)

        self.task_dep_le.setText(task.name)
        statusmap = {"New": 0, "Open": 1, "Done":2}
        self.task_status_cb.setCurrentIndex(statusmap.get(task.status, -1))
        dt = dt_to_qdatetime(task.deadline) if task.deadline else None
        self.task_deadline_de.setDateTime(dt)

        self.task_link_le.setText(task.element.name)

        userrootdata = treemodel.ListItemData(['Username', 'First', 'Last', 'Email'])
        userrootitem = treemodel.TreeItem(userrootdata)
        for user in task.users.all():
            userdata = djitemdata.UserItemData(user)
            treemodel.TreeItem(userdata, userrootitem)
        self.task_user_model = treemodel.TreeModel(userrootitem)
        self.task_user_tablev.setModel(self.task_user_model)

        self.cur_task = task
774197
def help(cls, task=None):
        """"""
        if task is None:
            usage_list = []
            for task in iter(cls._tasks):
                task_func = getattr(cls, task)
                usage_string = "  %s %s" % (cls._prog, task_func.usage)
                desc = task_func.__doc__.splitlines()[0]
                usage_list.append((usage_string, desc))
            max_len = functools.reduce(lambda m, item: max(m, len(item[0])), usage_list, 0)
            print("Tasks:")
            cols = int(os.environ.get("COLUMNS", 80))
            for line, desc in usage_list:
                task_func = getattr(cls, task)
                if desc:
                    line = "%s%s  # %s" % (line, " " * (max_len - len(line)), desc)
                if len(line) > cols:
                    line = line[:cols - 3] + "..."
                print(line)
        else:
            task_func = getattr(cls, task)
            print("Usage:")
            print("  %s %s" % (cls._prog, task_func.usage))
            print("")
            print(task_func.__doc__)
981456
private void readWBS()
   {
      Map<Integer, List<MapRow>> levelMap = new HashMap<Integer, List<MapRow>>();
      for (MapRow row : m_tables.get("STR"))
      {
         Integer level = row.getInteger("LEVEL_NUMBER");
         List<MapRow> items = levelMap.get(level);
         if (items == null)
         {
            items = new ArrayList<MapRow>();
            levelMap.put(level, items);
         }
         items.add(row);
      }

      int level = 1;
      while (true)
      {
         List<MapRow> items = levelMap.get(Integer.valueOf(level++));
         if (items == null)
         {
            break;
         }

         for (MapRow row : items)
         {
            m_wbsFormat.parseRawValue(row.getString("CODE_VALUE"));
            String parentWbsValue = m_wbsFormat.getFormattedParentValue();
            String wbsValue = m_wbsFormat.getFormattedValue();
            row.setObject("WBS", wbsValue);
            row.setObject("PARENT_WBS", parentWbsValue);
         }

         final AlphanumComparator comparator = new AlphanumComparator();
         Collections.sort(items, new Comparator<MapRow>()
         {
            @Override public int compare(MapRow o1, MapRow o2)
            {
               return comparator.compare(o1.getString("WBS"), o2.getString("WBS"));
            }
         });

         for (MapRow row : items)
         {
            String wbs = row.getString("WBS");
            if (wbs != null && !wbs.isEmpty())
            {
               ChildTaskContainer parent = m_wbsMap.get(row.getString("PARENT_WBS"));
               if (parent == null)
               {
                  parent = m_projectFile;
               }

               Task task = parent.addTask();
               String name = row.getString("CODE_TITLE");
               if (name == null || name.isEmpty())
               {
                  name = wbs;
               }
               task.setName(name);
               task.setWBS(wbs);
               task.setSummary(true);
               m_wbsMap.put(wbs, task);
            }
         }
      }
   }
873792
def scan_tasks(self):
        ''''''
        def update_task_status(info, error=None):
            if error or not info:
                logger.error('CloudPage.scan_tasks: %s, %s' % (info, error))
                return
            tasks = info['task_info']
            for row in self.liststore:
                if not row or row[TASKID_COL] not in tasks:
                    continue
                task = tasks[row[TASKID_COL]]
                row[SIZE_COL] = int(task['file_size'])
                row[FINISHED_COL] = int(task['finished_size'])
                row[STATUS_COL] = int(task['status'])
                if row[SIZE_COL]:
                    row[PERCENT_COL] = int(
                            row[FINISHED_COL] / row[SIZE_COL] * 100)
                size = util.get_human_size(row[SIZE_COL])[0]
                finished_size = util.get_human_size(row[FINISHED_COL])[0]
                if row[SIZE_COL] == row[FINISHED_COL]:
                    row[HUMANSIZE_COL] = size
                else:
                    row[HUMANSIZE_COL] = '{0}/{1}'.format(finished_size, size)

        task_ids = [row[TASKID_COL] for row in self.liststore]
        if task_ids:
            gutil.async_call(pcs.cloud_query_task, self.app.cookie,
                             self.app.tokens, task_ids,
                             callback=update_task_status)