Example #1
0
 public function load($clusterName)
 {
     $result = $this->awsClient->listTasks(['cluster' => $clusterName, 'serviceName' => $this->serviceName, 'maxResults' => 99, 'nextToken' => '']);
     //get existing tasks
     foreach ($result['taskArns'] as $taskArn) {
         $task = new Task();
         $task->setArn($taskArn);
         if (!$task->init($this->creds)) {
             return false;
         }
         if (!$task->load($clusterName)) {
             return false;
         }
         $this->tasks[$taskArn] = $task;
     }
     //get task def
     $details = $this->awsClient->describeServices(['cluster' => $clusterName, 'services' => [$this->serviceName]]);
     $this->taskDefinition = $details['services'][0]['taskDefinition'];
     $this->taskDef = new TaskDef();
     $this->taskDef->init($this->creds);
     $this->taskDef->load($this->taskDefinition);
     //other service items
     $this->status = $details['services'][0]['status'];
     $this->minHealthyPercent = $details['services'][0]['deploymentConfiguration']['minimumHealthyPercent'];
     $this->maxPercent = $details['services'][0]['deploymentConfiguration']['maximumPercent'];
     $this->desiredTaskCount = $details['services'][0]['desiredCount'];
     $this->pendingTaskCount = $details['services'][0]['pendingCount'];
     $this->runningTaskCount = $details['services'][0]['runningCount'];
     return true;
 }
Example #2
0
 /**
  * Called by the parser to let the task initialize properly.
  * Should throw a BuildException if something goes wrong with the build
  *
  * This is abstract here, but may not be overloaded by subclasses.
  *
  * @throws \BuildException
  */
 public function init()
 {
     if (!defined('SW_PATH') && $this->checkSWPath()) {
         $this->includeSWAutoloader();
     }
     // if
     return parent::init();
 }
 /**
  * Executes initialization actions required to setup the data structures
  * related to the tag.
  * <p>
  * This includes:
  * <ul>
  * <li>creation of the task object</li>
  * <li>calling the setters for attributes</li>
  * <li>adding the task to the container object</li>
  * <li>adding a reference to the task (if id attribute is given)</li>
  * <li>executing the task if the container is the &lt;project&gt;
  * element</li>
  * </ul>
  *
  * @param string $tag The tag that comes in
  * @param array $attrs Attributes the tag carries
  * @throws ExpatParseException if attributes are incomplete or invalid
  */
 function init($tag, $attrs)
 {
     // shorthands
     try {
         $configurator = $this->configurator;
         $project = $this->configurator->project;
         $this->task = $project->createTask($tag);
     } catch (BuildException $be) {
         // swallow here, will be thrown again in
         // UnknownElement->maybeConfigure if the problem persists.
         print "Swallowing exception: " . $be->getMessage() . "\n";
     }
     // if the task is not known beforehand, wrap it
     // in an UnknownElement object to enable runtime configuration
     // NB: this is also done for ConditionBase objects to allow
     // dynamic conditions without breaking BC for all tasks
     if ($this->task === null) {
         $this->task = new UnknownElement($tag);
         $this->task->setProject($project);
         $this->task->setTaskType($tag);
         $this->task->setTaskName($tag);
     }
     // add file position information to the task (from parser)
     // should be used in task exceptions to provide details
     $this->task->setLocation($this->parser->getLocation());
     $configurator->configureId($this->task, $attrs);
     if ($this->container) {
         $this->container->addTask($this->task);
     }
     // Top level tasks don't have associated targets
     // FIXME: if we do like Ant 1.6 and create an implicitTarget in the projectconfigurator object
     // then we don't need to check for null here ... but there's a lot of stuff that will break if we
     // do that at this point.
     if ($this->target !== null) {
         $this->task->setOwningTarget($this->target);
         $this->task->init();
         $this->wrapper = $this->task->getRuntimeConfigurableWrapper();
         $this->wrapper->setAttributes($attrs);
         /*
         Commenting this out as per thread on Premature configurate of ReuntimeConfigurables 
         with Matthias Pigulla: http://phing.tigris.org/servlets/ReadMsg?list=dev&msgNo=251
         
         if ($this->parentWrapper !== null) { // this may not make sense only within this if-block, but it
                                             // seems to address current use cases adequately
             $this->parentWrapper->addChild($this->wrapper);
         }
         */
     } else {
         $this->task->init();
         $configurator->configure($this->task, $attrs, $project);
     }
 }
Example #4
0
 /**
  * Initializes this task.
  */
 public function init()
 {
     parent::init();
     $this->defaultValue = "";
     $this->promptCharacter = "?";
     $this->useExistingValue = false;
 }
Example #5
0
        return $tasks;
    }
    public function isMilestoneOrVersion()
    {
        return $this->isOfCategory(array(TCATEGORY_MILESTONE, TCATEGORY_VERSION));
    }
    public function isOfCategory($cat)
    {
        if (is_array($cat)) {
            foreach ($cat as $c) {
                if ($this->category == $c) {
                    return true;
                }
            }
            return false;
        } elseif ($this->category == $cat) {
            return true;
        }
        return false;
    }
    public function isDocumentation()
    {
        return isOfCategory(TCATEGORY_DOCU);
    }
    public function isBug()
    {
        return isOfCategory(TCATEGORY_BUG);
    }
}
Task::init();
Example #6
0
 /**
  * 初始化一些定时任务
  * @return void
  */
 protected static function initTask()
 {
     // 任务初始化
     Task::init();
     // 测试环境定时获取worker包含的文件
     if (PHPServerConfig::get('ENV') == 'dev') {
         // 定时获取worker包含的文件
         Task::add(self::$commonWaitTimeLong, array('PHPServer', 'sendCmdToAll'), array(Cmd::CMD_REPORT_INCLUDE_FILE));
         // 定时检测终端是否关闭
         Task::add(self::$commonWaitTimeLong, array('PHPServer', 'checkTty'));
     } else {
         // 定时发送alarm命令
         Task::add(self::$commonWaitTimeLong, array('PHPServer', 'sendCmdToAll'), array(Cmd::CMD_PING));
     }
     // 如果不支持inotify则上报文件给FileMonitor进程来监控文件更新
     Task::add(self::$checkFilesTimeLong, function () {
         Reporter::reportIncludedFiles(PHPServer::getFilesToInotify());
     });
     // 检查worker内存占用情况
     Task::add(self::$checkStatusTimeLong, array('PHPServer', 'checkWorkersMemory'));
     // 检查心跳情况
     Task::add(self::$checkStatusTimeLong, array('PHPServer', 'checkPingInfo'));
     // 开发环境定时清理master输出
     if (PHPServerConfig::get('ENV') == 'dev') {
         Task::add(self::$commonWaitTimeLong, function () {
             @ob_clean();
         });
     }
 }
Example #7
0
 /**
  * Access point for this special page.
  */
 public function execute($parameters)
 {
     global $wgOut, $wgTranslateBlacklist, $wgRequest;
     $wgOut->addModules('ext.translate.special.translate');
     $this->setHeaders();
     // @todo Move to api or so
     if ($parameters === 'editpage') {
         $editpage = TranslationEditPage::newFromRequest($wgRequest);
         if ($editpage) {
             $editpage->execute();
             return;
         }
     }
     $this->setup($parameters);
     $errors = array();
     if ($this->options['group'] === '') {
         TranslateUtils::addSpecialHelpLink($wgOut, 'Help:Extension:Translate/Translation_example');
         $this->groupInformation();
         return;
     }
     $codes = Language::getLanguageNames(false);
     if (!$this->options['language'] || !isset($codes[$this->options['language']])) {
         $errors['language'] = wfMsgExt('translate-page-no-such-language', array('parse'));
         $this->options['language'] = $this->defaults['language'];
     }
     if (!$this->task instanceof TranslateTask) {
         $errors['task'] = wfMsgExt('translate-page-no-such-task', array('parse'));
         $this->options['task'] = $this->defaults['task'];
     }
     if (!$this->group instanceof MessageGroup) {
         $errors['group'] = wfMsgExt('translate-page-no-such-group', array('parse'));
         $this->options['group'] = $this->defaults['group'];
     }
     TranslateUtils::addSpecialHelpLink($wgOut, 'Help:Extension:Translate/Translation_example');
     // Show errors nicely.
     $wgOut->addHTML($this->settingsForm($errors));
     if (count($errors)) {
         return;
     } else {
         $checks = array($this->options['group'], strtok($this->options['group'], '-'), '*');
         foreach ($checks as $check) {
             $reason = @$wgTranslateBlacklist[$check][$this->options['language']];
             if ($reason !== null) {
                 $wgOut->addWikiMsg('translate-page-disabled', $reason);
                 return;
             }
         }
     }
     // Proceed.
     $taskOptions = new TaskOptions($this->options['language'], $this->options['limit'], $this->options['offset'], array($this, 'cbAddPagingNumbers'));
     // Initialise and get output.
     $this->task->init($this->group, $taskOptions);
     $output = $this->task->execute();
     if ($this->task->plainOutput()) {
         $wgOut->disable();
         header('Content-type: text/plain; charset=UTF-8');
         echo $output;
     } else {
         $description = $this->getGroupDescription($this->group);
         $taskid = $this->options['task'];
         if (in_array($taskid, array('untranslated', 'reviewall'), true)) {
             $hasOptional = count($this->group->getTags('optional'));
             if ($hasOptional) {
                 $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker();
                 $linktext = wfMessage('translate-page-description-hasoptional-open')->escaped();
                 $params = array('task' => 'optional') + $this->nondefaults;
                 $link = $linker->link($this->getTitle(), $linktext, array(), $params);
                 $note = wfMessage('translate-page-description-hasoptional')->rawParams($link)->parseAsBlock();
                 if ($description) {
                     $description .= '<br>' . $note;
                 } else {
                     $description = $note;
                 }
             }
         }
         $status = $this->getWorkflowStatus();
         if ($status !== false) {
             $description = $status . $description;
         }
         if ($description) {
             $description = Xml::fieldset(wfMsg('translate-page-description-legend'), $description);
         }
         $links = $this->doStupidLinks();
         if ($this->paging['count'] === 0) {
             $wgOut->addHTML($description . $links);
         } else {
             $wgOut->addHTML($description . $links . $output . $links);
         }
     }
 }