getCommandLine() public method

Gets the command line to be executed.
public getCommandLine ( ) : string
return string The command to execute
コード例 #1
0
 /**
  * @param Process     $process
  * @param bool        $mustRun
  * @param bool        $quiet
  *
  * @return int|string
  * @throws \Exception
  */
 protected function runProcess(Process $process, $mustRun = false, $quiet = true)
 {
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->writeln("Running command: <info>" . $process->getCommandLine() . "</info>");
     }
     try {
         $process->mustRun($quiet ? null : function ($type, $buffer) {
             $this->output->write(preg_replace('/^/m', '  ', $buffer));
         });
     } catch (ProcessFailedException $e) {
         if (!$mustRun) {
             return $process->getExitCode();
         }
         // The default for ProcessFailedException is to print the entire
         // STDOUT and STDERR. But if $quiet is disabled, then the user will
         // have already seen the command's output.  So we need to re-throw
         // the exception with a much shorter message.
         $message = "The command failed with the exit code: " . $process->getExitCode();
         $message .= "\n\nFull command: " . $process->getCommandLine();
         if ($quiet) {
             $message .= "\n\nError output:\n" . $process->getErrorOutput();
         }
         throw new \Exception($message);
     }
     $output = $process->getOutput();
     return $output ? rtrim($output) : true;
 }
コード例 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $env = array('APP_INCLUDE' => $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/autoload.php', 'VVERBOSE' => 1, 'QUEUE' => $input->getArgument('queues'));
     $workerCommand = 'php ' . $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/chrisboulton/php-resque/resque.php';
     if (!$input->getOption('foreground')) {
         $workerCommand = 'nohup ' . $workerCommand . ' > ' . $this->getContainer()->getParameter('kernel.logs_dir') . '/resque.log 2>&1 & echo $!';
     }
     $process = new Process($workerCommand, null, $env);
     $output->writeln(\sprintf('Starting worker <info>%s</info>', $process->getCommandLine()));
     // if foreground, we redirect output
     if ($input->getOption('foreground')) {
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $process->run();
         $pid = \trim($process->getOutput());
         if (function_exists('gethostname')) {
             $hostname = gethostname();
         } else {
             $hostname = php_uname('n');
         }
         $output->writeln(\sprintf('<info>Worker started</info> %s:%s:%s', $hostname, $pid, $input->getArgument('queues')));
     }
 }
コード例 #3
0
ファイル: PhpCsFixerFormatter.php プロジェクト: phpro/grumphp
 /**
  * @param Process $process
  *
  * @return string
  */
 public function formatSuggestion(Process $process)
 {
     $pattern = '%s ';
     $dryrun = sprintf($pattern, ProcessUtils::escapeArgument('--dry-run'));
     $formatJson = sprintf($pattern, ProcessUtils::escapeArgument('--format=json'));
     return str_replace([$dryrun, $formatJson], '', $process->getCommandLine());
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $apply = $input->getOption('apply');
     $filename = 'app/config/parameters.yml';
     if (!file_exists($filename)) {
         throw new RuntimeException("No such file: " . $filename);
     }
     $data = file_get_contents($filename);
     $config = Yaml::parse($data);
     if (isset($config['pdo'])) {
         $pdo = $config['pdo'];
     } else {
         if (!isset($config['parameters']['pdo'])) {
             throw new RuntimeException("Can't find pdo configuration");
         }
         $pdo = $config['parameters']['pdo'];
     }
     $cmd = 'vendor/bin/dbtk-schema-loader schema:load app/schema.xml ' . $pdo;
     if ($apply) {
         $cmd .= ' --apply';
     }
     $process = new Process($cmd);
     $output->writeLn($process->getCommandLine());
     $process->run();
     if (!$process->isSuccessful()) {
         throw new ProcessFailedException($process);
     }
     $output->write($process->getOutput());
 }
コード例 #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var QuestionHelper $helper */
     $helper = $this->getHelper('question');
     $target = $this->rootPath . '/' . basename($this->pathToPackage);
     $question = new ConfirmationQuestion(sprintf('<question>File in %s already exists. Replace?</question> [yN] ', $target), false);
     if (!file_exists($target) || $helper->ask($input, $output, $question)) {
         copy($this->pathToPackage, $target);
         $output->writeln(sprintf('Dumped default package to <info>%s</info>', $target));
     } else {
         $output->writeln(sprintf('Please update <info>%s</info> by example in <info>%s</info> manually', $target, $this->pathToPackage));
     }
     $target = $this->configPath . '/' . basename($this->pathToWebpackConfig);
     $question = new ConfirmationQuestion(sprintf('<question>File in %s already exists. Replace?</question> [yN] ', $target), false);
     if (!file_exists($target) || $helper->ask($input, $output, $question)) {
         copy($this->pathToWebpackConfig, $target);
         $output->writeln(sprintf('Dumped default webpack config to <info>%s</info>', $target));
     } else {
         $output->writeln(sprintf('Please update <info>%s</info> by example in <info>%s</info> manually', $target, $this->pathToWebpackConfig));
     }
     $process = new Process('npm install', $this->rootPath);
     $question = new ConfirmationQuestion(sprintf('<question>Should I install node dependencies?</question> (%s) [Yn] ', $process->getCommandLine()), true);
     if ($helper->ask($input, $output, $question)) {
         $process->setTimeout(600);
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $output->writeln('Please update dependencies manually before compiling webpack assets');
     }
     $output->writeln('Run <bg=white;fg=black>maba:webpack:compile</> to compile assets when deploying');
     $output->writeln('Always run <bg=white;fg=black>maba:webpack:dev-server</> in dev environment');
 }
コード例 #6
0
 private function runCommandProcess($cmd, OutputInterface $output)
 {
     $process = new Process($cmd);
     $output->writeLn('<comment>' . $process->getCommandLine() . '</comment>');
     $process->run();
     $output->writeLn($process->getOutput());
 }
コード例 #7
0
ファイル: LockingTest.php プロジェクト: kmelia/fresh-symfony
 /**
  * @group console
  */
 public function testSleeperCommand()
 {
     // init
     $sleeperCommand = new SleeperCommand();
     $sleeperCommandLockFilePath = sprintf('%s/lock_command_%s', $this->getClient()->getKernel()->getCacheDir(), str_replace(':', '_', $sleeperCommand->getName()));
     $commandline = sprintf('env bin/console --env=%s %s', $this->getClient()->getKernel()->getEnvironment(), $sleeperCommand->getName());
     // the first run of this command with the locking mechanism: the lock is created
     $firstProcess = new Process($commandline);
     $firstProcess->start();
     sleep(SleeperCommand::SLEEPING_TIME / 2);
     // the second run of this command is invalid
     $secondProcess = new Process($commandline);
     $secondProcess->run();
     $this->assertSame(2, $secondProcess->getExitCode(), 'Invalid exit code');
     $secondProcessOutput = $secondProcess->getOutput();
     $this->assertSame(2, substr_count($secondProcessOutput, PHP_EOL), 'There is more than two lines');
     $this->assertContains('locking is activated', $secondProcessOutput, 'Incorrect line 1');
     $this->assertContains('will not be started', $secondProcessOutput, 'Incorrect line 2');
     // check the first process is still running
     $this->assertTrue($firstProcess->isRunning(), sprintf('The command %s does not work', $firstProcess->getCommandLine()));
     // after the sleeping, the lock is released
     sleep(1 + SleeperCommand::SLEEPING_TIME / 2);
     $this->assertSame(0, $firstProcess->getExitCode());
     $firstProcessOutput = $firstProcess->getOutput();
     $this->assertSame(3, substr_count($firstProcessOutput, PHP_EOL), 'There is more than three lines');
     $this->assertContains('starting', $firstProcessOutput);
     $this->assertContains('processing', $firstProcessOutput);
     $this->assertContains('ending', $firstProcessOutput);
     // the third run of this command, after the sleeping, is valid
     $thirdProcess = new Process($commandline);
     $thirdProcess->run();
     $this->assertSame(0, $thirdProcess->getExitCode());
 }
コード例 #8
0
 /**
  * Starts a wiremock process.
  *
  * @param string $jarPath
  * @param string $logsPath
  * @param string $arguments
  *
  * @throws \Exception
  */
 public function start($ip, $port, $path, $logsPath, $debug)
 {
     $phiremockPath = is_file($path) ? $path : "{$path}/phiremock";
     $this->process = new Process($this->getCommandPrefix() . "{$phiremockPath} -i {$ip} -p {$port}" . ($debug ? ' -d' : ''));
     if ($debug) {
         echo 'Executing: ' . $this->process->getCommandLine() . PHP_EOL;
     }
     $logFile = $logsPath . DIRECTORY_SEPARATOR . self::LOG_FILE_NAME;
     $this->process->start(function ($type, $buffer) use($logFile) {
         file_put_contents($logFile, $buffer, FILE_APPEND);
     });
     $this->process->setEnhanceSigchildCompatibility(true);
     if ($this->isWindows()) {
         $this->process->setEnhanceWindowsCompatibility(true);
     }
 }
コード例 #9
0
 public function __construct(Process $process)
 {
     $error = sprintf('PHP error message was detected when running this command:' . PHP_EOL . '  %s' . PHP_EOL . 'Moodle scripts should run without any PHP errors.', $process->getCommandLine());
     if (!$process->isOutputDisabled()) {
         $error .= sprintf("\n\nError Output\n============\n%s", $process->getErrorOutput());
     }
     parent::__construct($error);
 }
コード例 #10
0
 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.' . "\n\nOutput:\n================\n" . $process->getOutput() . "\n\nError Output:\n================\n" . $process->getErrorOutput(), $process->getCommandLine()));
     $this->process = $process;
 }
コード例 #11
0
ファイル: Local.php プロジェクト: anorgan/deployer-common
 public function runCommands()
 {
     $commands = implode('; ', $this->getCommands());
     $process = new Process($commands, $this->getPath());
     $process->setTimeout(600);
     $process->setIdleTimeout(null);
     $this->logger->info('Running "' . $process->getCommandLine() . '"');
     $process->mustRun();
 }
コード例 #12
0
 /**
  * @param OutputInterface $output
  * @param Process $process
  */
 private function runProcess(OutputInterface $output, Process $process)
 {
     if ($output->getVerbosity() >= $output::VERBOSITY_VERBOSE) {
         $output->writeln(sprintf('<comment>Execute: <info>%s</info></comment>', $process->getCommandLine()));
     }
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
コード例 #13
0
 public static function forProcess(Process $process)
 {
     $shortError = $fullError = $process->getErrorOutput();
     if (preg_match('~^fatal: (.+)$~', $shortError, $matches)) {
         $shortError = trim($matches[1]);
     } elseif (preg_match('~^\\s+\\[([\\w\\\\]+\\\\)?(\\w+)\\]\\s+(.+)\\n\\n\\S~s', $shortError, $matches)) {
         $shortError = trim($matches[2]) . ': ' . trim($matches[3]);
     }
     return new static($process->getCommandLine(), $process->getExitCode(), $shortError, $fullError);
 }
コード例 #14
0
ファイル: ProcessRunner.php プロジェクト: php-lug/webhook
 /**
  * @param Process $process
  */
 public function run(Process $process)
 {
     $this->logger->debug(sprintf('Webhook process started: "%s".', $command = $process->getCommandLine()));
     $process->run();
     if ($process->isSuccessful()) {
         $this->logger->debug(sprintf('Webhook process finished: "%s".', $command), ['output' => $process->getOutput()]);
     } else {
         $this->logger->error(sprintf('Webhook process errored: "%s".', $command), ['output' => $process->getOutput(), 'error' => $process->getErrorOutput()]);
     }
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function run(Process $process, $mustSucceed = true)
 {
     $this->userInteraction->write('<info>RUN</info> ' . $process->getCommandLine());
     if ($mustSucceed) {
         $process->setTimeout(null);
         return $process->mustRun($this->getRunningProcessCallback());
     }
     $process->run($this->getRunningProcessCallback());
     return $process;
 }
コード例 #16
0
ファイル: CheckCommand.php プロジェクト: delegator/magegen
 public function phpLint($path)
 {
     $command = new Process('php -l ' . escapeshellarg($path));
     $command->run();
     if (!$command->isSuccessful()) {
         $this->error($command->getCommandLine());
         $this->output->write($command->getErrorOutput());
         exit($command->getExitCode());
     }
 }
コード例 #17
0
 /**
  * @param Process $process
  *
  * @return TestCase
  */
 public function test(Process $process)
 {
     $process->run();
     $testcase = new TestCase($process->getCommandLine(), 0);
     $testcase->incAssertions();
     if ($process->getExitCode() != 0) {
         $testcase->setFailure(new TestFailure('exec', $process->getOutput()));
         return $testcase;
     }
     return $testcase;
 }
コード例 #18
0
ファイル: Ssh.php プロジェクト: anorgan/deployer-common
 public function runCommands()
 {
     $commands = ['cd ' . $this->getPath()];
     $commands = array_merge($commands, $this->getCommands());
     $commands = implode('; ', $commands);
     $process = new Process($commands);
     $commandLine = $process->getCommandLine();
     $this->logger->info('Running "' . $commandLine . '"');
     $output = $this->getSession()->getExec()->run($commandLine);
     $this->logger->info('Output:' . PHP_EOL . $output);
 }
コード例 #19
0
 /**
  * {@inheritdoc}
  */
 public function run(Process $process, SplObjectStorage $listeners, $bypassErrors)
 {
     $this->logger->info(sprintf('%s running command %s', $this->name, $process->getCommandLine()));
     try {
         $process->run($this->buildCallback($listeners));
     } catch (RuntimeException $e) {
         if (!$bypassErrors) {
             $this->doExecutionFailure($process->getCommandLine(), $e);
         }
     }
     if (!$bypassErrors && !$process->isSuccessful()) {
         $this->doExecutionFailure($process->getCommandLine());
     } elseif (!$process->isSuccessful()) {
         $this->logger->error(sprintf('%s failed to execute command %s', $this->name, $process->getCommandLine()));
         return;
     } else {
         $this->logger->info(sprintf('%s executed command successfully', $this->name));
         return $process->getOutput();
     }
 }
コード例 #20
0
 /**
  * @param Process $process
  */
 public function __construct(Process $process)
 {
     $this->command = $process->getCommandLine();
     $this->exitCode = $process->getExitCode();
     $this->output = $process->getOutput();
     $this->errorOutput = $process->getErrorOutput();
     if (!($message = $this->getCleanErrorOutput())) {
         $message = $this->output;
     }
     parent::__construct($message, $this->getExitCode());
 }
コード例 #21
0
 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());
     }
 }
コード例 #22
0
 /**
  * @param string $command
  * @param OutputInterface $output
  * @param callable|null $callback A valid PHP callback
  */
 protected function basicProcess($command, OutputInterface $output, $callback = null)
 {
     $process = new Process($command);
     $process->setTimeout(600);
     $output->writeln($this->helper->formatSection('Executing', $process->getCommandLine(), 'comment'));
     $process->start();
     $process->wait(function ($type, $buffer) use($output) {
         if (Process::ERR == $type) {
             $output->write($this->helper->formatSection('Error', $buffer, 'error'));
         } else {
             $output->write($this->helper->formatSection('Progress', $buffer, 'comment'));
         }
     });
     if ($process->isTerminated()) {
         $output->writeln($this->helper->formatSection('Finishing', $process->getCommandLine(), 'comment'));
         if (null !== $callback) {
             $callback();
         }
     }
 }
コード例 #23
0
 public function __construct(Process $process)
 {
     if ($process->isSuccessful()) {
         throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
     }
     $error = sprintf('The command "%s" failed.' . "\nExit Code: %s(%s)", $process->getCommandLine(), $process->getExitCode(), $process->getExitCodeText());
     if (!$process->isOutputDisabled()) {
         $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", $process->getOutput(), $process->getErrorOutput());
     }
     parent::__construct($error);
     $this->process = $process;
 }
コード例 #24
0
ファイル: StartCommand.php プロジェクト: Bonscho/packages
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $env = array('QUEUE' => $input->getArgument('queues'), 'VERBOSE' => $input->getOption('verbose'), 'COUNT' => $input->getOption('count'), 'INTERVAL' => $input->getOption('interval'), 'PREFIX' => 'resque:');
     $redisHost = $this->container->getParameter('packages.resque.host');
     $redisPort = $this->container->getParameter('packages.resque.port');
     $redisDatabase = $this->container->getParameter('packages.resque.database');
     if ($redisHost != null && $redisPort != null) {
         $backend = strpos($redisHost, 'unix:') === false ? $redisHost . ':' . $redisPort : $redisHost;
         $env['REDIS_BACKEND'] = $backend;
     }
     if (isset($redisDatabase)) {
         $env['REDIS_BACKEND_DB'] = $redisDatabase;
     }
     $opt = '';
     if (0 !== ($m = (int) $input->getOption('memory-limit'))) {
         $opt = sprintf('-d memory_limit=%dM', $m);
     }
     $workerCommand = strtr('%bin% %opt% %dir%/bin/resque', array('%bin%' => $this->getPhpBinary(), '%opt%' => $opt, '%dir%' => $this->container->getParameter('app.root_dir')));
     if (!$input->getOption('foreground')) {
         $workerCommand = strtr('nohup %cmd% > %logs_dir%/resque.log 2>&1 & echo $!', array('%cmd%' => $workerCommand, '%logs_dir%' => $this->container->getParameter('app.log_dir')));
     }
     // In windows: When you pass an environment to CMD it replaces the old environment
     // That means we create a lot of problems with respect to user accounts and missing vars
     // this is a workaround where we add the vars to the existing environment.
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         foreach ($env as $key => $value) {
             putenv($key . "=" . $value);
         }
         $env = null;
     }
     $process = new Process($workerCommand, null, $env, null, null);
     if (!$input->getOption('quiet')) {
         $output->writeln(sprintf('Executing <info>%s</info>...', $process->getCommandLine()));
     }
     if ($input->getOption('foreground')) {
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $process->run();
         if (function_exists('gethostname')) {
             $hostname = gethostname();
         } else {
             $hostname = php_uname('n');
         }
         if (!$input->getOption('quiet')) {
             $workers = $env['COUNT'];
             $output->writeln(sprintf('Starting <info>%s %s</info> on <info>%s</info> for <info>%s</info> queues', $workers, $workers != 1 ? 'workers' : 'worker', $hostname, $input->getArgument('queues')));
         }
     }
     $output->writeln('');
 }
コード例 #25
0
ファイル: FilterException.php プロジェクト: sidibea/castor
 public static function fromProcess(Process $proc)
 {
     $message = sprintf("An error occurred while running:\n%s", $proc->getCommandLine());
     $errorOutput = $proc->getErrorOutput();
     if (!empty($errorOutput)) {
         $message .= "\n\nError Output:\n" . str_replace("\r", '', $errorOutput);
     }
     $output = $proc->getOutput();
     if (!empty($output)) {
         $message .= "\n\nOutput:\n" . str_replace("\r", '', $output);
     }
     return new self($message);
 }
コード例 #26
0
 /**
  * Execute a command and return the output
  *
  * @param  string     $command
  * @return string
  * @throws \Exception
  */
 public function executeCommand($command)
 {
     $command = self::getBinary() . ' ' . $command;
     $process = new Process($command);
     $this->logger->addInfo(sprintf('Exiftool executes command %s', $process->getCommandLine()));
     $process->run();
     if (!$process->isSuccessful()) {
         throw new RuntimeException(sprintf('Command %s failed : %s, exitcode %s', $command, $process->getErrorOutput(), $process->getExitCode()));
     }
     $output = $process->getOutput();
     unset($process);
     return $output;
 }
コード例 #27
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $kernel = $this->getContainer()->get('kernel');
     /** @var $kernel Kernel */
     $res = $kernel->locateResource('@AvanzuAdminThemeBundle/Resources/bower');
     $helper = $this->getHelperSet()->get('formatter');
     /** @var $helper FormatterHelper */
     $bower = $this->getContainer()->getParameter('avanzu_admin_theme.bower_bin');
     $action = $input->getOption('update') ? 'update' : 'install';
     $asRoot = $input->getOption('root') ? '--allow-root' : '';
     $process = new Process($bower . ' ' . $action . ' ' . $asRoot);
     $process->setTimeout(600);
     $output->writeln($helper->formatSection('Executing', $process->getCommandLine(), 'comment'));
     $process->setWorkingDirectory($res);
     $process->run(function ($type, $buffer) use($output, $helper) {
         if (Process::ERR == $type) {
             $output->write($helper->formatSection('Error', $buffer, 'error'));
         } else {
             $output->write($helper->formatSection('Progress', $buffer, 'info'));
         }
     });
     // no more pulling/cloning directly from master in favor of a bower installation with specific version constraint
     /*
     $process = new Process('git clone https://github.com/almasaeed2010/AdminLTE.git');
             $process->setWorkingDirectory(dirname($res).'/public/vendor');
             // run checkout if no dir present
             // run update only if update requested
             $process = null;
             $adminlte_dir = dirname($res).'/public/vendor/AdminLTE';
             if($input->getOption('update')) {
                 $process = new Process('git pull');
                 $process->setWorkingDirectory($adminlte_dir);
             }
             $output->writeln($helper->formatSection('Executing',$process->getCommandLine(), 'comment'));
     if(!is_dir($adminlte_dir)) {
                 $process = new Process('git clone https://github.com/almasaeed2010/AdminLTE.git');
                 $process->setWorkingDirectory(dirname($adminlte_dir));
             }
     if ($process) {
                 $output->writeln($helper->formatSection('Executing',$process->getCommandLine(), 'comment'));
         $process->run(function($type, $buffer) use ($output, $helper){
                     if(Process::ERR == $type) {
                         $output->write($helper->formatSection('Error', $buffer, 'error' ));
                     } else {
                         $output->write($helper->formatSection('Progress', $buffer, 'info' ));
                     }
                 });
             }
     */
 }
コード例 #28
0
 /**
  * Executes a Process and throws a consistent exception
  *
  * @param Process $process
  * @param bool $throwExceptionOnFailure
  * @param null $extraMessage
  * @throws GitException
  */
 private function executeProcess(Process $process, $throwExceptionOnFailure = true, $extraMessage = null)
 {
     $process->run();
     if (!$process->isSuccessful() && $throwExceptionOnFailure) {
         // sometimes an unsuccessful command will still render output, instead of error output
         // this happens, for example, when merging and having a conflict
         $output = $process->getErrorOutput() ? $process->getErrorOutput() : $process->getOutput();
         $msg = sprintf('Error executing "%s": %s', $process->getCommandLine(), $output);
         if ($extraMessage) {
             $msg = $extraMessage . ' ' . $msg;
         }
         throw new GitException($msg);
     }
 }
コード例 #29
0
ファイル: Sparkle.php プロジェクト: sourcestream/highcore-api
 /**
  * @inheritdoc
  * @var string $stack_definition Json-encoded set of stack parameters
  */
 public function getTemplate(Template $template, $stack_definition, $update = true)
 {
     $update && $this->updateTemplate($template);
     $parameters = (new ParametersCollection(['stack_definition' => $stack_definition, 'template' => $template->name]))->toShell();
     $input = new ArrayInput($parameters, $this->getInputDefinition($template));
     $command = new Process("./template.sh {$input}", $this->getTemplatePath($template), $this->getTemplateScriptEnv());
     Log::debug(sprintf('Calling sparke for template %s in project %s: %s', $template->name, $template->project->name, $command->getCommandLine()));
     //$exitCode = 0; //$command->run();
     $exitCode = $command->run();
     if ($exitCode) {
         throw new Exception($command->getErrorOutput());
     }
     //$output = ''; //$command->getOutput();
     $output = $command->getOutput();
     return $output;
 }
コード例 #30
0
ファイル: Process.php プロジェクト: TomAdam/db-backup
 /**
  * @param string          $command
  * @param array           $arguments
  * @param array           $env
  * @param LoggerInterface $logger
  *
  * @return Process
  */
 public static function exec($command, array $arguments, array $env = [], LoggerInterface $logger = null)
 {
     $process = new BaseProcess(strtr($command, $arguments));
     if ($logger) {
         $logger->debug('Executing ' . $process->getCommandLine());
     }
     try {
         $process->setEnv($env)->setTimeout(null)->mustRun();
     } catch (ProcessFailedException $exception) {
         if ($logger) {
             $logger->error($exception->getMessage());
         }
         throw $exception;
     }
     return $process;
 }