protected static function stopServer() { if (!static::$enabled) { return; } self::$server->stop(); }
protected function execute(InputInterface $input, OutputInterface $output) { # снимаем ограничение времени выполнения скрипта (в safe-mode не работает) set_time_limit(0); $container = $this->getContainer(); $logger = $container->get('vidal.digest_logger'); $em = $container->get('doctrine')->getManager(); # рассылаем с помощью EventSendCommand $command = 'php ' . $container->get('kernel')->getRootDir() . '/console vidal:eventsend '; $doctors = $em->createQuery(' SELECT e.username FROM VidalMainBundle:User e ')->getResult(); $emails = array(); foreach ($doctors as $doctor) { $emails[] = $doctor['username']; } // $emails[] = '*****@*****.**'; $emails = array_diff($emails, $logger->getSentEmails()); for ($i = 0, $c = count($emails); $i < $c; $i = $i + 100) { $emails100 = array_slice($emails, $i, 100); $emails100 = implode(' ', $emails100); # формируем команду для рассылки соточки try { $processCmd = $command . $emails100; $process = new Process($processCmd); $process->run(); } catch (\Exception $e) { continue; } $process = null; sleep(40); } }
/** * Execute the command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return void */ public function execute(InputInterface $input, OutputInterface $output) { $process = new Process('vagrant resume', realpath(__DIR__ . '/../'), $_ENV, null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
public function download($in_dir) { $repo = $in_dir . '/' . $this->package . ".git"; if (is_dir($repo)) { return; } $cmd = 'git clone --mirror %s %s'; $process = new Process(sprintf($cmd, $this->url, $repo)); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } $cmd = 'cd %s && git update-server-info -f'; $process = new Process(sprintf($cmd, $repo)); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } $cmd = 'cd %s && git fsck'; $process = new Process(sprintf($cmd, $repo)); $process->setTimeout(3600); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } }
protected function dump_base(base $base, InputInterface $input, OutputInterface $output) { $date_obj = new DateTime(); $filename = sprintf('%s%s_%s.sql', p4string::addEndSlash($input->getArgument('directory')), $base->get_dbname(), $date_obj->format('Y_m_d_H_i_s')); $command = sprintf('mysqldump %s %s %s %s %s %s --default-character-set=utf8', '--host=' . escapeshellarg($base->get_host()), '--port=' . escapeshellarg($base->get_port()), '--user='******'--password='******'--databases', escapeshellarg($base->get_dbname())); if ($input->getOption('gzip')) { $filename .= '.gz'; $command .= ' | gzip -9'; } elseif ($input->getOption('bzip')) { $filename .= '.bz2'; $command .= ' | bzip2 -9'; } $output->write(sprintf('Generating <info>%s</info> ... ', $filename)); $command .= ' > ' . escapeshellarg($filename); $process = new Process($command); $process->setTimeout((int) $input->getOption('timeout')); $process->run(); if (!$process->isSuccessful()) { $output->writeln('<error>Failed</error>'); return 1; } if (file_exists($filename) && filesize($filename) > 0) { $output->writeln('OK'); return 0; } else { $output->writeln('<error>Failed</error>'); return 1; } }
public function __construct(\Symfony\Component\Process\Process $process) { $this->process = $process; $code = 0; $message = ''; // Not all of the ansible errors have output in stderr. Therefore, if // stderr is empty we will use the stdout output instead to get clues // on what the actual error was. $error = $process->getErrorOutput(); if (is_null($error)) { $error = $process->getOutput(); } // Figure out the specific error that occured if (false !== strpos($error, 'the playbook') && false !== strpos($error, 'could not be found')) { $code = self::NOT_FOUND; $message = self::NOT_FOUND_MSG; } else { if (false !== strpos($error, 'Syntax Error while loading YAML script')) { $code = self::SYNTAX_ERROR; $message = self::SYNTAX_ERROR_MSG; } else { if (false !== strpos($error, 'One or more undefined variables')) { $code = self::UNDEFINED_VARIABLE; $message = self::UNDEFINED_VARIABLE_MSG; } else { $code = self::GENERAL_ERROR; $message = self::GENERAL_ERROR_MSG; } } } parent::__construct($message, $code); }
/** * Compiles the Silex source code into one single Phar file. * * @param string $pharFile Name of the output Phar file */ public function compile($pharFile = 'silex.phar') { if (file_exists($pharFile)) { unlink($pharFile); } $process = new Process('git log --pretty="%h %ci" -n1 HEAD'); if ($process->run() > 0) { throw new \RuntimeException('The git binary cannot be found.'); } $this->version = trim($process->getOutput()); $phar = new \Phar($pharFile, 0, 'silex.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/..')->in(__DIR__ . '/../../vendor/pimple/pimple/lib')->in(__DIR__ . '/../../vendor/symfony/class-loader/Symfony/Component/ClassLoader')->in(__DIR__ . '/../../vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher')->in(__DIR__ . '/../../vendor/symfony/http-foundation/Symfony/Component/HttpFoundation')->in(__DIR__ . '/../../vendor/symfony/http-kernel/Symfony/Component/HttpKernel')->in(__DIR__ . '/../../vendor/symfony/routing/Symfony/Component/Routing')->in(__DIR__ . '/../../vendor/symfony/browser-kit/Symfony/Component/BrowserKit')->in(__DIR__ . '/../../vendor/symfony/css-selector/Symfony/Component/CssSelector')->in(__DIR__ . '/../../vendor/symfony/dom-crawler/Symfony/Component/DomCrawler'); foreach ($finder as $file) { $this->addFile($phar, $file); } $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../LICENSE'), false); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/ClassLoader.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload_namespaces.php')); // Stubs $phar->setStub($this->getStub()); $phar->stopBuffering(); // $phar->compressFiles(\Phar::GZ); unset($phar); }
/** * Compiles composer into a single phar file * * @throws \RuntimeException * @param string $pharFile The full path to the file to create */ public function compile($pharFile = 'composer.phar') { if (file_exists($pharFile)) { unlink($pharFile); } $process = new Process('git log --pretty="%h" -n1 HEAD'); if ($process->run() != 0) { throw new \RuntimeException('The git binary cannot be found.'); } $this->version = trim($process->getOutput()); $phar = new \Phar($pharFile, 0, 'composer.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in(__DIR__ . '/..'); foreach ($finder as $file) { $this->addFile($phar, $file); } $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->in(__DIR__ . '/../../vendor/symfony/'); foreach ($finder as $file) { $this->addFile($phar, $file); } $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/ClassLoader.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload.php')); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/.composer/autoload_namespaces.php')); $this->addComposerBin($phar); // Stubs $phar->setStub($this->getStub()); $phar->stopBuffering(); // disabled for interoperability with systems without gzip ext // $phar->compressFiles(\Phar::GZ); $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../LICENSE'), false); unset($phar); }
/** * @Route("/file-upload", name="uploadFile") * @Template() */ public function uploadFileAction(Request $request) { $allow = $request->get('private', false); /** @var File $file */ $file = $request->files->get('file'); $imageName = uniqid('legofy-online') . '.png'; $command = sprintf('legofy %s/%s %s/../../../web/images/%s', $file->getPath(), $file->getFilename(), __DIR__, $imageName); $process = new Process($command); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } $imagine = new Imagine(); $imageFile = $imagine->open(sprintf('%s/../../../web/images/%s', __DIR__, $imageName)); $box = $imageFile->getSize(); if ($box->getHeight() > $box->getWidth()) { $imageFile->resize(new Box(400, $box->getHeight() * (400 / $box->getWidth())))->crop(new Point(0, 0), new Box(400, 400)); } else { $newWidth = $box->getWidth() * (400 / $box->getHeight()); $imageFile->resize(new Box($newWidth, 400))->crop(new Point(($newWidth - 400) / 2, 0), new Box(400, 400)); } $imageFile->save(sprintf('%s/../../../web/images/thumbnails/%s', __DIR__, $imageName)); $image = new Image(); $image->setPrivate($allow)->setName($imageName)->setCreationDate(new \DateTime()); $em = $this->getDoctrine()->getManager(); $em->persist($image); $em->flush(); return new JsonResponse(['url' => $this->generateUrl('editImage', ['id' => $image->getId(), 'name' => $image->getName()])]); }
protected function execute(InputInterface $input, OutputInterface $output) { $distribution = $input->getArgument('distribution'); $version = $input->getArgument('version'); $download = $this->downloadProject($distribution, $version); $process = new Process("tar -xzf {$download['location']} -C /tmp/"); $process->start(); if (substr($version, 0, 3) == '7.x') { $finder = new Finder(); $process->wait(); // Find all modules dropped in to the distribution. $finder->files()->name("*.info"); $filename = array(); foreach ($finder->in($download['locationUncompressed']) as $file) { $filename[] = array('path' => $file->getRealPath(), 'filename' => $file->getFileName()); } // Create the array for the containing modules. $return = array(); foreach ($filename as $file) { $contents = $this->parse_info_file(file_get_contents($file['path'])); $machine_name = substr($file['filename'], 0, strpos($file['filename'], '.')); $return[$machine_name] = array('name' => $contents['name'], 'machine_name' => substr($file['filename'], 0, strpos($file['filename'], '.')), 'core' => $contents['core'], 'version' => $contents['version'], 'status' => 'Enabled', 'package' => isset($contents['package']) ? $contents['package'] : null); } $output->write(json_encode($return)); } }
/** *@group cmd */ public function testPhpdocIsInstalled() { $process = new Process('phpdoc --version'); $process->run(); $output = $process->getOutput(); $this->assertContains("phpDocumentor version", $output); }
/** * @param string $serialized * * @return Process */ public function deserialize($serialized) { $data = json_decode($serialized, true); $process = new Process($data['command']); $process->setTimeout($data['timeout']); return $process; }
/** * @param $command * @param $projectPath * @param OutputInterface $output */ protected function run($command, $projectPath, OutputInterface $output) { $process = new Process($command, $projectPath, array_merge($_SERVER, $_ENV), null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
/** * @param string $path * @param Event $event */ protected static function runFix($path, Event $event) { $bin = self::getOption('phpcsfixer-bin', $event); $failOnError = self::getOption('phpcsfixer-fail-on-error', $event); $logPrepend = self::getOption('phpcsfixer-log-prepend', $event); $level = self::getOption('phpcsfixer-level', $event); $fixers = self::getOption('phpcsfixer-fixers', $event); $config = self::getOption('phpcsfixer-config', $event); $dryRun = self::getOption('phpcsfixer-dry-run', $event); $command = array($bin, 'fix', $path); if ($level) { $command[] = '--level=' . $level; } if (!empty($fixers) && is_array($fixers)) { $command[] = '--fixers=' . implode(',', $fixers); } if ($config) { $command[] = '--config=' . $config; } if ($dryRun === true) { $command[] = '--dry-run'; } if (!$failOnError) { $command[] = '|| true'; } $process = new Process(implode(' ', $command), null, null, null, null, []); $process->mustRun(function ($type, $buffer) use($event, $logPrepend) { self::writeProcessBuffer($type, $buffer, $event, $logPrepend); }); }
protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getApplication()->getContainer(); $commandFile = realpath($_SERVER['SCRIPT_FILENAME']); $currentVersion = "v" . $container->getVersion(); $updateVersion = trim(@file_get_contents('https://raw.githubusercontent.com/kohkimakimoto/altax/master/version')); if (!$container->isPhar()) { $output->writeln('<error>You can not update altax. Because altax only supports self-update command on PHAR file version.</error>'); return 1; } if (!preg_match('/^v[0-9].[0-9]+.[0-9]+$/', $updateVersion)) { $output->writeln('<error>You can not update altax. Because the latest version of altax are not available for download.</error>'); return 1; } if ($currentVersion === $updateVersion) { $output->writeln('<info>You are already using altax version <comment>' . $updateVersion . '</comment>.</info>'); return 0; } $output->writeln(sprintf("Updating to version <info>%s</info>.", $updateVersion)); $tmpDir = "/tmp/" . uniqid("altax.update."); $process = new Process("mkdir {$tmpDir} && cd {$tmpDir} && curl -L https://raw.githubusercontent.com/kohkimakimoto/altax/master/installer.sh | bash -s local {$updateVersion}"); $process->setTimeout(null); if ($process->run() !== 0) { $output->writeln('<error>You can not update altax.'); return 1; } $fs = new Filesystem(); $fs->copy($tmpDir . "/altax.phar", $commandFile, true); $fs->remove($tmpDir); $output->writeln("Done."); }
/** * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output, $retried = false) { if ($this->getContainer()->get('foreman.accessor')->ping()) { $output->writeln('<error>The Foreman Processor server is already running.'); return; } if ($input->getOption('daemon')) { $phpPath = (new PhpExecutableFinder())->find(); $process = new Process($phpPath . ' app/console foreman:processor:start' . ($input->getOption('verbose') ? ' -v' : '')); $process->setTimeout(0); $output->writeln('<info>Starting daemon server...'); $process->start(); $accessor = $this->getContainer()->get('foreman.accessor'); $start = time(); $interval = $this->getContainer()->getParameter('foreman.processor')['interval']; //When we try to ping the server the first time, it almost always fails. //The server isn't started yet by the time we get here, so we wait. //Timeout = 3 seconds. Should be enough for all servers. while (!$accessor->ping() && time() - $start < 3) { sleep($interval); } if ($accessor->ping()) { $status = $accessor->status(); $output->writeln('<info>The server was started successfully with PID ' . $status['pid'] . '</info>'); } else { $output->writeln('<error>The server could not be started at this moment.</error>'); $output->writeln('Please check if the server port (' . $this->getContainer()->getParameter('foreman.processor.port') . ') is available.'); $output->writeln('If you have closed the server recently, the connection may not have released. Try again ' . 'in a few seconds.'); } } else { $output->writeln('<info>Starting the Foreman Processor...</info>'); $this->getContainer()->get('foreman.processor')->start($output, $input->getOption('verbose')); } }
/** * Run a terminal command * @param [array] $command [description] * @param [path] $directory [description] * @param OutputInterface $output [description] * @return [void] [description] */ private function runProcess($command, $directory, $output, $alias) { $output->writeln(''); if (is_array($command['line'])) { $commandLine = implode(' && ', $command['line']); } else { $commandLine = $command['line']; } $process = new Process($commandLine, $directory); $process->setTimeout(7600); $process->start(); if ($output->isVerbose()) { $process->wait(function ($type, $buffer) { echo $buffer; }); } else { $progress = new ProgressBar($output); $progress->setFormat("<comment>%message%</comment> [%bar%]"); $progress->setMessage($command['title']); $progress->start(); $progress->setRedrawFrequency(10000); while ($process->isRunning()) { $progress->advance(); } $progress->finish(); $progress->clear(); } $output->writeln(''); $output->write('<comment>' . $command['title'] . ' </comment><info>√ done</info>'); }
private function install(OutputInterface $output, $targetFolder, $symlinkName, $forceDownload, HttpSource $source) { $version = $source->getVersion(); $extractedFolder = 'PhpStorm-' . $version; if (is_dir($targetFolder . '/' . $extractedFolder) && false === $forceDownload) { $output->writeln(sprintf('<comment>Phpstorm <info>%s</info> already exists, skipping download..</comment>', $version)); } else { $output->write(sprintf('<comment>Download %s </comment><info>%s</info><comment>...</comment>', $source->getName(), $version)); $downloadProcess = new Process(sprintf("wget %s -O phpstorm.tar.gz", escapeshellarg($source->getUrl()))); $downloadProcess->setTimeout(3600); $downloadProcess->run(); $output->writeln(' <info>OK</info>'); if (!$downloadProcess->isSuccessful()) { throw new \RuntimeException($downloadProcess->getErrorOutput()); } $output->write('<comment>Extracting...</comment>'); $extractProcess = new Process(sprintf('tar xfz phpstorm.tar.gz; rm phpstorm.tar.gz; mv %1$s %2$s', escapeshellarg($extractedFolder), escapeshellarg($targetFolder))); $extractProcess->run(); $output->writeln(' <info>OK</info>'); if (!$extractProcess->isSuccessful()) { throw new \RuntimeException($extractProcess->getErrorOutput()); } } $output->write('<comment>Linking...</comment>'); $command = sprintf('cd %2$s && ln -s -f -T %1$s %3$s', escapeshellarg($extractedFolder), escapeshellarg($targetFolder), escapeshellarg($symlinkName)); $linkProcess = new Process($command); $linkProcess->run(); $output->writeln(' <info>OK</info>'); if (!$linkProcess->isSuccessful()) { throw new \RuntimeException($linkProcess->getErrorOutput()); } }
/** * Execute the command. * * @param InputInterface $input * @param OutputInterface $output */ public function execute(InputInterface $input, OutputInterface $output) { $process = new Process('vagrant up', $_ENV['PUBSTACK_PATH'], array_merge($_SERVER, $_ENV), null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('<info>Defining crontab task...</info>'); $output->writeln('<info>Please enter the frequency of data aggregating</info> <comment>(frequency must be equal "pinba_stats_history" of the pinba engine config)</comment>.'); $dialog = $this->getHelperSet()->get('dialog'); $frequency = $dialog->askAndValidate($output, 'Frequency (in minutes, default "15"): ', function ($answer) { if (intval($answer) <= 0) { throw new \RunTimeException('You must enter positive integer value'); } return $answer; }, false, '15'); $process = new Process('crontab -l'); $process->setTimeout(20); $process->run(); $crontabString = $process->isSuccessful() ? $process->getOutput() : ''; $path = realpath(__DIR__ . '/../../../console'); $command = '*/' . $frequency . ' * * * * ' . $path . ' aggregate'; if (strpos($crontabString, $command) === false) { $crontabString .= "\n" . $command . "\n"; } $file = tempnam(sys_get_temp_dir(), 'ipm'); file_put_contents($file, $crontabString); $process = new Process('crontab ' . $file); $process->setTimeout(20); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $output->writeln('<info>Crontab task are defined successfully</info>'); $output->writeln('<info>Please set parameter "aggregation_period" to value "PT' . $frequency . 'M" in config/parameters.yml</info>'); }
/** * Create process that lint PHP file. * * @param string $path path to file * * @return Process */ public function createProcessForFile($path) { $process = new Process('php -l ' . ProcessUtils::escapeArgument($path)); $process->setTimeout(null); $process->run(); return $process; }
/** * @return string */ public function compile() { $this->stopwatch->start('webpack.total'); $this->stopwatch->start('webpack.prepare'); // Recompile twig templates where its needed. $this->addSplitPoints(); $this->addResolveConfig(); // Write the webpack configuration file. file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.config.js', $this->generator->getConfiguration()); $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration()); $this->stopwatch->start('webpack.compiler'); $this->process->run(); $output = $this->process->getOutput() . $this->process->getErrorOutput(); $this->profiler->set('compiler.executed', true); $this->profiler->set('compiler.successful', strpos($output, 'Error:') === false); $this->profiler->set('compiler.last_output', $output); if ($this->profiler->get('compiler.successful')) { $this->tracker->rebuild(); } // Finally, write some logging for later use. file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.compiler.log', $output); $this->profiler->set('compiler.performance.compiler', $this->stopwatch->stop('webpack.compiler')->getDuration()); $this->profiler->set('compiler.performance.total', $this->stopwatch->stop('webpack.total')->getDuration()); return $output; }
public function execute(InputInterface $input, OutputInterface $output) { $process = new Process('vagrant destroy --force', realpath(__DIR__ . '/../'), array_merge($_SERVER, $_ENV), null, null); $process->run(function ($type, $line) use($output) { $output->write($line); }); }
/** * @param Process $process * @param OutputInterface $outputInterface * * @return int */ public function executeProcess(Process $process, OutputInterface $outputInterface) { return $process->run(function ($type, $buffer) use($outputInterface) { $type; $outputInterface->write($buffer); }); }
public function generate($url, $width, $height, $name) { $hash = md5($url); $thumbnail = new Thumbnail(); $thumbnail->url = $url; $thumbnail->width = $width; $thumbnail->height = $height; $thumbnail->relativePath = $this->compilePattern($width, $height, $name); $thumbnail->absolutePath = $this->documentRoot . '/' . $thumbnail->relativePath; if ($this->fs->exists($thumbnail->absolutePath)) { return $thumbnail; } $tmpFile = $this->cacheDir . '/' . $hash; if (!$this->fs->exists($this->cacheDir)) { $this->fs->mkdir($this->cacheDir); } if (!$this->fs->exists($tmpFile)) { $this->getImageForUrl($url, $tmpFile); } if (!$this->fs->exists(dirname($thumbnail->absolutePath))) { $this->fs->mkdir(dirname($thumbnail->absolutePath)); } $cmd = "convert %s[0] -resize '%dx%d^' -gravity center -crop %dx%d+0+0 +repage %s"; $process = new Process(sprintf($cmd, $tmpFile, $width, $height, $width, $height, $thumbnail->absolutePath)); $process->run(); if (!$process->isSuccessful()) { throw new \Exception($process->getErrorOutput()); } return $thumbnail; }
/** * Compiles composer into a single phar file * * @throws \RuntimeException */ public function compile() { $pharFile = 'refactor.phar'; if (file_exists($pharFile)) { unlink($pharFile); } $process = new Process('git log --pretty="%H" -n1 HEAD', $this->directory); if ($process->run() != 0) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.'); } $this->version = trim($process->getOutput()); $process = new Process('git describe --tags HEAD'); if ($process->run() == 0) { $this->version = trim($process->getOutput()); } $phar = new \Phar($pharFile, 0, 'refactor.phar'); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->in($this->directory . '/src/main'); foreach ($finder as $file) { $this->addFile($phar, $file); } $finder = new Finder(); $finder->files()->ignoreVCS(true)->name('*.php')->exclude('test')->exclude('features')->in($this->directory . '/vendor/'); foreach ($finder as $file) { $this->addFile($phar, $file); } $this->addRefactorBin($phar); // Stubs $phar->setStub($this->getStub()); $phar->stopBuffering(); unset($phar); }
/** * @inheritDoc */ public function isSuccessful() { if ($this->symfonyProcess->isSuccessful()) { echo "[33m{$this->job->jobName()}: [36mHas finished without errors.\n"; } return $this->symfonyProcess->isSuccessful(); }
/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $vendorDir = sprintf('%s/../vendor', $this->rootDir); $codeSnifferDir = sprintf('%s/squizlabs/php_codesniffer', $vendorDir); if (false === file_exists($codeSnifferDir)) { $output->writeln('<error>Could not find squizlabs/php_codesniffer. Is it installed?</error>'); } $command = 'git clone git@github.com:florianeckerstorfer/Symfony2-coding-standard.git Symfony2'; $cwd = sprintf('%s/CodeSniffer/Standards', $codeSnifferDir); $update = false; if (true === file_exists(sprintf('%s/Symfony2', $cwd))) { $command = 'git pull origin master'; $cwd = sprintf('%s/Symfony2', $cwd); $update = true; } $process = new Process($command, $cwd); $process->run(function ($type, $buffer) use($input, $output) { if (true === $input->getOption('verbose')) { $output->writeln(sprintf('<comment>%s</comment>', $buffer)); } }); if (false === $process->isSuccessful()) { throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($command))); } if (true === $update) { $output->writeln('<info>Updated Symfony2 coding standard for PHP_CodeSniffer.</info>'); return; } $output->writeln('<info>Installed Symfony2 coding standard for PHP_CodeSniffer.</info>'); }
/** * Runs the given string as a command and returns the resulting output. * The CWD is set to the root project directory to simplify command paths. * * @param string $command * * @return string * * @throws ProcessFailedException in case the command execution is not successful */ private function runCommand($command, $workingDirectory = null) { $process = new Process($command); $process->setWorkingDirectory($workingDirectory ?: $this->rootDir); $process->mustRun(); return $process->getOutput(); }
public function createProcess($command) { //echo ": $command\n"; $process = new Process($command); $process->setWorkingDirectory($this->repoDirectory); return $process; }