setCommandLine() public method

Sets the command line to be executed.
public setCommandLine ( string $commandline ) : self
$commandline string The command to execute
return self The current Process instance
コード例 #1
0
 /**
  * @When /^I run behat$/
  */
 public function iRunBehat()
 {
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"')), '--format=progress'));
     $this->process->start();
     $this->process->wait();
 }
コード例 #2
0
 /**
  * Runs behat command with provided parameters
  *
  * @When /^I run "behat(?: ([^"]*))?"$/
  *
  * @param   string $argumentsString
  */
 public function iRunBehat($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, array('\'' => '"'));
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $argumentsString, strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"'))));
     $this->process->run();
 }
コード例 #3
0
ファイル: Process.php プロジェクト: vuthaihoc/pdf-parser
 /**
  * Run a command as a process.
  *
  * @param string $command
  * @return self
  */
 public function run($command)
 {
     $this->command = escapeshellcmd($command);
     $this->process->setCommandLine($this->command);
     $this->process->run();
     $this->validateRun();
     return $this;
 }
コード例 #4
0
ファイル: ZipArchiver.php プロジェクト: nadimtuhin/archiver
 /**
  * Executes the backup command.
  */
 public function archive()
 {
     $this->process->setCommandLine($this->getCommand());
     $this->process->run();
     if ($this->process->getErrorOutput()) {
         throw new \RuntimeException($this->process->getErrorOutput());
     }
 }
コード例 #5
0
 /**
  * @param $command
  * @throws ShellProcessFailed
  * @throws \Symfony\Component\Process\Exception\LogicException
  */
 public function process($command)
 {
     if (empty($command)) {
         return;
     }
     $this->process->setCommandLine($command);
     $this->process->run();
     if (!$this->process->isSuccessful()) {
         throw new ShellProcessFailed($this->process->getErrorOutput());
     }
 }
コード例 #6
0
ファイル: FeatureContext.php プロジェクト: Canu667/todoapp
 /**
  * @param string $configurationAsString
  */
 private function doRunBehat($configurationAsString)
 {
     $this->process->setWorkingDirectory($this->testApplicationDir);
     $this->process->setCommandLine(sprintf('%s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $configurationAsString));
     $this->process->start();
     $this->process->wait();
 }
コード例 #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->downloadConfiguration();
     $library = new GLibc();
     try {
         $this->download()->extract();
         $library->setEnv($this->env)->setProjectDir($this->baseDir)->initialize()->boot($input, $output);
         $configure = $this->projectDir . '/' . $library->configure();
         $this->projectDir = dirname($this->projectDir) . '/glibc-build';
         $this->fs->mkdir($this->projectDir);
         $this->output->write('    Building   :  ');
         $process = new Process($configure, $this->projectDir, $this->env->toArray());
         $process->setTimeout(0);
         $process->run();
         if ($process->isSuccessful()) {
             $process->setCommandLine('make -j4 && make -j4 install');
             $process->run();
         }
         if ($process->isSuccessful()) {
             $message = '<info>✔</info>';
         } else {
             $message = '<error>✕</error>';
         }
         $this->output->writeln($message);
     } catch (\Exception $e) {
         $this->cleanUp();
         throw $e;
     }
     $this->createConfiguration();
     $this->output->writeln(sprintf(" <info>%s</info>  Droidphp Installer <info>successfully configured</info> Now you can:\n" . "    * Run :\n" . "        1. Execute the <comment>%s build:components</comment> command.\n" . " To Build the project\n\n", defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔', basename($_SERVER['PHP_SELF'])));
 }
コード例 #8
0
 /**
  * Runs Behat with provided parameters.
  *
  * @When /^I run "behat(?: ((?:\"|[^"])*))?"$/
  *
  * @param string $argumentsString
  */
 public function iRunBehat($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, ['\'' => '"']);
     $this->behatProcess->setWorkingDirectory($this->workingDir);
     $this->behatProcess->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $argumentsString, strtr('--format-settings=\'{"timer": false}\' --no-colors', ['\'' => '"', '"' => '\\"'])));
     $this->behatProcess->start();
     $this->behatProcess->wait();
 }
コード例 #9
0
 /**
  * Runs phpspec command with provided parameters
  *
  * @When /^I run "phpspec(?: ((?:\"|[^"])*))?"$/
  *
  * @param string $argumentsString
  */
 public function iRunPhpspec($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, array('\'' => '"'));
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s --no-interaction', $this->phpBin, escapeshellarg($this->getPhpspecBinPath()), $argumentsString));
     $this->process->start();
     $this->process->wait();
 }
コード例 #10
0
 function it_should_not_process_empty_commands(Process $process)
 {
     $process->setCommandLine('')->shouldNotBeCalled();
     $process->run()->shouldNotBeCalled();
     $process->isSuccessful()->willReturn(true);
     /** @noinspection PhpParamsInspection */
     $this->beConstructedWith($process);
     $this->process('');
 }
コード例 #11
0
ファイル: FeatureContext.php プロジェクト: robmasters/filler
 /**
  * Runs behat command with provided parameters
  *
  * @When /^I run "filler(?: ((?:\"|[^"])*))?"$/
  *
  * @param   string $argumentsString
  */
 public function iRunFiller($argumentsString = '')
 {
     $argumentsString = str_replace('{dir}', $this->workingDir, strtr($argumentsString, array('\'' => '"')));
     $this->process->setWorkingDirectory($this->workingDir);
     $command = sprintf('%s %s %s', $this->phpBin, escapeshellarg($this->binDir . 'filler'), $argumentsString);
     $this->process->setCommandLine($command);
     $this->process->start();
     // TODO store exit code and process output for verification
     $exitCode = $this->process->wait();
 }
コード例 #12
0
ファイル: CommandRunner.php プロジェクト: alebon/graviton
 /**
  * Executes a app/console command
  *
  * @param array           $args    Arguments
  * @param OutputInterface $output  Output
  * @param string          $message Message to be shown on error.
  *
  * @return integer|null Exit code
  */
 public function executeCommand(array $args, OutputInterface $output, $message)
 {
     $name = $args[0];
     $cmd = $this->getCmd($args);
     $output->writeln('');
     $output->writeln(sprintf('<info>Running %s</info>', $name));
     $output->writeln(sprintf('<comment>%s</comment>', $cmd));
     $this->process->setCommandLine($cmd);
     $this->process->run(function ($type, $buffer) use($output, $cmd) {
         if (Process::ERR === $type) {
             $output->writeln(sprintf('<error>%s</error>', $buffer));
         } else {
             $output->writeln(sprintf('<comment>%s</comment>', $buffer));
         }
     });
     if (!$this->process->isSuccessful()) {
         throw new \RuntimeException($message . '<error>' . $this->process->getErrorOutput() . '</error>');
     }
 }
コード例 #13
0
 /**
  * @param string $commandline
  * @return string
  * @throws ProcessFailedException
  */
 protected function runProcess($commandline)
 {
     if (null === $this->process) {
         $this->process = new Process(null);
     }
     $this->process->setCommandLine($commandline);
     $this->process->run();
     if (!$this->process->isSuccessful()) {
         throw new ProcessFailedException($this->process);
     }
     return trim($this->process->getOutput());
 }
コード例 #14
0
 protected static function executeCommand($command)
 {
     $process = new Process(null);
     $process->setCommandLine($command);
     $process->setTimeout(300);
     $process->run(function ($type, $buffer) {
         echo $buffer;
     });
     if (!$process->isSuccessful()) {
         throw new \RuntimeException(sprintf('An error occurred while executing \'%s\'.', $command));
     }
 }
コード例 #15
0
 public function start()
 {
     $seleniumUrl = $this->seleniumOptions->getSeleniumUrl();
     $seleniumQuery = $this->seleniumOptions->getSeleniumQuery();
     $seleniumJarLocation = $this->seleniumOptions->getSeleniumJarLocation();
     if (!$seleniumUrl || !$seleniumQuery || !$seleniumJarLocation) {
         throw new \LogicException('Url, Query and Selenium Jar Location is mandatory and Jar Location should point to a .jar file.');
     }
     if (!is_file($seleniumJarLocation)) {
         throw new \RuntimeException('Selenium jar is not a file');
     }
     if (!is_readable($seleniumJarLocation)) {
         throw new \RuntimeException('Selenium jar not readable - ' . $seleniumJarLocation);
     }
     if ($this->isSeleniumAvailable()) {
         throw new \RuntimeException('Selenium was already started');
     }
     $this->setStartCommand($this->createStartCommand());
     $this->process->setCommandLine($this->getStartCommand());
     $this->process->start();
     $this->responseWaitter->waitUntilAvailable($seleniumUrl, $seleniumQuery);
 }
コード例 #16
0
ファイル: Package.php プロジェクト: newup-playground/disco
 /**
  * Gets a Process for opening a URI.
  *
  * This method attempts to detect operating systems so it
  * is inevitable that it will fail at some point.
  *
  * @param $uri
  * @return Process
  */
 private function getProcess($uri)
 {
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         // ex: start "" "https://www.wikipedia.org/
         $command = 'start "" "' . $uri . '"';
     } else {
         // ex: open https://www.wikipedia.org/
         $command = 'open ' . $uri;
     }
     $process = new Process('', __DIR__);
     $process->setCommandLine($command);
     return $process;
 }
コード例 #17
0
 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function executeCommand($cmd, \Closure $closure = null, Process $process = null)
 {
     try {
         $cmd = $this->php . ' ' . $this->console . ' ' . $cmd;
         if (null === $process) {
             $process = new Process($cmd);
         } else {
             $process->setCommandLine($cmd);
         }
         return $process->run($closure);
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #18
0
ファイル: CommandActionSpec.php プロジェクト: gajdaw/stamp
 function it_should_not_run_command_in_dry_mode(VariableContainer $variableContainer, Process $process)
 {
     $params = array('commandTemplate' => 'echo "Hello, {{ subjectOfGreeting }}"');
     $variableContainer->getVariables()->willReturn(array('subjectOfGreeting' => 'WORLD'));
     $process->setCommandLine('echo "Hello, WORLD"')->shouldNotBeCalled();
     $process->disableOutput()->shouldNotBeCalled();
     $process->run()->shouldNotBeCalled();
     $process->getExitCode()->shouldNotBeCalled();
     $this->setParams($params);
     $this->setVerbose(true);
     $this->setDryRun(true);
     $this->exec()->shouldReturn(true);
     $this->getResult()->shouldReturn(null);
     $this->getOutput()->shouldReturn('command["echo "Hello, WORLD""]');
 }
コード例 #19
0
 /**
  * Runs behat command with provided parameters
  *
  * @When /^I run "behat(?: ((?:\"|[^"])*))?"$/
  *
  * @param   string $argumentsString
  */
 public function iRunBehat($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, array('\'' => '"'));
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $argumentsString, strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"'))));
     // Don't reset the LANG variable on HHVM, because it breaks HHVM itself
     if (!defined('HHVM_VERSION')) {
         $env = $this->process->getEnv();
         $env['LANG'] = 'en';
         // Ensures that the default language is en, whatever the OS locale is.
         $this->process->setEnv($env);
     }
     $this->process->start();
     $this->process->wait();
 }
コード例 #20
0
ファイル: functions.php プロジェクト: jamayka/db-patcher
/**
 * @param DBPatcher\PatchFile $patchFile
 * @param \Symfony\Component\Process\Process $process
 * @param resource $stdout
 * @param resource $stderr
 * @return DBPatcher\PatchFile
 */
function applyPhpPatch($patchFile, $process, $stdout = null, $stderr = null)
{
    if ($patchFile->extension === 'php') {
        $process->setTimeout(null);
        $process->setIdleTimeout(null);
        $process->setCommandLine('/usr/bin/env php ' . $patchFile->filename);
        $process->start(function ($type, $buffer) use($stdout, $stderr) {
            $pipe = $type === Process::ERR && is_resource($stderr) ? $stderr : $stdout;
            if ($pipe) {
                fputs($pipe, $buffer);
            }
        });
        if ($process->wait() === 0) {
            return array(DBPatcher\PatchFile::copyWithNewStatus($patchFile, DBPatcher\PatchFile::STATUS_INSTALLED));
        } else {
            return array(DBPatcher\PatchFile::copyWithNewStatus($patchFile, DBPatcher\PatchFile::STATUS_ERROR), $process->getErrorOutput());
        }
    }
    return array(DBPatcher\PatchFile::copyWithNewStatus($patchFile, DBPatcher\PatchFile::STATUS_ERROR));
}
コード例 #21
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $start = microtime(true);
     if (Storage::makeDirectory('tmp')) {
         $dirs = Storage::allDirectories('tmp');
         do {
             $id = str_random(8);
         } while (in_array($id, $dirs));
         $id = 'tmp/' . $id;
         if (Storage::makeDirectory($id)) {
             Storage::put($id . '/document.tex', $this->document);
             $process = new Process('xelatex --interaction=batchmode --draftmode document');
             $process->setTimeout(180);
             $process->setWorkingDirectory(storage_path('app/' . $id));
             $lap = microtime(true);
             $process->run();
             if ($process->isSuccessful()) {
                 Log::info('ProcessTeXpdf first time ' . (microtime(true) - $lap));
                 $process->setCommandLine('xelatex --interaction=batchmode document');
                 $lap = microtime(true);
                 $process->run();
             }
             if ($process->isSuccessful()) {
                 Log::info('ProcessTeXpdf second time ' . (microtime(true) - $lap));
                 if (Storage::exists('pdf/' . $this->filename . '.pdf')) {
                     Storage::delete('pdf/' . $this->filename . '.pdf');
                 }
                 if (Storage::move($id . '/document.pdf', 'pdf/' . $this->filename . '.pdf')) {
                     Storage::deleteDirectory($id);
                     Log::info('ProcessTeXpdf total time ' . (microtime(true) - $start));
                     return;
                 }
                 throw new \Exception('could not move pdf');
             }
             throw new \Exception('failed to run lualatex');
         }
         throw new \Exception('could not create app/tmp/' . $id);
     }
     throw new \Exception('could not create/use app/tmp');
 }
コード例 #22
0
 /**
  * Execute a command process.
  *
  * @param string $command
  * @param string $operation
  *
  * @throws BackupException
  * @throws BackupExportException
  * @throws BackupRestoreException
  *
  * @return boolean
  */
 public function run($command, $operation = 'default')
 {
     $this->output = null;
     try {
         $this->processInstance->setCommandLine($command);
         $this->processInstance->setTimeout(self::PROCESS_TIMEOUT);
         $this->processInstance->run();
         if (!$this->processInstance->isSuccessful()) {
             $this->output = $this->processInstance->getErrorOutput();
             return false;
         }
     } catch (Exception $exception) {
         $message = 'An error occurred that prevented the operation ' . $operation . ': ' . $exception->getMessage();
         switch ($operation) {
             case 'export':
                 throw new BackupExportException($message);
             case 'restore':
                 throw new BackupRestoreException($message);
             default:
                 throw new BackupException($message);
         }
     }
     return true;
 }
コード例 #23
0
ファイル: ComposerManager.php プロジェクト: PhonemeCms/cms
 private function setDirectoryToBaseFolderOnCommand(Process $command)
 {
     $commandLine = $command->getCommandLine();
     $commandLine = "cd " . $this->baseFolder . " && " . $commandLine;
     $command->setCommandLine($commandLine);
 }
コード例 #24
0
ファイル: Runner.php プロジェクト: rebelinblue/deployer
 /**
  * Runs a script locally.
  *
  * @param callable|null $callback
  *
  * @return int
  */
 public function run($callback = null)
 {
     $command = $this->wrapCommand($this->script);
     $this->process->setCommandLine($command);
     return $this->process->run($callback);
 }
コード例 #25
0
 protected function updateCommandLine()
 {
     parent::setCommandLine($this->getCommandLineWithOptions());
 }
コード例 #26
0
ファイル: ShellProcessor.php プロジェクト: hilmysyarif/phpv8
 /**
  * Executes the given command.
  *
  * @param  string  $command
  * @return void
  */
 public function process($command)
 {
     $this->process->setCommandLine($command);
     $this->process->run();
 }
コード例 #27
0
ファイル: DepControl.php プロジェクト: Choate/coderelease
 protected function runCommand($command)
 {
     $process = new Process($command);
     $exec = $process->setCommandLine('whereis dep')->mustRun()->getOutput();
     return $process->setCommandLine(sprintf('php %s --file=%s %s %s', trim(substr($exec, strpos($exec, '/'))), $this->deployScript, $command, $this->deployProject))->mustRun()->getOutput();
 }
コード例 #28
0
 /**
  * Modifies process command to add environment variable
  * Used instead of setEnv because:
  *  1) currently practically used only in TTY mode, which is only available in Linux
  *  2) setEnv resets all other environment variables, like PATH - this breaks things
  *  3) there is no portable way to get all current environment variables, $_ENV is empty by default
  *
  * @param Process $process
  * @param string $environment
  */
 private function addEnvironment(Process $process, $environment)
 {
     if (DIRECTORY_SEPARATOR !== '\\') {
         $process->setCommandLine($environment . ' ' . $process->getCommandLine());
     }
 }