public function testShouldSetArguments()
 {
     $pb = new ProcessBuilder(array('initial'));
     $pb->setArguments(array('second'));
     $proc = $pb->getProcess();
     $this->assertContains("second", $proc->getCommandLine());
 }
 /**
  * @throws InvalidCodingStandardException
  */
 public function run()
 {
     $this->outputHandler->setTitle('Checking code style with PHPCS');
     $this->output->write($this->outputHandler->getTitle());
     foreach ($this->files as $file) {
         if (!preg_match($this->neddle, $file)) {
             continue;
         }
         $oldPath = getcwd();
         $file = $oldPath . '/' . $file;
         chdir(__DIR__ . '/../../../../../../../');
         $processBuilder = new ProcessBuilder(array('php', 'bin/phpcs', '--standard=' . self::STANDARD . '', $file));
         /** @var Process $phpCs */
         $phpCs = $processBuilder->getProcess();
         $phpCs->run();
         if (false === $phpCs->isSuccessful()) {
             $this->outputHandler->setError($phpCs->getOutput());
             $this->output->writeln($this->outputHandler->getError());
             $this->output->writeln(BadJobLogo::paint());
             throw new InvalidCodingStandardException();
         }
         chdir($oldPath);
     }
     $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
 }
 /**
  * @param string $file
  *
  * @return Process
  */
 private function execute($file)
 {
     $processBuilder = new ProcessBuilder(['php', '-l', $file]);
     $process = $processBuilder->getProcess();
     $process->run();
     return $process;
 }
 public function filterDump(AssetInterface $asset)
 {
     $pb = new ProcessBuilder(array($this->pngoutBin));
     if (null !== $this->color) {
         $pb->add('-c' . $this->color);
     }
     if (null !== $this->filter) {
         $pb->add('-f' . $this->filter);
     }
     if (null !== $this->strategy) {
         $pb->add('-s' . $this->strategy);
     }
     if (null !== $this->blockSplitThreshold) {
         $pb->add('-b' . $this->blockSplitThreshold);
     }
     $pb->add($input = tempnam(sys_get_temp_dir(), 'assetic_pngout'));
     file_put_contents($input, $asset->getContent());
     $output = tempnam(sys_get_temp_dir(), 'assetic_pngout');
     unlink($output);
     $pb->add($output .= '.png');
     $proc = $pb->getProcess();
     $code = $proc->run();
     if (0 < $code) {
         unlink($input);
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent(file_get_contents($output));
     unlink($input);
     unlink($output);
 }
Beispiel #5
0
 /**
  * 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);
 }
 /**
  * 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";
 }
Beispiel #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Direct access to the Container.
     /** @var Kengrabber $kg */
     $kg = $this->getApplication()->getContainer();
     $output->writeln("Build everything...");
     $kg['monolog']->addDebug("Build everything...");
     $commands = array("videolist:grab", "videolist:download", "cleanup", "verify", "render");
     foreach ($commands as $command) {
         $builder = new ProcessBuilder(array("php", $_SERVER["SCRIPT_FILENAME"], $command));
         if ($kg['debug'] === true) {
             $builder->add("--debug");
         }
         $process = $builder->getProcess();
         $process->setTimeout(0);
         $process->run(function ($type, $buffer) use($kg, $output) {
             if (Process::ERR === $type) {
                 $output->write("<error>{$buffer}</error>");
             } else {
                 $output->write($buffer);
             }
         });
     }
     $output->writeln("<info>Finished building...</info>");
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $database = $input->getArgument('database');
     $file = $input->getOption('file');
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $databaseConnection = $this->resolveConnection($io, $database);
     if (!$file) {
         $io->error($this->trans('commands.database.restore.messages.no-file'));
         return;
     }
     if ($databaseConnection['driver'] == 'mysql') {
         $command = sprintf('mysql --user=%s --password=%s --host=%s --port=%s %s < %s', $databaseConnection['username'], $databaseConnection['password'], $databaseConnection['host'], $databaseConnection['port'], $databaseConnection['database'], $file);
     } elseif ($databaseConnection['driver'] == 'pgsql') {
         $command = sprintf('PGPASSWORD="******" psql -w -U %s -h %s -p %s -d %s -f %s', $databaseConnection['password'], $databaseConnection['username'], $databaseConnection['host'], $databaseConnection['port'], $databaseConnection['database'], $file);
     }
     if ($learning) {
         $io->commentBlock($command);
     }
     $processBuilder = new ProcessBuilder(['-v']);
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->getDrupalHelper()->getRoot());
     $process->setTty('true');
     $process->setCommandLine($command);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $io->success(sprintf('%s %s', $this->trans('commands.database.restore.messages.success'), $file));
 }
 protected function runCommand($cmd)
 {
     $builder = new ProcessBuilder($cmd);
     $process = $builder->getProcess();
     $process->run();
     return $process->getOutput();
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $address = $this->validatePort($input->getArgument('address'));
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         $io->error($this->trans('commands.server.errors.binary'));
         return;
     }
     $router = $this->getRouterPath();
     $cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
     if ($learning) {
         $io->commentBlock($cli);
     }
     $io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
     $processBuilder = new ProcessBuilder(explode(' ', $cli));
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->appRoot);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty('true');
     } else {
         $process->setTimeout(null);
     }
     $process->run();
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }
 /**
  * @param ImageSavedEvent $event
  */
 public function onPngImageSaved(ImageSavedEvent $event)
 {
     if ($event->getImage()->mime() == "image/png" && $this->pngquantPath != "") {
         $builder = new ProcessBuilder(array($this->pngquantPath, '-f', '--speed', '1', '-o', $event->getImageFile()->getPathname(), $event->getImageFile()->getPathname()));
         $builder->getProcess()->run();
     }
 }
 public function run()
 {
     $this->outputHandler->setTitle(sprintf('Checking json code with %s', strtoupper('jsonlint')));
     $this->output->write($this->outputHandler->getTitle());
     $errors = [];
     foreach ($this->files as $file) {
         if (!preg_match($this->needle, $file)) {
             continue;
         }
         $processBuilder = new ProcessBuilder(array('php', 'bin/jsonlint', $file));
         $process = $processBuilder->getProcess();
         $process->run();
         if (false === $process->isSuccessful()) {
             $errors[] = $process->getOutput();
         }
     }
     $errors = array_filter($errors, function ($var) {
         return !is_null($var);
     });
     if ($errors) {
         $this->output->writeln(BadJobLogo::paint());
         throw new JsonLintViolationsException(implode('', $errors));
     }
     $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
 }
Beispiel #13
0
 /**
  * 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();
 }
 /**
  * @param BinaryInterface $binary
  *
  * @throws ProcessFailedException
  *
  * @return BinaryInterface
  *
  * @see      Implementation taken from Assetic\Filter\optipngFilter
  */
 public function process(BinaryInterface $binary)
 {
     $type = strtolower($binary->getMimeType());
     if (!in_array($type, array('image/png'))) {
         return $binary;
     }
     if (false === ($input = tempnam(sys_get_temp_dir(), 'imagine_optipng'))) {
         throw new \RuntimeException(sprintf('Temp file can not be created in "%s".', sys_get_temp_dir()));
     }
     $pb = new ProcessBuilder(array($this->optipngBin));
     $pb->add('--o7');
     $pb->add($input);
     if ($binary instanceof FileBinaryInterface) {
         copy($binary->getPath(), $input);
     } else {
         file_put_contents($input, $binary->getContent());
     }
     $proc = $pb->getProcess();
     $proc->run();
     if (false !== strpos($proc->getOutput(), 'ERROR') || 0 !== $proc->getExitCode()) {
         unlink($input);
         throw new ProcessFailedException($proc);
     }
     $result = new Binary(file_get_contents($input), $binary->getMimeType(), $binary->getFormat());
     unlink($input);
     return $result;
 }
Beispiel #15
0
 /**
  * Creates the given process
  *
  * @throws \Exception
  */
 private function startProcess(OutputInterface $output)
 {
     $arguments = $this->resolveProcessArgs();
     $name = sha1(serialize($arguments));
     if ($this->background->hasProcess($name)) {
         throw new \RuntimeException("Service is already running.");
     }
     $builder = new ProcessBuilder($arguments);
     if ($this->hasParameter('cwd')) {
         $builder->setWorkingDirectory($this->getParameter('cwd'));
     }
     $process = $builder->getProcess();
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $output->writeln($process->getCommandLine());
     }
     if ($this->hasParameter('output')) {
         $append = $this->hasParameter('append') && $this->getParameter('append') ? 'a' : 'w';
         $stream = fopen($this->getParameter('output'), $append);
         $output = new StreamOutput($stream, StreamOutput::VERBOSITY_NORMAL, true);
     }
     $process->start(function ($type, $buffer) use($output) {
         $output->write($buffer);
     });
     $this->background->addProcess($name, $process);
     if (!in_array($process->getExitCode(), $this->getParameter('successCodes'))) {
         throw new TaskRuntimeException($this->getName(), $process->getErrorOutput());
     }
 }
 /**
  * @param string $file
  * @param string $standard
  *
  * @return Process
  */
 private function execute($file, $standard)
 {
     $processBuilder = new ProcessBuilder(['php', $this->toolPathFinder->find('phpcs'), '--standard=' . $standard, $file]);
     $process = $processBuilder->getProcess();
     $process->run();
     return $process;
 }
 /**
  * @throws PhpCsFixerException
  */
 public function run()
 {
     foreach ($this->levels as $level => $value) {
         if (true === $value) {
             $this->outputHandler->setTitle('Checking ' . strtoupper($level) . ' code style with PHP-CS-FIXER');
             $this->output->write($this->outputHandler->getTitle());
             $errors = array();
             foreach ($this->files as $file) {
                 $srcFile = preg_match($this->filesToAnalyze, $file);
                 if (!$srcFile) {
                     continue;
                 }
                 $processBuilder = new ProcessBuilder(array('php', 'bin/php-cs-fixer', '--dry-run', 'fix', $file, '--level=' . $level));
                 $phpCsFixer = $processBuilder->getProcess();
                 $phpCsFixer->run();
                 if (false === $phpCsFixer->isSuccessful()) {
                     $errors[] = $phpCsFixer->getOutput();
                 }
             }
             if ($errors) {
                 $this->output->writeln(BadJobLogo::paint());
                 throw new PhpCsFixerException(implode('', $errors));
             }
             $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
         }
     }
 }
Beispiel #18
0
 /**
  * {@inheritdoc}
  */
 public function analyze($analyzedFileName = null)
 {
     $result = new \SCQAT\Result();
     $processBuilder = new ProcessBuilder(array($this->language->configuration["command"], $this->context->vendorDirectory . "bin/php-cs-fixer", "--level=psr2", "--dry-run", "--verbose", "fix", $analyzedFileName));
     $process = $processBuilder->getProcess();
     $process->run();
     if (!$process->isSuccessful()) {
         $result->isSuccess = false;
         $result->value = "KO";
         $description = "";
         $outputLines = explode("\n", trim($process->getOutput()));
         foreach ($outputLines as $line) {
             // remove all output useless lines
             if (strpos($line, $analyzedFileName) !== false) {
                 // remove filename and useles chars to just keep fixers violated
                 $description = trim(substr($line, strpos($line, $analyzedFileName) + strlen($analyzedFileName)), " ()");
             }
         }
         $result->description = "Triggered fixers : " . $description;
     } else {
         $result->isSuccess = true;
         $result->value = "OK";
     }
     return $result;
 }
Beispiel #19
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $address = $input->getArgument('address');
     if (false === strpos($address, ':')) {
         $address = sprintf('%s:8088', $address);
     }
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         $io->error($this->trans('commands.server.errors.binary'));
         return;
     }
     $router = $this->getRouterPath();
     $cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
     if ($learning) {
         $io->commentBlock($cli);
     }
     $io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
     $processBuilder = new ProcessBuilder(explode(' ', $cli));
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->get('site')->getRoot());
     $process->setTty('true');
     $process->run();
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }
 /**
  * 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;
 }
 /**
  * Run the asset through UglifyJs
  *
  * @see Assetic\Filter\FilterInterface::filterDump()
  */
 public function filterDump(AssetInterface $asset)
 {
     $executables = array();
     if ($this->nodeJsPath !== null) {
         $executables[] = $this->nodeJsPath;
     }
     $executables[] = $this->uglifyCssPath;
     $pb = new ProcessBuilder($executables);
     if ($this->expandVars) {
         $pb->add('--expand-vars');
     }
     if ($this->uglyComments) {
         $pb->add('--ugly-comments');
     }
     if ($this->cuteComments) {
         $pb->add('--cute-comments');
     }
     // input and output files
     $input = tempnam(sys_get_temp_dir(), 'input');
     file_put_contents($input, $asset->getContent());
     $pb->add($input);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($input);
     if (127 === $code) {
         throw new \RuntimeException('Path to node executable could not be resolved.');
     }
     if (0 < $code) {
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     $asset->setContent($proc->getOutput());
 }
 /**
  * @throws PHPMDViolationsException
  */
 public function run()
 {
     $this->outputHandler->setTitle('Checking code mess with PHPMD');
     $this->output->write($this->outputHandler->getTitle());
     $errors = [];
     foreach ($this->files as $file) {
         if (!preg_match($this->needle, $file)) {
             continue;
         }
         $processBuilder = new ProcessBuilder(array('php', 'bin/phpmd', $file, 'text', 'PmdRules.xml', '--minimumpriority', 1));
         $process = $processBuilder->getProcess();
         $process->run();
         if (false === $process->isSuccessful()) {
             $errors[] = $process->getOutput();
         }
     }
     $errors = array_filter($errors, function ($var) {
         return !is_null($var);
     });
     if ($errors) {
         $this->output->writeln(BadJobLogo::paint());
         throw new PHPMDViolationsException(implode('', $errors));
     }
     $this->output->writeln($this->outputHandler->getSuccessfulStepMessage());
 }
Beispiel #23
0
 /**
  * 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;
 }
    /**
     * {@inheritDoc}
     */
    public function format($string)
    {
        static $format = <<<EOF
package main

import "fmt"
import "github.com/russross/blackfriday"

func main() {
    input := []byte("%s")
    output := blackfriday.MarkdownCommon(input)
    fmt.Printf(string(output[:]))
}
EOF;
        $input = tempnam(sys_get_temp_dir(), 'fabricius_blackfriday');
        $input .= '.go';
        file_put_contents($input, sprintf($format, addcslashes($string, "\n\"")));
        $pb = new ProcessBuilder(array($this->goBin, 'run', $input));
        $proc = $pb->getProcess();
        $code = $proc->run();
        unlink($input);
        if (0 !== $code) {
            $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);
            }
            throw new RuntimeException($message);
        }
        return $proc->getOutput();
    }
 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);
     });
 }
 /**
  * @inheritdoc
  *
  * @throws \Exception
  *   If $mustRun is enabled and the command fails.
  */
 public function execute(array $args, $dir = null, $mustRun = false, $quiet = true)
 {
     $builder = new ProcessBuilder($args);
     $process = $builder->getProcess();
     // The default timeout is 1 minute. Increase it to 1 hour.
     $process->setTimeout(3600);
     if ($dir) {
         $process->setWorkingDirectory($dir);
     }
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->writeln("Running command: <info>" . $process->getCommandLine() . "</info>");
     }
     try {
         $process->mustRun($quiet ? null : function ($type, $buffer) {
             $indent = '  ';
             $this->output->writeln($indent . str_replace("\n", "\n{$indent}", trim($buffer)));
         });
     } catch (ProcessFailedException $e) {
         if (!$mustRun) {
             return false;
         }
         // 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;
 }
Beispiel #27
0
 /**
  * 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();
 }
Beispiel #28
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $database = $input->getArgument('database');
     $file = $input->getOption('file');
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $databaseConnection = $this->resolveConnection($io, $database);
     if (!$file) {
         $date = new \DateTime();
         $file = sprintf('%s/%s-%s.sql', $this->getSite()->getSiteRoot(), $databaseConnection['database'], $date->format('Y-m-d-h-i-s'));
     }
     $command = sprintf('mysqldump --user=%s --password=%s --host=%s --port=%s %s > %s', $databaseConnection['username'], $databaseConnection['password'], $databaseConnection['host'], $databaseConnection['port'], $databaseConnection['database'], $file);
     if ($learning) {
         $io->commentBlock($command);
     }
     $processBuilder = new ProcessBuilder(['–lock-all-tables']);
     $process = $processBuilder->getProcess();
     $process->setTty('true');
     $process->setCommandLine($command);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $io->success(sprintf('%s %s', $this->trans('commands.database.dump.messages.success'), $file));
 }
 /**
  * @param string $file
  *
  * @return Process
  */
 private function execute($file)
 {
     $processBuilder = new ProcessBuilder(['php', $this->toolPathFinder->find('jsonlint'), $file]);
     $process = $processBuilder->getProcess();
     $process->run();
     return $process;
 }
 /**
  * Checks if the render check commands returns "[OK]"
  */
 public function testRenderCheckOk()
 {
     $pb = new ProcessBuilder();
     $pb->setWorkingDirectory(realpath(__DIR__ . '\\..\\..\\..'))->setArguments(['php', 'bin/console', 'render:check']);
     $out = $pb->getProcess()->mustRun()->getOutput();
     $this->assertContains('[OK]', $out);
 }