Checks if the process ended successfully.
public isSuccessful ( ) : boolean | ||
return | boolean | true if the process ended successfully, false otherwise |
/** * @inheritDoc */ public function isSuccessful() { if ($this->symfonyProcess->isSuccessful()) { echo "[33m{$this->job->jobName()}: [36mHas finished without errors.\n"; } return $this->symfonyProcess->isSuccessful(); }
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']))); }
private function isSuccessful() { if (null === $this->isSuccessful) { $this->process->wait(); $this->isSuccessful = $this->process->isSuccessful(); } return $this->isSuccessful; }
/** * @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()); } }
/** * @param string $command * @return array */ protected function execucte($command) { $command = (string) $command; $process = new Process($command); $process->run(); if (!$process->isSuccessful()) { $this->failed++; $this->success = false; } else { $this->succeeded++; } return array('success' => $process->isSuccessful(), 'output' => $process->getOutput()); }
public function execute() { $logger = $this->getRunConfig()->getLogger(); $this->process = new Process($this->command); $logger->info('Start command:' . $this->command); $this->process->setTimeout($this->timeout); $this->process->setWorkingDirectory($this->getRunConfig()->getRepositoryDirectory()); $this->process->run(); $output = trim($this->process->getOutput()); $logger->info($output); if (!$this->process->isSuccessful()) { $logger->emergency($this->process->getErrorOutput()); throw new \RuntimeException('Command not successful:' . $this->command); } }
/** * {@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()); }
public static function dump() { $ret = ''; if (!isset(\Kwf_Setup::$configClass)) { throw new Exception("Run Kwf_Setup::setUp() before using this method"); } $dbConfig = \Kwf_Registry::get('dao')->getDbConfig(); $cacheTables = \Kwf_Util_ClearCache::getInstance()->getDbCacheTables(); $dumpCmd = "mysqldump"; $dumpCmd .= " --host=" . escapeshellarg($dbConfig['host']); $dumpCmd .= " --user="******" --password="******" --ignore-table=" . escapeshellarg($dbConfig['dbname'] . '.' . $t); } $cmd .= " {$dbConfig['dbname']}"; $process = new Process($cmd); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $ret .= $process->getOutput(); foreach ($cacheTables as $t) { $cmd = $dumpCmd; $cmd .= " --no-data " . escapeshellarg($dbConfig['dbname']) . " " . escapeshellarg($t); $process = new Process($cmd); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $ret .= $process->getOutput(); } return $ret; }
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; } }
/** * 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) { // Useful for working on pubstack-shell. if ($input->getOption('clean')) { // Since it'd be easy for some shell script to change the PUBSTACK_PATH // variable, confirm this every time. $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('Are you sure you want to delete ' . $_ENV['PUBSTACK_PATH'] . '? This operation cannot be undone.', false); if (!$helper->ask($input, $output, $question)) { return; } // Remove the existing pubstack directory. $process = new Process('rm -rf ' . $_ENV['PUBSTACK_PATH']); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } } // Only complain if --clean isn't specified. if (is_dir($_ENV['PUBSTACK_PATH']) && !$input->getOption('clean')) { throw new \RuntimeException("Pubstack has already been initialized."); } $output->writeln('<comment>Cloning pubstack...</comment>'); $process = new Process('git clone ' . $_ENV['PUBSTACK_REPO'] . ' ' . $_ENV['PUBSTACK_PATH']); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $output->writeln('<info>Done!</info>'); $output->writeln('<comment>Now run "pubstack configure"</comment>'); }
/** * @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()])]); }
/** * Creates a Terra instance. * * @return Terra * A configured Flo instance. */ private function createTerra() { $terra = new Terra(); // Get config from env variables or files. if ($config_env = getenv('TERRA')) { $config_env = Yaml::parse($config_env); $config = new Config($config_env); } else { $fs = new Filesystem(); $user_config = array(); $user_config_file = getenv('HOME') . '/.terra/terra'; if ($fs->exists($user_config_file)) { $user_config = Yaml::parse($user_config_file); } $project_config = array(); $process = new Process('git rev-parse --show-toplevel'); $process->run(); if ($process->isSuccessful()) { $project_config_file = trim($process->getOutput()) . '/terra.yml'; if ($fs->exists($project_config_file)) { $project_config = Yaml::parse($project_config_file); } } $config = new Config($user_config, $project_config); } $terra->setConfig($config); return $terra; }
/** * Perform the database backup. * * @return bool Whether the backup completed successfully or not. */ public function backup() { if (!$this->get_mysqldump_executable_path()) { return false; } // Grab the database connections args $args = $this->get_mysql_connection_args(); // Allow lock-tables to be overridden if (defined('HMBKP_MYSQLDUMP_SINGLE_TRANSACTION') && HMBKP_MYSQLDUMP_SINGLE_TRANSACTION) { $args[] = '--single-transaction'; } // Make sure binary data is exported properly $args[] = '--hex-blob'; // The file we're saving too $args[] = '-r ' . escapeshellarg($this->get_backup_filepath()); // The database we're dumping $args[] = escapeshellarg($this->get_name()); $process = new Process($this->get_mysqldump_executable_path() . ' ' . implode(' ', $args)); $process->setTimeout(HOUR_IN_SECONDS); try { $process->run(); } catch (\Exception $e) { $this->error(__CLASS__, $e->getMessage()); } if (!$process->isSuccessful()) { $this->error(__CLASS__, $process->getErrorOutput()); } return $this->verify_backup(); }
public function dump() { if ($this->user != '' && $this->pass != "") { $this->auth = sprintf("--host='%s' --port='%d' --username='******' --password='******'", $this->host, $this->port, $this->user, $this->pass); } else { if ($this->user != '' && $this->pass == "") { $this->auth = sprintf("--host='%s' --port='%d' --username='******'", $this->host, $this->port, $this->user); } else { $this->auth = sprintf("--host='%s' --port='%d'", $this->host, $this->port); } } if ($this->database != '') { $command = sprintf('mongodump %s -db %s -out %s', $this->auth, $this->database, $this->backupPath . $this->backupFilename); } else { $command = sprintf('mongodump %s -out %s', $this->auth, $this->backupPath . $this->backupFilename); } $process = new Process($command); $process->setTimeout(null); $process->run(); if (!$process->isSuccessful()) { $this->result['status'] = 0; $this->result['message'] = $process->getErrorOutput(); } else { $this->result['status'] = 1; $this->result['message'] = "Successful backup of Mongodb in local file: " . $this->backupPath . $this->backupFilename; $this->result['backup_path'] = $this->backupPath; $this->result['backup_filename'] = $this->backupFilename; $this->result['backup_name'] = $this->backupName; $this->result['full_path'] = $this->backupPath . $this->backupFilename; $this->result['host'] = $this->host; } return $this->result; }
public static function kanjiToRomaji($input, &$returnCode = '') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { return $input; } $japanese = "/([\\x{3000}-\\x{303f}\\x{3040}-\\x{309f}\\x{30a0}-\\x{30ff}\\x{ff00}-\\x{ff9f}\\x{4e00}-\\x{9faf}\\x{3400}-\\x{4dbf}])+/iu"; preg_match_all($japanese, $input, $matches); if (empty($matches[0]) || !is_array($matches[0])) { return $input; } $placeholders = ['in' => $matches[0], 'out' => []]; $uniq = uniqid(); $kakasi = 'kakasi -i euc -w | kakasi -i euc -Ha -Ka -Ja -Ea -ka'; $process = new Process($kakasi); $words = implode($uniq, $placeholders['in']); $convertedWords = mb_convert_encoding($words, 'eucjp', 'utf-8'); $process->setInput($convertedWords); $process->run(); if (!$process->isSuccessful()) { return IRCHelper::colorText('ERROR', IRCHelper::COLOR_RED) . ': can\'t run kakasi'; } $romaji = $process->getOutput(); $placeholders['out'] = explode($uniq, $romaji); $input = str_replace($placeholders['in'], $placeholders['out'], $input); return $input; }
/** * Creates a Flo instance. * * @return Flo * A configured Flo instance. */ private function createFlo() { $flo = new Flo(); // Get config from env variables or files. if ($config_env = getenv('FLO')) { $config_env = Yaml::parse($config_env); $config = new Config($config_env); } else { $fs = new Filesystem(); $user_config = array(); $user_config_file = getenv("HOME") . '/.config/flo'; if ($fs->exists($user_config_file)) { $user_config = Yaml::parse($user_config_file); } $project_config = array(); $process = new Process('git rev-parse --show-toplevel'); $process->run(); if ($process->isSuccessful()) { $project_config_file = trim($process->getOutput()) . '/flo.yml'; if ($fs->exists($project_config_file)) { $project_config = Yaml::parse($project_config_file); } } $config = new Config($user_config, $project_config); } $flo->setConfig($config); return $flo; }
/** * @param InputInterface $input * @param OutputInterface $output * @return bool|null * TRUE is patch applies, FALSE if patch does not, and NULL if something * else occurs. */ protected function checkPatch(InputInterface $input, OutputInterface $output) { $issue = $this->getIssue($input->getArgument('url')); if ($issue) { $patch = $this->choosePatch($issue, $input, $output); if ($patch) { $patch = $this->getPatch($patch); $this->verbose($output, "Checking {$patch} applies"); $repo_dir = $this->getConfig()->getDrupalRepoDir(); $this->ensureLatestRepo($repo_dir); $process = new Process("git apply --check {$patch}"); $process->setWorkingDirectory($repo_dir); $process->run(); if ($process->isSuccessful()) { $this->output = $process->getOutput(); return TRUE; } else { $this->output = $process->getErrorOutput(); return FALSE; } } } // There is no patch, or there is a problem getting the issue. return NULL; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $configCommand = $this->getApplication()->find('oro:requirejs:generate-config'); $configCommand->run(new ArrayInput(['command' => 'oro:requirejs:generate-config']), $output); $webRoot = $this->getContainer()->getParameter('oro_require_js.web_root'); $config = $this->getContainer()->getParameter('oro_require_js'); $configProvider = $this->getContainer()->get('oro_requirejs_config_provider'); $output->writeln('Generating require.js build config'); $buildConfigContent = $configProvider->generateBuildConfig(self::MAIN_CONFIG_FILE_NAME); $buildConfigContent = '(' . json_encode($buildConfigContent) . ')'; $buildConfigFilePath = $webRoot . DIRECTORY_SEPARATOR . self::BUILD_CONFIG_FILE_NAME; if (false === @file_put_contents($buildConfigFilePath, $buildConfigContent)) { throw new \RuntimeException('Unable to write file ' . $buildConfigFilePath); } if (isset($config['js_engine']) && $config['js_engine']) { $output->writeln('Running code optimizer'); $command = $config['js_engine'] . ' ' . self::OPTIMIZER_FILE_PATH . ' -o ' . basename($buildConfigFilePath) . ' 1>&2'; $process = new Process($command, $webRoot); $process->setTimeout($config['building_timeout']); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } $output->writeln('Cleaning up'); if (false === @unlink($buildConfigFilePath)) { throw new \RuntimeException('Unable to remove file ' . $buildConfigFilePath); } $output->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), realpath($webRoot . DIRECTORY_SEPARATOR . $config['build_path']))); } }
/** * Execute an SVN command * * @param string $cmd Command name (update, info, etc) * @param array $arguments An array of argument (path, url, etc) * @param array $options An array of options * @param string $path Working directory * @param integer $timeout Timeout * * @return string * @throws \Exception */ public static function exec($cmd, $arguments = array(), $options = array(), $path = null, $output = false, $timeout = null) { if (!is_array($arguments)) { $arguments = array($arguments); } $arguments = array_map("escapeshellarg", $arguments); $new_options = array(); foreach ($options as $key => $value) { $new_options[] = preg_replace("/[^-\\w]/", "", $key); if ($value !== true) { $new_options[] = escapeshellarg($value); } } $cmdline = "svn {$cmd} " . implode(" ", $arguments) . " " . implode(" ", $new_options); $process = new Process($cmdline, $path, null, null, $timeout); $process->run(); if (!$process->isSuccessful()) { throw new RuntimeException($process->getErrorOutput()); } if ($output) { echo $process->getOutput(); return null; } return $process->getOutput(); }
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>'); }
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()); } }
public function prepareLibrary($library_name, $images) { $dir = $this->library_path . '/' . $library_name; $metapixel_table = $dir . '/tables.mxt'; if (is_file($metapixel_table) && filesize($metapixel_table) <= 0) { unlink($metapixel_table); } if (!is_file($metapixel_table)) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0755, true) && !is_dir($dir)) { throw new \RuntimeException(sprintf("Unable to create the metapixel library directory (%s).", $dir)); } } elseif (!is_writable($dir)) { throw new \RuntimeException(sprintf("Unable to write in the metapixel library directory (%s).", $dir)); } $process = new Process("metapixel --new-library '{$dir}'"); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } foreach ($images as $image) { $file = $image['file_path']; $process = new Process("metapixel --width=75 --height=75 --prepare '{$dir}' '{$file}'"); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } } } }
/** * {@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>'); }
protected function execute(InputInterface $input, OutputInterface $output) { $ctx = array(); $ctx['type'] = 'module'; $ctx['basedir'] = rtrim(getcwd(), '/'); $basedir = new Path($ctx['basedir']); $info = new Info($basedir->string('info.xml')); $info->load($ctx); $attrs = $info->get()->attributes(); if ($attrs['type'] != 'module') { $output->writeln('<error>Wrong extension type: ' . $attrs['type'] . '</error>'); return; } $ctx['zipFile'] = $basedir->string('build', $ctx['fullName'] . '.zip'); $cmdArgs = array('-r', $ctx['zipFile'], $ctx['fullName'], '--exclude', 'build/*', '*~', '*.bak'); $cmd = 'zip ' . implode(' ', array_map('escapeshellarg', $cmdArgs)); chdir($basedir->string('..')); $process = new Process($cmd); $process->run(function ($type, $buffer) use($output) { $output->writeln($buffer); }); if (!$process->isSuccessful()) { throw new \RuntimeException('Failed to create zip'); } print $process->getOutput(); }
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()); } }
public function dump() { if ($this->pass != "") { $exportPasswordCommand = 'PGPASSWORD="******"'; $exportPasswordProcess = new Process($exportPasswordCommand); $exportPasswordProcess->run(); } $this->auth = sprintf("-U '%s' -h '%s' -p '%s'", $this->user, $this->host, $this->port); if ($this->database == "") { $command = sprintf('pg_dumpall %s > %s', $this->auth, $this->backupPath . $this->backupFilename); } else { $command = sprintf('pg_dump %s %s > %s', $this->auth, $this->database, $this->backupPath . $this->backupFilename); } $process = new Process($command); $process->setTimeout(null); $process->run(); if (!$process->isSuccessful()) { $this->result['status'] = 0; $this->result['message'] = $process->getErrorOutput(); } else { echo $process->getOutput(); $this->result['status'] = 1; $this->result['message'] = "Successful backup of PostgreSQL in local file: " . $this->backupPath . $this->backupFilename; $this->result['backup_path'] = $this->backupPath; $this->result['backup_filename'] = $this->backupFilename; $this->result['backup_name'] = $this->backupName; $this->result['full_path'] = $this->backupPath . $this->backupFilename; $this->result['host'] = $this->host; } return $this->result; }
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; }
protected function execute(InputInterface $input, OutputInterface $output) { /* @var $kernel KernelInterface */ $kernel = $this->getContainer()->get("kernel"); $node = $this->getContainer()->getParameter("assetic.node.bin"); $https = $this->getContainer()->getParameter("assetic.nodesass.compiler.https"); $port = $this->getContainer()->getParameter("assetic.nodesass.compiler.port"); $portHttp = $this->getContainer()->getParameter("assetic.nodesass.compiler.portHttps"); $sslKey = $this->getContainer()->getParameter("assetic.nodesass.compiler.sslKey"); $sslCert = $this->getContainer()->getParameter("assetic.nodesass.compiler.sslCert"); $node = $this->getContainer()->getParameter("assetic.node.bin"); $outputStyle = $this->getContainer()->getParameter("assetic.filter.nodesass.style"); $http_path = $this->getContainer()->getParameter("assetic.filter.nodesass.http_path"); $fonts_dir = $this->getContainer()->getParameter("assetic.filter.nodesass.fonts_dir"); $images_dir = $this->getContainer()->getParameter("assetic.filter.nodesass.images_dir"); $bundlePath = realpath($kernel->getBundle("GollumSFLibSassBundle")->getPath()); $rootPath = realpath($kernel->getRootDir()); $compile = $bundlePath . "/Resources/nodejs/assets_compiler_httpserver.js"; $nodeSassPath = realpath(dirname($this->getContainer()->getParameter("assetic.nodesass.bin")) . "/.."); $includePaths = ""; foreach ($this->getContainer()->getParameter("assetic.filter.nodesass.load_paths") as $includePath) { $includePaths .= " --includePaths {$includePath}"; } $cmd = "{$node} {$compile} " . ($port ? "--port {$port} " : "") . ($https != AsseticLoader::HTTPS_MODE_NONE && $portHttp ? "--portHttps {$portHttp} " : "") . ($https != AsseticLoader::HTTPS_MODE_NONE ? "--https 1 " : "") . "\n\t\t\t--nodeSassPath {$nodeSassPath} \n\t\t\t--rootPath {$rootPath} \n\t\t\t--bundlePath {$bundlePath} " . ($outputStyle ? "--outputStyle {$outputStyle}" : "") . " \n\t\t\t--http_path {$http_path} \n\t\t\t--fonts_dir {$fonts_dir} \n\t\t\t--images_dir {$images_dir}{$includePaths} " . ($https != AsseticLoader::HTTPS_MODE_NONE && $sslKey ? "--sslKey {$sslKey} " : "") . ($https != AsseticLoader::HTTPS_MODE_NONE && $sslCert ? "--sslCert {$sslCert} " : "") . "\n\t\t"; $cmd = str_replace(["\n", "\t"], " ", $cmd); echo "Start compilation server: {$cmd}\n"; $process = new Process($cmd, null, null, null, 0); $process->run(function ($type, $buffer) { echo $buffer; }); if (!$process->isSuccessful()) { throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd))); } }
/** * Check if linting process was successful and raise LintingException if not. * * @param Process $process */ private function checkProcess(Process $process) { if (!$process->isSuccessful()) { // on some systems stderr is used, but on others, it's not throw new LintingException($process->getErrorOutput() ?: $process->getOutput(), $process->getExitCode()); } }
/** * Execute the console command. * * @return mixed */ public function handle() { if (\App::environment() === 'production') { $this->error('This feature is not available on this server'); } $command = base_path('vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'apigen') . ' generate -s app -d phpdoc'; $this->comment($command); $process = new Process($command); $process->run(function ($type, $buffer) { $buffer = trim($buffer); if (empty($buffer)) { return; } if ('err' === $type) { $this->error($buffer); } else { $this->comment($buffer); } }); if (!$process->isSuccessful()) { $this->error($process->getErrorOutput()); return; } $this->comment('Documentation generated in folder ' . base_path('phpdoc')); $this->comment(\PHP_Timer::resourceUsage()); }