protected function runSampleDataInstaller() { $installationArgs = $this->config->getArray('installation_args'); $processBuilder = new ProcessBuilder(['php', 'bin/magento', 'sampledata:deploy']); if (!OperatingSystem::isWindows()) { $processBuilder->setPrefix('/usr/bin/env'); } $process = $processBuilder->getProcess(); $process->setTimeout(86400); $process->start(); $process->wait(function ($type, $buffer) { $this->output->write($buffer, false); }); // @TODO Refactor code duplication if (!OperatingSystem::isWindows()) { $processBuilder->setPrefix('/usr/bin/env'); } $processBuilder = new ProcessBuilder(array('php', 'bin/magento', 'setup:upgrade')); $process = $processBuilder->getProcess(); $process->setTimeout(86400); $process->start(); $process->wait(function ($type, $buffer) { $this->output->write($buffer, false); }); }
/** * Build a Process to run tivodecode decoding a file with a MAK * * @param string $mak TiVo's Media Access Key * @param string $input Where the encoded TiVo file is * @param string $output Where the decoded MPEG file goes * * @return Process */ protected function buildProcess($mak, $input, $output) { $this->builder->setPrefix('/usr/local/bin/tivodecode'); $this->builder->setArguments([$input, '--mak=' . $mak, '--no-verify', '--out=' . $output]); $this->builder->setTimeout(null); return $this->builder->getProcess(); }
public function __construct(string $directory) { $this->builder = new ProcessBuilder(); $this->builder->setPrefix('./vendor/bin/php-cs-fixer'); $this->builder->add('fix'); $this->builder->add($directory); }
/** * Build a Process to run avahi-browse looking for TiVo on TCP * * @return Process */ protected function buildProcess() { $this->builder->setPrefix('avahi-browse'); $this->builder->setArguments(['--ignore-local', '--resolve', '--terminate', '_tivo-videos._tcp']); $this->builder->setTimeout(60); return $this->builder->getProcess(); }
public function __construct(string $directory) { $this->builder = new ProcessBuilder(); $this->builder->setPrefix('./vendor/bin/phpcs'); $this->builder->add($directory); $this->builder->add('--colors'); $this->builder->add('-p'); $this->builder->add('-s'); }
public function __construct($source = null) { $bin = $this->findExecutable($this->commands); $this->builder = new ProcessBuilder(); $this->builder->setPrefix($bin); if (!is_null($source)) { $this->setSource($source); } }
/** * Function to install Laravel * * @return string directory where app was installed */ public function install() { $this->command->comment("Foreman", "Installing fresh Laravel app"); $this->builder->setPrefix('composer'); $this->builder->setArguments(['create-project', 'laravel/laravel', $this->appDir, '--prefer-dist']); $this->builder->getProcess()->run(); $this->command->comment("Foreman", "Done, Laravel installed at: {$this->appDir}"); return $this->appDir; }
/** * @param string|array $prefix A command prefix or an array of command prefixes * @param null|string $cwd The working directory * @param float|null $timeout */ private function initProcessBuilder(array $prefix = [], $cwd = null, $timeout = null) { $this->processBuilder = new ProcessBuilder(); $this->processBuilder->setPrefix($prefix); if ($cwd !== null) { $this->setWorkingDirectory($cwd); } if ($timeout !== null) { $this->setTimeout($timeout); } }
/** * VideoDownload constructor. */ public function __construct(Config $config = null) { if (isset($config)) { $this->config = $config; } else { $this->config = Config::getInstance(); } $this->procBuilder = new ProcessBuilder(); if (!is_file($this->config->youtubedl)) { throw new \Exception("Can't find youtube-dl at " . $this->config->youtubedl); } elseif (!is_file($this->config->python)) { throw new \Exception("Can't find Python at " . $this->config->python); } $this->procBuilder->setPrefix(array_merge([$this->config->python, $this->config->youtubedl], $this->config->params)); }
public function execute() { global $wgPygmentizePath; function lang_filter($val) { return preg_match('/^[a-zA-Z0-9\\-_]+$/', $val); } $header = '// Generated by ' . basename(__FILE__) . "\n\n"; $lexers = array(); $builder = new ProcessBuilder(); $builder->setPrefix($wgPygmentizePath); $process = $builder->add('-L')->add('lexer')->getProcess(); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $output = $process->getOutput(); foreach (explode("\n", $output) as $line) { if (substr($line, 0, 1) === '*') { $newLexers = explode(', ', trim($line, "* :\n")); $lexers = array_merge($lexers, $newLexers); } } $lexers = array_unique($lexers); sort($lexers); $code = "<?php\n" . $header . 'return ' . var_export($lexers, true) . ";\n"; $code = preg_replace('/(\\d+ \\=\\>| (?=\\())/i', '', $code); $code = preg_replace("/^ +/m", "\t", $code); file_put_contents(__DIR__ . '/../SyntaxHighlight_GeSHi.lexers.php', $code); $this->output("Updated language list written to SyntaxHighlight_GeSHi.lexers.php\n"); }
/** * @return ProcessBuilder */ protected function createProcessBuilder() { $this->guardIsExecutable($this->executable); $processBuilder = new ProcessBuilder(); $processBuilder->setPrefix($this->executable); return $processBuilder; }
/** * Execute command * * @return int|mixed * @throws \Exception */ public function exec() { $args = func_get_args(); if (!$this->cmd) { throw new FWException('no cmd provided', 1); } $build = new ProcessBuilder(); $pro = $build->setPrefix($this->cmd)->setArguments($args)->getProcess(); $pro->setTimeout($this->timeout); $rm = new \ReflectionMethod($this, 'output'); $func = $rm->getClosure($this); $re = 0; if ($this->async) { $pro->start($func); } else { try { $pro->mustRun($func); $this->out = $pro->getOutput(); $re = $this->out; } catch (ProcessFailedException $e) { getLog()->error($e->getMessage()); $re = 1; } } return $re; }
/** * @return Process */ public function create() { $processBuilder = new ProcessBuilder(); $processBuilder->setPrefix('vendor/bin/behat'); $processBuilder->setArguments(['--init']); return $processBuilder->getProcess(); }
/** * Create process builder object * * @param array $arguments * * @return ProcessBuilder */ protected function createProcessBuilder(array $arguments = []) { $processBuilder = new ProcessBuilder($arguments); $processBuilder->setPrefix($this->getOption('bin', self::DEFAULT_BINARY)); $processBuilder->addEnvironmentVariables($this->getOption('env', [])); return $processBuilder; }
/** * Execute the job. * * @return void */ public function handle() { echo "Run task: #" . $this->job_id, "\n"; $task = Tasks::find($this->job_id); $task->status = Tasks::RUN; $task->save(); $client = new \Hoa\Websocket\Client(new \Hoa\Socket\Client('tcp://127.0.0.1:8889')); $client->setHost('127.0.0.1'); $client->connect(); $client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $this->job_id, "msg" => json_encode(["jid" => $this->job_id, "status" => Tasks::RUN])])); $builder = new ProcessBuilder(); $builder->setPrefix('ansible-playbook'); $builder->setArguments(["-i", "inv" . $this->job_id, "yml" . $this->job_id]); $builder->setWorkingDirectory(storage_path("roles")); $process = $builder->getProcess(); $process->run(); //echo $process->getOutput() . "\n"; $client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $this->job_id, "msg" => json_encode(["jid" => $this->job_id, "status" => Tasks::FINISH])])); $client->close(); $task->status = Tasks::FINISH; $task->content = file_get_contents(storage_path("tmp/log" . $this->job_id . ".txt")); $task->save(); unlink(storage_path("roles/yml" . $this->job_id)); unlink(storage_path("roles/inv" . $this->job_id)); unlink(storage_path("tmp/log" . $this->job_id . ".txt")); echo "End task: #" . $this->job_id, "\n"; }
/** * Execute this task * * @param \TYPO3\Surf\Domain\Model\Node $node * @param \TYPO3\Surf\Domain\Model\Application $application * @param \TYPO3\Surf\Domain\Model\Deployment $deployment * @param array $options * @throws \TYPO3\Surf\Exception\InvalidConfigurationException * @return void */ public function execute(Node $node, Application $application, Deployment $deployment, array $options = array()) { $this->assertRequiredOptionsExist($options); $dumpCommand = new ProcessBuilder(); $dumpCommand->setPrefix('mysqldump'); $dumpCommand->setArguments(array('-h', $options['sourceHost'], '-u', $options['sourceUser'], '-p' . $options['sourcePassword'], $options['sourceDatabase'])); $mysqlCommand = new ProcessBuilder(); $mysqlCommand->setPrefix('mysql'); $mysqlCommand->setArguments(array('-h', $options['targetHost'], '-u', $options['targetUser'], '-p' . $options['targetPassword'], $options['targetDatabase'])); $arguments = array(); $username = isset($options['username']) ? $options['username'] . '@' : ''; $hostname = $node->getHostname(); $arguments[] = $username . $hostname; if ($node->hasOption('port')) { $arguments[] = '-P'; $arguments[] = $node->getOption('port'); } $arguments[] = $mysqlCommand->getProcess()->getCommandLine(); $sshCommand = new ProcessBuilder(); $sshCommand->setPrefix('ssh'); $sshCommand->setArguments($arguments); $command = $dumpCommand->getProcess()->getCommandLine() . ' | ' . $sshCommand->getProcess()->getCommandLine(); $localhost = new Node('localhost'); $localhost->setHostname('localhost'); $this->shell->executeOrSimulate($command, $localhost, $deployment); }
/** * @return AnsibleGalaxyInterface */ public function testCreateInstance() { $process = new ProcessBuilder(); $process->setPrefix($this->getGalaxyUri())->setWorkingDirectory($this->getProjectUri()); $ansibleGalaxy = new AnsibleGalaxy($process); $this->assertInstanceOf('\\Asm\\Ansible\\Command\\AnsibleGalaxy', $ansibleGalaxy); return $ansibleGalaxy; }
/** * @param string $filename * @param string $ruleset * * @return Process */ protected function runPhpmd($filename, $ruleset) { $processBuilder = new ProcessBuilder(); $processBuilder->setPrefix(__DIR__ . '/../../vendor/bin/phpmd'); $processBuilder->add(__DIR__ . '/../Fixtures/code/' . $filename)->add('text')->add(__DIR__ . '/../../Rulesets/' . $ruleset); $process = $processBuilder->getProcess(); $process->run(); return $process; }
/** * Performs immediate task start - fire and forget. * Used in web requests to start task in background. * @param integer $taskId */ public static function runImmediateTask($taskId) { $command = new ProcessBuilder(); $command->setWorkingDirectory(Yii::getAlias('@app')); if (strncasecmp(PHP_OS, 'WIN', 3) === 0) { $command->setPrefix('yii.bat'); } else { $command->setPrefix('./yii'); } $command->add('deferred/index')->add("{$taskId}"); $process = $command->getProcess(); $process->setWorkingDirectory(Yii::getAlias('@app')); $process->setCommandLine($process->getCommandLine() . ' > /dev/null 2>&1 &'); if (isset(Yii::$app->params['deferred.env'])) { $process->setEnv(Yii::$app->params['deferred.env']); } $process->run(); }
/** * @return Process */ private function getProcess() { if (!$this->process) { $this->processBuilder->setPrefix($this->utilityCommands[$this->utility]); $this->processBuilder->setArguments(array_merge($this->utilityArguments[$this->utility], [$this->image])); $this->process = $this->processBuilder->getProcess(); } return $this->process; }
protected function getProcess($drupal, $dsn) { $builder = new ProcessBuilder(); $builder->inheritEnvironmentVariables(true); $builder->setWorkingDirectory($drupal); $builder->setPrefix('php'); $builder->setArguments(array('-d sendmail_path=`which true`', $this->drush, 'site-install', 'standard', "--db-url={$dsn}", '-y')); $process = $builder->getProcess(); return $process; }
/** * {@inheritdoc} */ public function getProcessBuilder(array $arguments, $timeout = self::DEFAULT_PROCESS_TIMEOUT) { $builder = new ProcessBuilder(); $builder->setPrefix($this->getPhpBinary()); $builder->setWorkingDirectory($this->getCwd()); $builder->setArguments($arguments); $builder->setTimeout($timeout); $builder->inheritEnvironmentVariables(true); return $builder; }
/** * Run a shell command. * * @param string $command * @param array $arguments * * @throws \RuntimeException If command execution fails */ protected function runCommand($command, array $arguments) { $builder = new ProcessBuilder($arguments); $builder->setPrefix($command); $process = $builder->getProcess(); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } }
protected function execute(InputInterface $input, OutputInterface $output) { $arguments = array('desc', $input->getArgument('class')); /* @var \PhpGuard\Application\Util\Runner $runner */ $container = $this->container; $runner = $container->get('runner'); $builder = new ProcessBuilder($arguments); $builder->setPrefix($runner->findExecutable('phpspec')); return $runner->run($builder)->getExitCode(); }
/** * @inheritdoc */ public function useBinary($binary) { if (!is_executable($binary)) { throw new InvalidArgumentException(sprintf('`%s` is not an executable binary', $binary)); } $this->binary = $binary; if (!static::$emulateSfLTS) { $this->builder->setPrefix($binary); } return $this; }
public function run($args) { $finder = new PhpExecutableFinder(); $builder = new ProcessBuilder(array('bin/console', 'satis:update', '--build')); $builder->setEnv('HOME', $this->getContainer()->getParameter('app.root_dir')); $builder->setPrefix($finder->find()); $process = $builder->getProcess(); $process->run(function ($type, $message) { echo $message; }); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return void */ public function run(InputInterface $input, OutputInterface $output) { /* @var $configuration \PhpHooks\Configuration */ $configuration = unserialize($input->getArgument('configuration')); if (false === file_exists($configuration['phpunit']['configuration'])) { return; } $processBuilder = new ProcessBuilder(); $processBuilder->setPrefix(__DIR__ . '/../../../bin/phpunit')->add('--configuration')->add($configuration['phpunit']['configuration']); $this->doExecute($processBuilder); }
public function run() { $builder = new ProcessBuilder(); $process = $builder->setPrefix($this->MediaConch)->add($this->source)->getProcess(); $process->run(); if ($process->isSuccessful()) { $this->success = true; $this->output = $process->getOutput(); } return $this; }
/** * @param Notification $notification * @param string $expectedCommandLine * * @dataProvider provideValidNotifications */ public function testConfigureProcessAcceptAnyValidNotification(Notification $notification, $expectedCommandLine) { try { $processBuilder = new ProcessBuilder(); $processBuilder->setPrefix(self::BINARY); $this->invokeMethod($this->getNotifier(), 'configureProcess', [$processBuilder, $notification]); $this->assertSame($expectedCommandLine, $processBuilder->getProcess()->getCommandLine()); } catch (\Exception $e) { $this->fail($e->getMessage()); } }
public function convert($imageUrl, $targetFilename, $targetFormat = 'png') { $export = sprintf('--export-%s=%s', $targetFormat, $targetFilename); $process = new XProcess($this->getContainer(), $this->getContainer()->getParameter('exec.inkscape')); $app = $process->getApplication(); $builder = new ProcessBuilder(); $builder->setPrefix($app); $arguments = ['--export-background=white', '--without-gui', $imageUrl, $export]; $cmd = $builder->setArguments($arguments)->getProcess()->getCommandLine(); return $process->run($cmd); }