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


PHP Process::getExitCodeText方法代码示例

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


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

示例1: run

 public function run(OutputInterface $output)
 {
     foreach ($this->queue as $command) {
         $process = new Process($command);
         if ($process->run()) {
             $output->writeln(sprintf('<error>%s:</error>', $process->getExitCodeText()));
             $output->writeln('');
             $output->writeln(sprintf('<error>%s</error>', $process->getErrorOutput()));
             return $process->getExitCode();
         } else {
             $output->writeln(sprintf('<info>%s</info>', $process->getExitCodeText()));
         }
     }
     // Ok
     return 0;
 }
开发者ID:nike,项目名称:beez,代码行数:16,代码来源:ShellQueue.php

示例2: __construct

 public function __construct(Process $process)
 {
     if ($process->isSuccessful()) {
         throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
     }
     parent::__construct(sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText(), $process->getOutput(), $process->getErrorOutput()));
     $this->process = $process;
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:8,代码来源:ProcessFailedException.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $commandLine = $input->getArgument('command-line');
     if ($this->forced) {
         $process = new Process($commandLine);
         if ($process->run()) {
             $output->writeln(sprintf('<error>%s:</error>', $process->getExitCodeText()));
             $output->writeln('');
             $output->writeln(sprintf('<error>%s</error>', $process->getErrorOutput()));
             return $process->getExitCode();
         } else {
             $output->writeln(sprintf('<info>%s</info>', $process->getExitCodeText()));
         }
     } else {
         $output->writeln($commandLine);
     }
     // Ok
     return 0;
 }
开发者ID:nike,项目名称:beez,代码行数:19,代码来源:ShellExecuteCommand.php

示例4: handleProcessResult

 protected function handleProcessResult(Process $process)
 {
     $this->processObjectList[] = $process;
     if ($process->getExitCode() !== 0) {
         $message = $messageEnd = 'process for <code>' . $process->getCommandLine() . '</code> exited with ' . $process->getExitCode() . ': ' . $process->getExitCodeText();
         $message .= PHP_EOL . 'Error Message:' . PHP_EOL . $process->getErrorOutput();
         $message .= PHP_EOL . 'Output:' . PHP_EOL . $process->getOutput();
         $message .= PHP_EOL . $messageEnd;
         throw new \Exception($message, $process->getExitCode());
     }
 }
开发者ID:AydinHassan,项目名称:composer-test-framework,代码行数:11,代码来源:Wrapper.php

示例5: processRestore

 /**
  * @param string          $command The command string
  * @param OutputInterface $output  An output instance
  *
  * @return int Process exit code
  */
 private function processRestore($command, OutputInterface $output)
 {
     $process = new Process($command);
     $output->writeln('<info>Start restore database, it may take some time...</info>');
     $process->run(function ($type, $buff) use($output) {
         $message = $type === Process::ERR ? '<comment>%s</comment>' : '<info>%s</info>';
         $output->writeln(sprintf($message, trim($buff)));
     });
     if (0 === ($exitCode = $process->getExitCode())) {
         $output->writeln(sprintf('<info>%s</info>', 'Restore completed!'));
     } else {
         $output->writeln(sprintf('<error>Restore failed: %s!</error>', $process->getExitCodeText()));
     }
     return $exitCode;
 }
开发者ID:nkt,项目名称:backup-bundle,代码行数:21,代码来源:RestoreCommand.php

示例6: processBackup

 /**
  * @param string          $command The command string
  * @param string          $filename
  * @param bool|string     $gzip
  * @param OutputInterface $output  An output instance
  *
  * @return int Process exit code
  */
 private function processBackup($command, $filename, $gzip, OutputInterface $output)
 {
     if ($gzip !== false) {
         $command .= ' | gzip > ' . $filename . '.gz';
     } else {
         $command .= ' > ' . $filename;
     }
     $process = new Process($command);
     $output->writeln('<info>Start backup database, it may take some time...</info>');
     $process->run(function ($type, $buff) use($output) {
         $message = $type === Process::ERR ? '<comment>%s</comment>' : '<info>%s</info>';
         $output->writeln(sprintf($message, trim($buff)));
     });
     if (0 === ($exitCode = $process->getExitCode())) {
         $output->writeln(sprintf('<info>%s</info>', 'Backup completed!'));
     } else {
         $output->writeln(sprintf('<error>Backup failed: %s!</error>', $process->getExitCodeText()));
     }
     return $exitCode;
 }
开发者ID:nkt,项目名称:backup-bundle,代码行数:28,代码来源:BackupCommand.php

示例7: execute

 /**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('build-folder') && $input->getOption('format')) {
         throw new \RuntimeException('Please provide a build folder');
     }
     if ($input->getOption('build-folder') && !is_writable($input->getOption('build-folder'))) {
         throw new \RuntimeException(sprintf('The build folder %s is not writable', $input->getOption('build-folder')));
     }
     if (!is_dir($input->getArgument('folder'))) {
         throw new \RuntimeException(sprintf('The folder %s does not exist', $input->getArgument('folder')));
     }
     $buildFolder = realpath($input->getOption('build-folder'));
     $output->writeln(sprintf(" >> Running Behat at <info>%s</info>", $input->getArgument('folder')));
     $formats = array('pretty' => '.log', 'progress' => '.log', 'html' => '.html', 'junit' => '', 'failed' => '.log', 'snippets' => '.log');
     if ($input->getOption('format') && !array_key_exists($input->getOption('format'), $formats)) {
         throw new \RuntimeException(sprintf('Invalid format', $input->getOption('format')));
     }
     $cliOptions = array();
     if ($input->getOption('format')) {
         $cliOptions[] = sprintf('--format %s --out %s/behat%s', $input->getOption('format'), $buildFolder, $formats[$input->getOption('format')]);
     }
     $cmd = sprintf("cd %s && php behat.phar %s", $input->getArgument('folder'), implode(" ", $cliOptions));
     $output->writeln(sprintf("Starting command: %s", $cmd));
     $process = new Process($cmd);
     $process->setTimeout(null);
     $out = "";
     // allows to nicely log data ....
     $process->run(function ($type, $data) use(&$out) {
         $out .= $data;
     });
     if ($process->getExitCode() !== 0) {
         $output->writeln(explode("\n", $out));
         $output->writeln("");
         $output->writeln(sprintf("<question>Exit code: %s (%s)</question>", $process->getExitCodeText(), $process->getExitCode()));
         $output->writeln("\n");
     } else {
         $output->writeln(" >> Tests OK !");
     }
     return $process->getExitCode() === 0;
 }
开发者ID:sonata-project,项目名称:composer-archive-creator,代码行数:43,代码来源:RunBehatTestsCommand.php

示例8: convertToPdf

 /**
  * @param string $resourcePath
  * @param string $targetPath
  * @param \PhantomPdf\Options $options
  * @throws \PhantomPdf\PhantomPdfException
  *
  * @return void
  */
 protected function convertToPdf($resourcePath, $targetPath, Options $options)
 {
     $command = $this->createCommand($resourcePath, $targetPath, $options);
     $process = new Process($command);
     if ($this->timeout !== null) {
         $process->setTimeout($this->timeout);
     }
     $process->run();
     $error = $process->getErrorOutput();
     if ($error !== null) {
         throw new PhantomPdfException($error . ' ' . $process->getExitCodeText());
     }
 }
开发者ID:project-a,项目名称:phantom-pdf,代码行数:21,代码来源:PdfGenerator.php

示例9: processDidNotEndSuccessfully

 /**
  * @param \Symfony\Component\Process\Process $process
  *
  * @return \Spatie\DbDumper\Exceptions\DumpFailed
  */
 public static function processDidNotEndSuccessfully(Process $process)
 {
     return new static("The dump process failed with exitcode {$process->getExitCode()} : {$process->getExitCodeText()} : {$process->getErrorOutput()}");
 }
开发者ID:spatie,项目名称:db-dumper,代码行数:9,代码来源:DumpFailed.php

示例10: exec

 public function exec($cmd, $chdir = null)
 {
     $nl = true;
     //
     $output = $this->output;
     $process = new Process($cmd, $chdir);
     $process->setTimeout(null);
     $process->start();
     $code = $process->wait(function ($type, $data) use($output, &$nl) {
         if ($nl === true) {
             $data = "\n" . $data;
             $nl = false;
         }
         if (substr($data, -1) === "\n") {
             $nl = true;
             $data = substr($data, 0, -1);
         }
         $data = str_replace("\n", "\n    ", $data);
         $output($data);
     });
     if ($nl) {
         $this->log('');
     }
     if ($code !== 0) {
         throw new UnexpectedValueException('Error status code: ' . $process->getExitCodeText() . ' (code ' . $code . ')');
     }
 }
开发者ID:Grisou13,项目名称:phar-composer,代码行数:27,代码来源:Packager.php

示例11: getMediaInfo

 private function getMediaInfo($file)
 {
     $command = str_replace('{{file}}', $file, $this->command);
     $process = new Process($command);
     $process->setTimeout(60);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException('Exception executing "' . $command . '": ' . $process->getExitCode() . ' ' . $process->getExitCodeText() . '. ' . $process->getErrorOutput());
     }
     return $process->getOutput();
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:11,代码来源:InspectionFfprobeService.php

示例12: composerExecute

 /**
  * composerExecute - execute a command using composer
  *
  * @param string $command_line command to pass to composer, i.e. 'update'
  *
  * @return boolean true on success, false if command failed or could not execute
  */
 public function composerExecute($command_line)
 {
     $this->output = array();
     $this->errors = array();
     $options = ' ' . trim($this->exeOptions) . ' ';
     if (empty($this->exe)) {
         $exeFinder = new PhpExecutableFinder();
         $foundExe = $exeFinder->find();
         if ($foundExe) {
             $this->exe = $foundExe . ' composer.phar';
         } else {
             $this->errors[] = 'Cannot find PHP executable';
             return false;
         }
     }
     if (!chdir(\XoopsBaseConfig::get('lib-path'))) {
         $this->errors[] = 'Cannot change directory to lib-path';
         return false;
     }
     set_time_limit(300);
     // don't want this script to timeout;
     $command = $this->exe . $options . $command_line;
     putenv('COMPOSER_HOME=' . \XoopsBaseConfig::get('var-path') . '/composer');
     $process = new Process($command);
     //$process->setEnv(array('COMPOSER_HOME' => \XoopsBaseConfig::get('var-path').'/composer'));
     $process->setTimeout(120);
     try {
         $process->run(function ($type, $buffer) use(&$errors, &$output) {
             if ('err' === $type) {
                 $errors[] = $buffer;
             } else {
                 $this->output[] = $buffer;
             }
         });
     } catch (\Exception $e) {
         $errors[] = $e->getMessage();
     }
     if ($process->isSuccessful()) {
         return true;
     } else {
         $this->errors[] = 'Failed: ' . $command;
         $this->errors[] = sprintf("Process exit code: %s, '%s'", $process->getExitCode(), $process->getExitCodeText());
     }
     return false;
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:52,代码来源:ComposerUtility.php

示例13: formatProcess

 /**
  * @param Process $process
  * @return string[]
  */
 protected function formatProcess(Process $process)
 {
     return ['[process] ' . $process->getCommandLine(), '[code]    ' . $process->getExitCode(), '[text]    ' . $process->getExitCodeText(), '[stderr]  ' . trim($process->getErrorOutput()), '[stdout]  ' . trim($process->getOutput())];
 }
开发者ID:graze,项目名称:supervisor,代码行数:8,代码来源:TerminatedProcessException.php

示例14: runPHPunit

 /**
  * @param string          $folder
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param string          $buildFolder
  *
  * @return bool
  */
 protected function runPHPunit($folder, InputInterface $input, OutputInterface $output, $buildFolder)
 {
     $output->writeln(sprintf(" >> Running PHPUnit at <info>%s</info>", $folder));
     $cliOptions = array();
     if ($input->getOption('junit')) {
         $cliOptions[] = sprintf('--log-junit %s/junit.xml', $buildFolder);
     }
     if ($input->getOption('clover')) {
         $cliOptions[] = sprintf('--coverage-clover %s/clover.xml', $buildFolder);
     }
     $cmd = sprintf("cd %s && phpunit %s", $folder, implode(" ", $cliOptions));
     $output->writeln(sprintf(" >> PHPUnit command %s", $cmd));
     $process = new Process($cmd);
     $process->setTimeout(null);
     $out = "";
     // allows to nicely log data ....
     $process->run(function ($type, $data) use(&$out) {
         $out .= $data;
     });
     if ($process->getExitCode() !== 0) {
         $output->writeln(explode("\n", $out));
         $output->writeln("");
         $output->writeln(sprintf("<question>Exit code: %s (%s)</question>", $process->getExitCodeText(), $process->getExitCode()));
         $output->writeln("\n");
     } else {
         $output->writeln(" >> Tests OK !");
     }
     return $process->getExitCode() === 0;
 }
开发者ID:sonata-project,项目名称:composer-archive-creator,代码行数:37,代码来源:RunUnitTestsCommand.php

示例15: runCommand

 /**
  * Runs the given command in the given working directory.
  *
  * @param string $command command to execute (please escape arguments via e.g. using ProcessUtils::escapeArgument())
  * @param string $working_directory
  *
  * @return array with "exitcode", "exitcode_text", "stdout", "stderr" and "success" flag
  *
  * @throws \InvalidArgumentException when working directory is not readable
  * @throws \Symfony\Component\Process\Exception\RuntimeException on errors executing the command
  */
 public static function runCommand($command, $working_directory)
 {
     if (!is_readable($working_directory)) {
         throw new InvalidArgumentException('Given working directory is not readable: ' . $working_directory);
     }
     $result = array('cmd' => $command, 'stdout' => '', 'stderr' => '', 'success' => false);
     $process = new Process($command, $working_directory);
     $process->setTimeout(300);
     $process->run();
     $result['exitcode'] = $process->getExitCode();
     $result['exitcode_text'] = $process->getExitCodeText();
     $result['stdout'] = $process->getOutput();
     $result['stderr'] = $process->getErrorOutput();
     $result['success'] = $process->isSuccessful();
     return $result;
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:27,代码来源:AssetCompiler.php


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