获取表中存放的Task信息
@param string $taskName 任务名称
@return array 任务信息
@throws CronTaskNotExist|\Exception
199588
private function getTableTaskInfo($taskName)
    {
        $table = TableManager::getInstance()->get(self::$__swooleTableName);
        if ($table) {
            if ($table->exist($taskName)) {
                return $table->get($taskName);
            } else {
                throw new CronTaskNotExist($taskName);
            }
        } else {
            throw new \Exception('Crontab tasks have not yet started!');
        }
    }
150075
public function getTasks()
    {
        $tasks = [];

        foreach ($this->getKernelEvents() as $event) {
            $tasks[] = [
                'task'          => $this->formatTask($event),
                'expression'    => $event->expression,
                'nextRunDate'   => $event->nextRunDate()->format('Y-m-d H:i:s'),
                'description'   => $event->description,
                'readable'      => CronSchedule::fromCronString($event->expression)->asNaturalLanguage(),
            ];
        }

        return $tasks;
    }
1291166
public function index() {
		$this->request->data('Task', $this->request->query);
		$this->paginate = array(
			'TaskClient' => array(
				'limit' => Configure::read('Pagination.limit'),
				'fields' => array(
					'command',
					'arguments',
					'status',
					'code_string',
					'stderr_truncated',
					'started',
					'stopped',
					'created',
					'modified',
					'runtime',
					'id',
					'process_id'
				),
				'conditions' => $this->_paginationFilter(),
				'order' => array('created' => 'desc'),
				'contain' => array('DependsOnTask' => array('id', 'status'))
			)
		);
		$this->set(array(
			'data' => $this->paginate("TaskClient")
		));

		$commandList = $this->TaskClient->find('list', array(
			'fields' => array('command', 'command'),
			'group' => array('command'),
		));
		$statusList = $this->TaskClient->find('list', array(
			'fields' => array('status', 'status'),
			'group' => array('status'),
		));
		$approximateRuntimes = array_map(function($command) {
			return $this->TaskProfiler->approximateRuntime($command);
		}, $commandList);
		$this->set(array(
			'commandList' => $commandList,
			'statusList' => $statusList,
			'approximateRuntimes' => $approximateRuntimes,
			'batchActions' => array_combine($this->batchActions, $this->batchActions)
		));
	}
1342253
def get_task_info(self, task_name, key):
        
        params = OrderedDict([('info', ''), ('taskname', task_name), ('key', key)])

        resp = self._client.get(self.resource(), params=params)
        return resp.text
996966
public static function parseCrontab($cron, $task_class)
    {
        $cron_array = explode(PHP_EOL, $cron);
        $comment = null;
        $result = array();
        foreach ($cron_array as $c) {
            $c = trim($c);
            if (empty($c)) {
                continue;
            }
            $r = array($c);
            if (preg_match(self::CRON_LINE_REGEXP, $c, $matches)) {
                try {
                    CronExpression::factory($matches[2]);
                } catch (\Exception $e) {
                    $r[1] = 'Time expression is not valid';
                    $r[2] = $matches[2];
                    $result[] = $r;
                    continue;
                }
                $task = self::createTaskWithCrontabLine($task_class, $matches, $comment);

                $r [1] = 'Saved';
                $r [2] = $task;

                $comment = null;
            } elseif (preg_match('/#([\w\d\s]+)/i', $c, $matches)) {
                $comment = trim($matches[1]);
                $r [1] = 'Comment';
                $r [2] = $comment;
            } else {
                $r [1] = 'Not matched';
            }
            $result[] = $r;
        }

        return $result;
    }
1077014
public static function get_scheduled_task($classname) {
        global $DB;

        $classname = self::get_canonical_class_name($classname);
        // We are just reading - so no locks required.
        $record = $DB->get_record('task_scheduled', array('classname'=>$classname), '*', IGNORE_MISSING);
        if (!$record) {
            return false;
        }
        return self::scheduled_task_from_record($record);
    }
338697
private function _getCreateTaskTemplateContext(TaskTemplate $taskTemplate)
    {
        $result = new HttpCallContext();
        $result->setMethod(Resources::HTTP_POST);
        $result->setHeaders($this->_batchHeaders);
        $result->setUri($this->getUri());
        $result->setPath('/$1/TaskTemplates');
        $result->setBody($this->wrapAtomEntry($taskTemplate));
        $result->addStatusCode(Resources::STATUS_CREATED);

        return $result;
    }
72603
public function process()
    {
        $taskRows = $this->getTasksWithAssignedSite();
        $legacySchedulerTasks = $taskRows->fetchAll();
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable("tx_scheduler_task");

        $status = FlashMessage::OK;
        $title = 'Remove site from scheduler task';
        $failedTaskCount = 0;
        $migratedTaskCount = 0;
        foreach ($legacySchedulerTasks as $legacySchedulerTask) {
            try {
                $uid = $legacySchedulerTask['uid'];
                $task = unserialize($legacySchedulerTask['serialized_task_object']);
                $task->setRootPageId($task->getSite()->getRootPageId());
                $updatedTask = serialize($task);
                $updatedRows = $queryBuilder->update('tx_scheduler_task')
                    ->where($queryBuilder->expr()->eq('uid', $uid))
                    ->set('serialized_task_object', $updatedTask)
                    ->execute();

                $migratedTaskCount += $updatedRows;
            } catch (\Exception $e) {
                $failedTaskCount++;
                $status = FlashMessage::ERROR;
            }
        }

        $message = 'Migrated ' . (int)$migratedTaskCount . ' scheduler tasks! Update of ' . (int)$failedTaskCount . ' failed!';
        return [$status, $title, $message];
    }
35096
public static function deliverByProcess(
        string $taskName,
        string $methodName,
        array $params = [],
        int $timeout = 3,
        int $workerId = 0,
        string $type = self::TYPE_ASYNC
    ): bool {
        /* @var PipeMessageInterface $pipeMessage */
        $pipeMessage = bean(PipeMessage::class);
        $message = $pipeMessage->pack(PipeMessage::MESSAGE_TYPE_TASK, [
            'name' => $taskName,
            'method' => $methodName,
            'params' => $params,
            'timeout' => $timeout,
            'type' => $type,
        ]);
        return App::$server->getServer()->sendMessage($message, $workerId);
    }
277832
public function singleTaskSchedule(TaskNumber $taskNumber, Schedule ...$schedules)
    {
        $events = \array_map(
            function (Schedule $schedule) {
                return $schedule->events();
            },
            $schedules
        );

        $flattenEvents = \array_merge(...$events);

        if (!isset($flattenEvents[$taskNumber->asArrayIndex()])) {
            $tasksCount = \count($flattenEvents);
            throw new TaskNotExistException("Task with id '{$taskNumber->asInt()}' not found. Last task id is '{$tasksCount}'.");
        }

        $event = $flattenEvents[$taskNumber->asArrayIndex()];

        $schedule = new Schedule();
        $schedule->events([$event]);

        return [$schedule];
    }
1151134
public function find($name = null)
    {
        $tasks = [];

        foreach ($this->application->getAppPaths() as $path) {
            $files = $this->finder->path($path['dir'] . DS . 'Task')->recursive()->name('*TaskList.php')->find();
            foreach ($files as $file) {
                $task_path = substr($file, strlen($path['dir'] . DS . 'Task' . DS), - strlen('TaskList.php'));
                $task_name = join(':', array_map('lcfirst', explode(DS, $task_path)));

                $class_name = $file->getClassName();
                if (! class_exists($class_name)) continue;

                $refletion = new ReflectionClass($class_name);
                if (! $refletion->isInstantiable()) continue;

                $taskList = $refletion->newInstance();
                $taskList->setName($task_name);

                foreach ($taskList->getTasks() as $task) {
                    $tasks[] = $task;
                }
            }
        }

        if ($name) {
            $tasks = array_filter($tasks, function($task) use ($name) {
                return strpos($task->getName(), $name) === 0;
            });
        }

        return $tasks;
    }
433992
protected function createTaskInstance($taskName)
    {
        $taskClassName = $this->mapTaskNameToTaskClass($taskName);
        $task = new $taskClassName();
        if ($task instanceof ShellCommandServiceAwareInterface) {
            $task->setShellCommandService(new ShellCommandService());
        }
        return $task;
    }
284270
public static function parseCommand($command)
    {
        if (preg_match('/([\w\\\\]+)::(\w+)\((.*)\)/', $command, $match)) {
            $params = explode(',', $match[3]);
            if ((1 == count($params)) && ('' == $params[0])) {
                //prevents to pass an empty string
                $params[0] = null;
            }
            return array(
                $match[1],
                $match[2],
                $params
            );
        }

        throw new TaskManagerException('Command not recognized');
    }
596665
protected function readProjectDates()
	{
		$node	= $this->xpath->evaluate( "//project/tasks/task" );

		if( $node->length == 0 )
			throw new Exception( 'Task Node not found. No Task defined in Project.' );

		$name		= $node->item(0)->getAttribute( 'name' );
		$start		= $node->item(0)->getAttribute( 'start' );
		$duration	= $node->item(0)->getAttribute( 'duration' );

		$data	= array(
			'name'		=> $name,
			'start'		=> $start,
			'duration'	=> $duration,
			'end'		=> self::calculateEndDate( $start, $duration ),
		);
		return $data;
	}
1090710
public function getTask($handle)
    {
        if (!isset($this->handles[$handle])) {
            throw new Exception('Unknown handle');
        }

        if (!isset($this->tasks[$this->handles[$handle]])) {
            throw new Exception('No task by that handle');
        }

        return $this->tasks[$this->handles[$handle]];
    }
1005242
public static function get_adhoc_tasks($classname) {
        global $DB;

        $classname = self::get_canonical_class_name($classname);
        // We are just reading - so no locks required.
        $records = $DB->get_records('task_adhoc', array('classname' => $classname));

        return array_map(function($record) {
            return self::adhoc_task_from_record($record);
        }, $records);
    }
20585
public function getStats(string $listID = ''): array
    {
        $result = [];
        $result['upcomingTasksCount'] = 0;
        $result['upcomingTasks'] = [];
        $result['nextTaskStartTime'] = null;

        $currentTime = time();
        $list = $this->getListData($listID);
        foreach ($list as $taskID => $taskListData) {
            $result['upcomingTasksCount'] ++;
            if ($taskListData[0] === 1) { // version check
                $startTime = $taskListData[1];
                $result['upcomingTasks'][] = ['id' => $taskID, 'startTime' => $startTime];
                $tempStartTime = $startTime === null ? $currentTime : $startTime;
                if ($result['nextTaskStartTime'] === null || $result['nextTaskStartTime'] > $tempStartTime) {
                    $result['nextTaskStartTime'] = $tempStartTime;
                }
            }
        }

        return $result;
    }