本文整理汇总了PHP中Symfony\Component\Process\Process::getIncrementalErrorOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::getIncrementalErrorOutput方法的具体用法?PHP Process::getIncrementalErrorOutput怎么用?PHP Process::getIncrementalErrorOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\Process
的用法示例。
在下文中一共展示了Process::getIncrementalErrorOutput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processOutput
/**
* Looks into and processes the child's output
*
* @param string $childName
* @return void
*/
public function processOutput($childName)
{
$output = $this->outputBuffer . $this->process->getIncrementalOutput();
$errorOutput = $this->errorOutputBuffer . $this->process->getIncrementalErrorOutput();
$outputLines = explode("\n", $output);
$errorOutputLines = explode("\n", $errorOutput);
if (count($outputLines) > 0) {
$lastItem = array_pop($outputLines);
$this->outputBuffer = $lastItem;
$this->bufferLength += implode("\n", $outputLines);
foreach ($outputLines as $line) {
if (strstr($line, "[[CHILD::BUSY]]")) {
$this->parent->verboseOutput('<info>' . $childName . ' BUSY</info>');
$this->status = ChildProcessContainer::STATUS_BUSY;
} elseif (strstr($line, "[[CHILD::READY]]")) {
$this->parent->verboseOutput('<info>' . $childName . ' READY</info>');
if ($this->status != ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY) {
$this->status = ChildProcessContainer::STATUS_READY;
} else {
$this->status = ChildProcessContainer::STATUS_SLEEPY;
}
} elseif (strlen($line) > 0) {
$this->parent->verboseOutput('<info>OUTPUT ' . $childName . ':</info>' . $line);
}
}
}
if (count($errorOutputLines) > 0) {
$lastItemError = array_pop($errorOutputLines);
$this->errorOutputBuffer = $lastItemError;
$knownErrorOutput = implode("\n", $errorOutputLines);
$this->bufferLength += strlen($knownErrorOutput);
}
}
示例2: execute
/**
* Executes post install SH script
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param OutputInterface $output
*
* @internal param \Symfony\Component\Console\Input\InputInterface $intput
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$command = $input->getOption("post");
$output->writeln("");
$output->writeln("========================");
$output->writeln('Executing post ' . $command . ' script.');
$output->writeln("========================");
// TODO: openssl req -new -x509 -sha256 -days 365 -nodes -out /tmp/server.crt -keyout /tmp/server.key
$process = new Process("/bin/bash ./src/FIT/NetopeerBundle/bin/netconfwebgui-postinstall.sh");
$process->run();
while ($process->isRunning()) {
$process->getIncrementalOutput();
$process->getIncrementalErrorOutput();
}
if (!$process->isSuccessful()) {
$output->writeln("Error in post " . $command . " script occured.");
$output->writeln($process->getErrorOutput());
} else {
$output->writeln($process->getOutput());
}
$output->writeln("========================");
$output->writeln("End of post " . $command . " script");
$output->writeln("========================");
}
示例3: testGetIncrementalErrorOutput
public function testGetIncrementalErrorOutput()
{
$p = new Process(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(50000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }')));
$p->start();
while ($p->isRunning()) {
$this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches));
usleep(20000);
}
}
示例4: startServer
/**
* @param $address
* @param $environment
*/
protected function startServer()
{
$publicDir = $this->getApplication()->getWorkingPath() . DS . 'public';
$shellCommand = $this->getBaseCommand();
$process = new Process($shellCommand, $publicDir);
if ($this->getInput()->getOption('background')) {
$process->disableOutput();
$process->start();
$processId = $this->getProcessId();
$this->getApplication()->getConfig()->setOption('server', ['pid' => $processId, 'address' => $address = 'http://' . $this->getAddress()]);
$this->getOutput()->writeln($this->info('Server has been started at ' . $address));
} else {
while ($process instanceof Process) {
if (!$process->isStarted()) {
$process->start();
continue;
}
echo $process->getIncrementalOutput();
echo $process->getIncrementalErrorOutput();
if (!$process->isRunning() || $process->isTerminated()) {
$process = false;
$this->getOutput()->writeln("");
$this->getOutput()->writeln($this->info('Server has been stopped.'));
}
sleep(1);
}
}
}
示例5: updateRelease
/**
* @param Process $process
* @return callable
*/
public function updateRelease(Process $process)
{
$out = $process->getIncrementalOutput() . $process->getIncrementalErrorOutput();
$this->release->update(['raw_log' => $process->getOutput() . PHP_EOL . $process->getErrorOutput()]);
if (!empty($out)) {
$this->release->logger()->info($out);
}
}
示例6: getProcessOutput
/**
* Decorate and return Process output
* @param Process $process
* @return string
*/
protected function getProcessOutput(Process $process)
{
$output = '';
// Add standard process output
if ($processOutput = $process->getIncrementalOutput()) {
$processOutputLines = explode("\n", $processOutput);
// color output lines containing "[WARN]"
foreach ($processOutputLines as &$processOutputLine) {
if (strpos($processOutputLine, '[WARN]') !== false) {
$processOutputLine = '<fg=black;bg=yellow>' . $processOutputLine . '</fg=black;bg=yellow>';
} elseif (strpos($processOutputLine, '[DEBUG]') !== false) {
$processOutputLine = '<comment>' . $processOutputLine . '</comment>';
}
}
$output .= implode("\n", $processOutputLines);
}
// Add error output
if ($errorOutput = $process->getIncrementalErrorOutput()) {
$output .= '<error>' . rtrim($errorOutput, PHP_EOL) . '</error>' . "\n";
}
return $output;
}