当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpProcess::isSuccessful方法代码示例

本文整理汇总了PHP中Symfony\Component\Process\PhpProcess::isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpProcess::isSuccessful方法的具体用法?PHP PhpProcess::isSuccessful怎么用?PHP PhpProcess::isSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Process\PhpProcess的用法示例。


在下文中一共展示了PhpProcess::isSuccessful方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Méthode d'execution
  */
 public function run()
 {
     // Initialisation des loggers
     $this->getConfiguration()->initLoggers();
     // Initialisation du process
     $this->createProcess();
     try {
         // Lancement du process
         $this->process->run(function ($type, $buffer) {
             // On affiche le debug à l'écran pour s'assurer qu'aucune erreur
             // bloquante n'est présente et suivre l'exécution des longs process
             if ('err' === $type) {
                 echo 'ERR > ' . $buffer;
             } else {
                 echo 'OUT > ' . $buffer;
             }
         });
         // On récupère la sortie standard en cas de succès (STDOUT)
         if ($this->process->isSuccessful()) {
             $this->message .= $this->process->getOutput();
         } else {
             // On récupère la sortie standard en cas d'erreur (STDERR)
             $this->message .= $this->process->getErrorOutput();
         }
     } catch (\Exception $e) {
         $this->message .= $e->getMessage();
     }
     // Log du process
     $this->report();
     // Envoi des notifications
     $this->notify();
 }
开发者ID:itkg,项目名称:batch,代码行数:35,代码来源:Console.php

示例2: execute

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var FormatterHelper $formatter */
        $formatter = $this->getHelper('formatter');
        //        $process = new Process('wkhtmltopdf http://google.com/ test.pdf');
        //        $process->run();
        //        $process->stop(3, SIGINT);
        //        $process->mustRun(function ($type, $message) use ($output, $formatter) {
        //            if ($type === Process::ERR) {
        //                $output->writeln($formatter->formatBlock($message, 'error'));
        //            } else {
        //                $output->writeln($formatter->formatBlock($message, 'comment'));
        //            }
        //        });
        $process = new PhpProcess(<<<EOF
        <?php
            sleep(5);
            echo "OK
";
        ?>
EOF
);
        $process->start();
        $process->stop(2, SIGINT);
        if (!$process->isSuccessful()) {
            $output->writeln($formatter->formatBlock($process->getErrorOutput(), 'error', true));
            return;
        }
        $output->writeln($formatter->formatSection('success', $process->getOutput()));
    }
开发者ID:GrizliK1988,项目名称:symfony-certification-prepare-project,代码行数:30,代码来源:ProcessCommand.php

示例3: run

 /**
  * {@inheritdoc}
  */
 public function run(JobReportInterface $report)
 {
     try {
         $this->process->start();
         $this->savePid($this->process->getPid(), $report);
         while ($this->process->isRunning()) {
             // waiting for process to finish
         }
         if ($this->process->isSuccessful()) {
             $report->setOutput(trim($this->process->getOutput()));
             return JobState::STATE_FINISHED;
         }
         $report->setErrorOutput(trim($this->process->getErrorOutput()));
     } catch (LogicException $e) {
         $report->setErrorOutput($e->getMessage());
     } catch (RuntimeException $e) {
         $report->setErrorOutput($e->getMessage());
     }
     return JobState::STATE_FAILED;
 }
开发者ID:dpk125,项目名称:JobQueue,代码行数:23,代码来源:PhpJob.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     if (null !== $filename) {
         $filename = $this->getSnippetsPath() . DIRECTORY_SEPARATOR . $filename;
         if (!file_exists($filename)) {
             throw new InvalidArgumentException(sprintf('file "%s" does not exist', $filename));
         }
         $snippets = array(new \SplFileInfo($filename));
         $nbSnippets = 1;
     } else {
         $snippets = $this->listSnippets(new Finder());
         $nbSnippets = count($snippets->getIterator()->getIterator());
     }
     $dialog = $this->getHelperSet()->get('dialog');
     $i = 0;
     foreach ($snippets as $snippet) {
         $snippetCode = file_get_contents($snippet->getRealpath());
         $output->writeln(sprintf('<info>DEMO [%d/%d]:</info> %s', $i + 1, $nbSnippets, $snippet->getRealPath()));
         $this->hr($output, 20);
         $output->writeln('<info>CODE :</info>');
         $output->writeln($snippetCode);
         $this->hr($output, 20);
         $dialog->askConfirmation($output, '<question>Press enter to see result</question>');
         $output->writeln('<info>RESULT :</info>');
         $process = new PhpProcess($snippetCode);
         $process->run();
         if (!$process->isSuccessful()) {
             $output->writeln(array('<error>Error ::</error>', $process->getErrorOutput()));
         }
         $output->writeln(array('<comment>Output ::</comment>', $process->getOutput()));
         $this->hr($output);
         $i++;
         if ($i < $nbSnippets) {
             $dialog->askConfirmation($output, '<question>Press enter to continue</question>');
             $output->writeln("[2J");
         }
     }
 }
开发者ID:ruian,项目名称:demoer,代码行数:39,代码来源:runCommand.php

示例5: doRequestInProcess

    /**
     * Makes a request in another process.
     *
     * @param Request $request A Request instance
     *
     * @return Response A Response instance
     *
     * @throws \RuntimeException When processing returns exit code
     */
    protected function doRequestInProcess($request)
    {
        // We set the TMPDIR because on Macs, the temp directory changes based on the user.
        $process = new PhpProcess($this->getScript($request), null, array('TMPDIR' => sys_get_temp_dir()));
        $process->run();

        if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return unserialize($process->getOutput());
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:21,代码来源:Client.php

示例6: doRequestInProcess

 /**
  * Makes a request in another process.
  *
  * @param object $request An origin request instance
  *
  * @return object An origin response instance
  *
  * @throws \RuntimeException When processing returns exit code
  */
 protected function doRequestInProcess($request)
 {
     $process = new PhpProcess($this->getScript($request), null, null);
     $process->run();
     if (!$process->isSuccessful() || !preg_match('/^O\\:\\d+\\:/', $process->getOutput())) {
         throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput()));
     }
     return unserialize($process->getOutput());
 }
开发者ID:blazarecki,项目名称:symfony,代码行数:18,代码来源:Client.php

示例7: doRequestInProcess

 /**
  * Makes a request in another process.
  *
  * @param object $request An origin request instance
  *
  * @return object An origin response instance
  *
  * @throws \RuntimeException When processing returns exit code
  */
 protected function doRequestInProcess($request)
 {
     // We set the TMPDIR (for Macs) and TEMP (for Windows), because on these platforms the temp directory changes based on the user.
     $process = new PhpProcess($this->getScript($request), null, array('TMPDIR' => sys_get_temp_dir(), 'TEMP' => sys_get_temp_dir()));
     $process->run();
     if (!$process->isSuccessful() || !preg_match('/^O\\:\\d+\\:/', $process->getOutput())) {
         throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput()));
     }
     return unserialize($process->getOutput());
 }
开发者ID:hichammoad,项目名称:symfony,代码行数:19,代码来源:Client.php

示例8: testCompressEventsKate

 /**
  * @medium
  * @dataProvider backends
  */
 public function testCompressEventsKate($backend)
 {
     // CREATE web.scssdx1493.new
     // MODIFY web.scssdx1493.new
     // MOVED_FROM web.scssdx1493.new
     // MOVED_TO web.scss
     if (!$backend->isAvailable()) {
         $this->markTestSkipped();
     }
     $f = __DIR__ . '/test/';
     sleep(1);
     $php = "<?php sleep(2);\n        file_put_contents('{$f}foo.txtdx1493.new', 'x');\n        rename('{$f}foo.txtdx1493.new', '{$f}foo.txt');\n\n        file_put_contents('{$f}stop.txt', 'x');\n        ";
     $process = new PhpProcess($php);
     $process->start();
     $gotEvents = array();
     $backend->setPath(__DIR__ . '/test');
     $backend->addListener(ModifyEvent::NAME, function ($e) use(&$gotEvents, $backend) {
         $gotEvents[] = 'modify';
     });
     $backend->addListener(CreateEvent::NAME, function ($e) use(&$gotEvents, $backend) {
         if ($e->filename == __DIR__ . '/test/stop.txt') {
             $backend->stop();
         } else {
             $gotEvents[] = 'create';
         }
     });
     $backend->addListener(DeleteEvent::NAME, function ($e) use(&$gotEvents, $backend) {
         $gotEvents[] = 'delete';
     });
     $backend->addListener(MoveEvent::NAME, function ($e) use(&$gotEvents, $backend) {
         $gotEvents[] = 'move';
     });
     $backend->start();
     $process->wait();
     $this->assertTrue($process->isSuccessful());
     $this->assertEquals($gotEvents, array('modify'));
 }
开发者ID:koala-framework,项目名称:file-watcher,代码行数:41,代码来源:BasicTest.php

示例9: addFallbackAutoloader

 private function addFallbackAutoloader($phpunitXml)
 {
     $xml = simplexml_load_file($phpunitXml);
     $bootstrap = dirname($phpunitXml) . '/' . $xml['bootstrap'];
     // The bootstrap file does not exists, we can't run the tests
     if (!file_exists($bootstrap)) {
         return false;
     }
     $content = file_get_contents($bootstrap);
     $newPath = sprintf('require_once \'%s\';', realpath(__DIR__ . '/../../../app/autoload.php'));
     // The bundle is trying to run tests into a symfony project, change it!
     if (preg_match('#require(../){2,}app/autoload.php["\'];$#i', $content, $match)) {
         $content = str_replace($match[0], $newPath, $content);
     } else {
         $content .= "\n" . $newPath;
     }
     file_put_contents($bootstrap, $content);
     // test if the bootstrap script can be runned
     $process = new PhpProcess($bootstrap);
     $process->run(function ($type, $data) {
         echo $data;
     });
     if (!$process->isSuccessful()) {
         return false;
     }
     $xml->filter->whitelist->exclude->directory[] = dirname($phpunitXml) . '/vendor';
     $xml->filter->whitelist->exclude->directory[] = dirname($phpunitXml) . '/vendors';
     $xml->asXml($phpunitXml);
     return true;
 }
开发者ID:noelg,项目名称:sonar.noelguilbert.com,代码行数:30,代码来源:ProjectBuilder.php

示例10: doRequestInProcess

 /**
  * Makes a request in another process.
  *
  * @param Request $request A Request instance
  *
  * @return Response A Response instance
  *
  * @throws \RuntimeException When processing returns exit code
  */
 protected function doRequestInProcess($request)
 {
     $process = new PhpProcess($this->getScript($request));
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     return unserialize($process->getOutput());
 }
开发者ID:rosstuck,项目名称:Pok,代码行数:18,代码来源:Client.php

示例11: updateCanonicalConfigFile

    public function updateCanonicalConfigFile(Bundle $bundle)
    {
        self::$canonicalConfiguration = '';
        $gitRepo = $this->gitRepoManager->getRepo($bundle);
        /**
         * Currently there is only support for bundles whose configuration is stored exactly under Configuration.php
         */
        $relativePath = 'DependencyInjection' . DIRECTORY_SEPARATOR . 'Configuration.php';
        if ($gitRepo->hasFile($relativePath)) {
            $absolutePath = $gitRepo->getDir() . DIRECTORY_SEPARATOR . $relativePath;
            $tokens = token_get_all(file_get_contents($absolutePath));
            $start = false;
            $namespace = '';
            foreach ($tokens as $token) {
                if ($token == ';') {
                    break;
                }
                $tokenName = is_array($token) ? $token[0] : null;
                if (T_NAMESPACE === $tokenName) {
                    $start = true;
                    continue;
                }
                // Still not found namespace, skip this part of code
                if ($start === false) {
                    continue;
                }
                $tokenData = is_array($token) ? $token[1] : $token;
                if ($tokenData == ' ') {
                    continue;
                }
                $namespace .= $tokenData;
            }
            unset($tokens);
            $autoloaderPath = __DIR__ . '/../../../../../vendor/autoload.php';
            $script = <<<EOF
<?php

include_once "{$autoloaderPath}";
include_once "{$absolutePath}";

use Knp\\Bundle\\KnpBundlesBundle\\Github\\Repo;

\$configuration = new \\ReflectionClass("{$namespace}\\Configuration");
// only dumps if it implements interface ConfigurationInterface
if (in_array('Symfony\\Component\\Config\\Definition\\ConfigurationInterface', \$configuration->getInterfaceNames())) {
    \$configuration = \$configuration->newInstance();
    \$configuration = Repo::outputNode(\$configuration->getConfigTreeBuilder()->buildTree());

    echo Repo::\$canonicalConfiguration;
} else {
    echo '';
}

?>
EOF;
            // Workaround for bundles with external deps called in DI configuration, i.e. FOSRestBundle
            $process = new PhpProcess($script);
            $process->run();
            if ($process->isSuccessful()) {
                $bundle->setCanonicalConfig(Repo::$canonicalConfiguration = $process->getOutput());
            }
        }
    }
开发者ID:KnpLabs,项目名称:KnpBundles,代码行数:63,代码来源:Repo.php

示例12: loadRaw

 protected function loadRaw($model, $parsePhp = false)
 {
     $content = file_get_contents(sprintf(__DIR__ . '/%s.yml', $model));
     if ($parsePhp) {
         $process = new PhpProcess($content);
         $process->run();
         if (!$process->isSuccessful()) {
             throw new \RuntimeException($process->getErrorOutput());
         }
         $content = $process->getOutput();
     }
     return Yaml::parse($content);
 }
开发者ID:alexislefebvre,项目名称:symfony-kickstarter,代码行数:13,代码来源:LoadData.php

示例13: doRequestInProcess

 /**
  * Makes a request in another process.
  *
  * @param object $request An origin request instance
  *
  * @return object An origin response instance
  *
  * @throws \RuntimeException When processing returns exit code
  * @see \Symfony\Component\BrowserKit\Client
  * @see \Symfony\Component\HttpKernel\Client
  */
 protected function doRequestInProcess($request)
 {
     // We set the TMPDIR (for Macs) and TEMP (for Windows), because on these platforms the temp directory changes based on the user.
     $process = new PhpProcess($this->getScript($request), $this->rootDir, array('TMPDIR' => sys_get_temp_dir(), 'TEMP' => sys_get_temp_dir()));
     $process->setPhpBinary('php-cgi');
     $process->run();
     // I think the second hcheck validates that the response is serialized, but that's not what we want here.
     //if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) {
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput()));
     }
     return $process->getOutput();
 }
开发者ID:bangpound,项目名称:drupal-kernel,代码行数:24,代码来源:Kernel.php


注:本文中的Symfony\Component\Process\PhpProcess::isSuccessful方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。