當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProgressBar::setRedrawFrequency方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Helper\ProgressBar::setRedrawFrequency方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProgressBar::setRedrawFrequency方法的具體用法?PHP ProgressBar::setRedrawFrequency怎麽用?PHP ProgressBar::setRedrawFrequency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Helper\ProgressBar的用法示例。


在下文中一共展示了ProgressBar::setRedrawFrequency方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepare

 /**
  * {@inheritdoc}
  */
 public function prepare()
 {
     $this->progress = new ProgressBar($this->output, $this->reader->count());
     $this->progress->setFormat($this->verbosity);
     $this->progress->setRedrawFrequency($this->redrawFrequency);
     $this->progress->start();
 }
開發者ID:megamanhxh,項目名稱:data-import,代碼行數:10,代碼來源:ConsoleProgressWriter.php

示例2: progressAdvance

 /**
  * @phpcsSuppress SlevomatCodingStandard.Typehints.TypeHintDeclaration.missingParameterTypeHint
  * @param int $step
  */
 public function progressAdvance($step = 1)
 {
     if ($this->output->isDecorated() && $step > 0) {
         $stepTime = (time() - $this->progressBar->getStartTime()) / $step;
         if ($stepTime > 0 && $stepTime < 1) {
             $this->progressBar->setRedrawFrequency(1 / $stepTime);
         } else {
             $this->progressBar->setRedrawFrequency(1);
         }
     }
     $this->progressBar->setProgress($this->progressBar->getProgress() + $step);
 }
開發者ID:phpstan,項目名稱:phpstan,代碼行數:16,代碼來源:ErrorsConsoleStyle.php

示例3: exportIndex

 /**
  * Exports es index to provided file.
  *
  * @param Manager         $manager
  * @param string          $filename
  * @param array           $types
  * @param int             $chunkSize
  * @param OutputInterface $output
  */
 public function exportIndex(Manager $manager, $filename, $types, $chunkSize, OutputInterface $output)
 {
     $typesMapping = $manager->getMetadataCollector()->getMappings($manager->getConfig()['mappings']);
     $typesToExport = [];
     if ($types) {
         foreach ($types as $type) {
             if (!array_key_exists($type, $typesMapping)) {
                 throw new \InvalidArgumentException(sprintf('Type "%s" does not exist.', $type));
             }
             $typesToExport[] = $typesMapping[$type]['bundle'] . ':' . $typesMapping[$type]['class'];
         }
     } else {
         foreach ($typesMapping as $type => $typeConfig) {
             $typesToExport[] = $typeConfig['bundle'] . ':' . $typeConfig['class'];
         }
     }
     $repo = $manager->getRepository($typesToExport);
     $results = $this->getResults($repo, $chunkSize);
     $progress = new ProgressBar($output, $results->count());
     $progress->setRedrawFrequency(100);
     $progress->start();
     $metadata = ['count' => $results->count(), 'date' => date(\DateTime::ISO8601)];
     $writer = $this->getWriter($this->getFilePath($filename), $metadata);
     foreach ($results as $data) {
         $doc = array_intersect_key($data, array_flip(['_id', '_type', '_source', 'fields']));
         $writer->push($doc);
         $progress->advance();
     }
     $writer->finalize();
     $progress->finish();
     $output->writeln('');
 }
開發者ID:emgiezet,項目名稱:ElasticsearchBundle,代碼行數:41,代碼來源:ExportService.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $indexName = $input->getOption('index');
     $batchSize = $input->getOption('batch_size');
     $indexManager = $this->getIndexManager($indexName);
     $totalDocuments = $indexManager->getTotalEntities();
     $iterations = $this->getIterations($totalDocuments, $batchSize);
     $output->writeln(sprintf('<info>Reindexing</info> "%s"', $indexName));
     $output->writeln(sprintf('<comment>Total documents:</comment> %s', $totalDocuments));
     $output->writeln(sprintf('<comment>Batch size:</comment> %s', $batchSize));
     $output->writeln(sprintf('<comment>Iterations:</comment> %s', $iterations));
     $progress = new ProgressBar($output, $totalDocuments);
     $progress->setFormat('verbose');
     $progress->setRedrawFrequency($batchSize);
     $progress->start();
     $indexManager->purgeIndex();
     for ($i = 0; $i < $iterations; $i++) {
         $criteria = new Criteria();
         $criteria->setMaxResults($batchSize);
         $criteria->setFirstResult($i * $batchSize);
         $collection = $indexManager->getEntitiesCollection($criteria);
         $collection->map(function (EntityInterface $entity) use($indexManager, $progress) {
             $indexManager->addEntity($entity);
             $progress->advance();
         });
     }
     $progress->finish();
     $output->writeln('');
     $output->writeln(sprintf('<info>Optimizing "%s"</info>', $indexName));
     $indexManager->optimizeIndex();
 }
開發者ID:wellcommerce,項目名稱:wellcommerce,代碼行數:31,代碼來源:ReindexCommand.php

示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ImportAddressService $importAddressService */
     $importAddressService = $this->getHelper('container')->getByType('StreetApi\\Services\\ImportAddressService');
     $cityId = $input->getArgument('cityId');
     $xmlFile = simplexml_load_file($importAddressService->getRootDir() . '/../adresy.xml');
     if (!$xmlFile) {
         $output->writeln(PHP_EOL . '<error>Missing source file!</error>');
         return 1;
     }
     try {
         $output->writeLn('<info>Start importing addresses</info>');
         $totalCount = $xmlFile->count();
         $output->writeln(PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL);
         $progressBar = new ProgressBar($output, $totalCount);
         $progressBar->setFormat('%message%' . PHP_EOL . '%bar% %percent:3s% %' . PHP_EOL . 'count: %current%/%max%' . PHP_EOL . 'time:  %elapsed:6s%/%estimated:-6s%' . PHP_EOL);
         $progressBar->setBarCharacter('<info>■</info>');
         $progressBar->setEmptyBarCharacter(' ');
         $progressBar->setProgressCharacter('');
         $progressBar->setRedrawFrequency(ceil($totalCount / 100));
         $progressBar->start();
         $importAddressService->import($xmlFile, $progressBar, $cityId);
         $output->writeLn(PHP_EOL . '<info>Importing addresses finished</info>');
         return 0;
     } catch (\Exception $e) {
         $output->writeLn('<error>' . $e->getMessage() . '</error>');
         return 1;
     }
 }
開發者ID:neogenia,項目名稱:mvcr-street-api,代碼行數:29,代碼來源:ImportAddressCommand.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $desde = (int) $input->getArgument('desde');
     $cantidad = 100;
     $progress = null;
     $importador = new ImportadorAgentes($this->getContainer(), $this->getContainer()->get('doctrine')->getManager());
     $importador->Inicializar();
     $progress = new ProgressBar($output, $importador->ObtenerCantidadTotal());
     $progress->setRedrawFrequency(1);
     $progress->setMessage('Importando agentes...');
     $progress->start();
     $ResultadoFinal = new ResultadoImportacion($importador);
     while (true) {
         $resultado = $importador->Importar($desde, $cantidad);
         $ResultadoFinal->AgregarContadoresLote($resultado);
         if (!$resultado->HayMasRegistros()) {
             break;
         }
         $desde += $cantidad;
         $progress->advance($cantidad);
     }
     $progress->finish();
     $output->writeln('');
     $output->writeln(' Se importaron   ' . $ResultadoFinal->RegistrosNuevos . ' registros nuevos.');
     $output->writeln(' Se actualizaron ' . $ResultadoFinal->RegistrosActualizados . ' registros.');
     $output->writeln(' Se ignoraron    ' . $ResultadoFinal->RegistrosIgnorados . ' registros.');
     $output->writeln('Importación finalizada, se procesaron ' . $ResultadoFinal->TotalRegistrosProcesados() . ' registros.');
 }
開發者ID:Drake86cnf,項目名稱:yacare,代碼行數:28,代碼來源:ImportarAgentesCommand.php

示例7: runProcess

 /**
  * 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>');
 }
開發者ID:nobox,項目名稱:nobox-laravel-installer,代碼行數:37,代碼來源:ProcessHelper.php

示例8: reindex

 private function reindex(string $locale, OutputInterface $output)
 {
     $totalEntities = $this->repository->getTotalCount();
     $iterations = $this->getIterations($totalEntities, $this->batchSize);
     $output->writeln(sprintf('<comment>Total entities:</comment> %s', $totalEntities));
     $output->writeln(sprintf('<comment>Batch size:</comment> %s', $this->batchSize));
     $output->writeln(sprintf('<comment>Iterations:</comment> %s', count($iterations)));
     $output->writeln(sprintf('<comment>Locale:</comment> %s', $locale));
     $output->writeln('<info>Flushing index</info>');
     $this->manager->flushIndex($locale);
     $progress = new ProgressBar($output, $totalEntities);
     $progress->setFormat('verbose');
     $progress->setRedrawFrequency($this->batchSize);
     $progress->start();
     foreach ($iterations as $iteration) {
         $entities = $this->getEntities($iteration);
         foreach ($entities as $entity) {
             $document = $this->type->createDocument($entity, $locale);
             $this->manager->addDocument($document);
             $progress->advance();
         }
     }
     $progress->finish();
     $output->writeln('');
     $output->writeln('<info>Optimizing index</info>');
     $this->manager->optimizeIndex($locale);
 }
開發者ID:WellCommerce,項目名稱:SearchBundle,代碼行數:27,代碼來源:ReindexCommand.php

示例9: executeRawImport

 /**
  * Executes a raw import.
  *
  * @param Manager         $manager
  * @param string          $filename
  * @param OutputInterface $output
  * @param int             $bulkSize
  */
 protected function executeRawImport(Manager $manager, $filename, OutputInterface $output, $bulkSize)
 {
     $reader = $this->getReader($manager, $filename, false);
     if (class_exists('\\Symfony\\Component\\Console\\Helper\\ProgressBar')) {
         $progress = new ProgressBar($output, $reader->count());
         $progress->setRedrawFrequency(100);
         $progress->start();
     } else {
         $progress = new ProgressHelper();
         $progress->setRedrawFrequency(100);
         $progress->start($output, $reader->count());
     }
     foreach ($reader as $key => $document) {
         $data = $document['_source'];
         $data['_id'] = $document['_id'];
         $manager->getConnection()->bulk('index', $document['_type'], $data);
         if (($key + 1) % $bulkSize == 0) {
             $manager->commit();
         }
         $progress->advance();
     }
     if (($key + 1) % $bulkSize != 0) {
         $manager->commit();
     }
     $progress->finish();
     $output->writeln('');
 }
開發者ID:N3m1s,項目名稱:ElasticsearchBundle,代碼行數:35,代碼來源:ImportService.php

示例10: __construct

 public function __construct(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('no-progress-bar')) {
         $progressBar = new ProgressBar($output);
         $progressBar->setFormat('verbose');
         $progressBar->setBarWidth(58);
         if (!$output->isDecorated()) {
             $progressBar->setRedrawFrequency(60);
         }
         $this->progressBar = $progressBar;
     } else {
         $this->isDisabled = true;
     }
 }
開發者ID:shadowhand,項目名稱:humbug,代碼行數:14,代碼來源:ProgressBarObserver.php

示例11: execute

 public function execute()
 {
     $bar = new ProgressBar($this->output, iterator_count($this->values));
     $bar->setFormat(" %current%/%max% [%bar%] %percent:3s%%\n %message%");
     $bar->setRedrawFrequency(100);
     $this->onBeforeStart($bar);
     $bar->start();
     foreach ($this->values as $value) {
         $this->onSingleStep($bar, $value);
         usleep(250);
     }
     $this->onBeforeFinish($bar);
     $bar->finish();
     $this->output->writeln(PHP_EOL);
 }
開發者ID:juniwalk,項目名稱:darwin,代碼行數:15,代碼來源:ProgressIterator.php

示例12: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pathToIlios2 = $input->getArgument('pathToIlios2');
     if (!$this->symfonyFileSystem->exists($pathToIlios2)) {
         throw new \Exception("'{$pathToIlios2}' does not exist.");
     }
     $totalLearningMaterialsCount = $this->learningMaterialManager->getTotalFileLearningMaterialCount();
     $helper = $this->getHelper('question');
     $output->writeln('');
     $question = new ConfirmationQuestion('<question>Ready to copy ' . $totalLearningMaterialsCount . ' learning materials. Shall we continue? </question>' . "\n", true);
     if ($helper->ask($input, $output, $question)) {
         $progress = new ProgressBar($output, $totalLearningMaterialsCount);
         $progress->setRedrawFrequency(208);
         $output->writeln("<info>Starting migration of learning materials...</info>");
         $progress->start();
         $migrated = 0;
         $skipped = 0;
         $offset = 0;
         $limit = 50;
         while ($migrated + $skipped < $totalLearningMaterialsCount) {
             $learningMaterials = $this->learningMaterialManager->findFileLearningMaterials($limit, $offset);
             foreach ($learningMaterials as $lm) {
                 $fullPath = $pathToIlios2 . $lm->getRelativePath();
                 if (!$this->symfonyFileSystem->exists($fullPath)) {
                     $skipped++;
                 } else {
                     $file = $this->iliosFileSystem->getSymfonyFileForPath($fullPath);
                     $newPath = $this->iliosFileSystem->storeLearningMaterialFile($file);
                     $lm->setRelativePath($newPath);
                     $this->learningMaterialManager->update($lm, false);
                     $migrated++;
                 }
                 $progress->advance();
             }
             $this->learningMaterialManager->flushAndClear();
             $offset += $limit;
         }
         $progress->finish();
         $output->writeln('');
         $output->writeln("<info>Migrated {$migrated} learning materials successfully!</info>");
         if ($skipped) {
             $msg = "<comment>Skipped {$skipped} learning materials because they could not be located " . "or were already migrated.</comment>";
             $output->writeln($msg);
         }
     } else {
         $output->writeln('<comment>Migration canceled.</comment>');
     }
 }
開發者ID:stopfstedt,項目名稱:ilios,代碼行數:51,代碼來源:MigrateIlios2LearningMaterialsCommand.php

示例13: downloadFile

 /**
  * Download a file from the URL to the destination.
  *
  * @param string $url      Fully qualified URL to the file.
  * @param bool   $progress Show the progressbar when downloading.
  */
 public function downloadFile($url, $progress = true)
 {
     /** @var ProgressBar|null $progressBar */
     $progressBar = null;
     $downloadCallback = function ($size, $downloaded, $client, $request, Response $response) use(&$progressBar) {
         // Don't initialize the progress bar for redirects as the size is much smaller.
         if ($response->getStatusCode() >= 300) {
             return;
         }
         if (null === $progressBar) {
             ProgressBar::setPlaceholderFormatterDefinition('max', function (ProgressBar $bar) {
                 return $this->formatSize($bar->getMaxSteps());
             });
             ProgressBar::setPlaceholderFormatterDefinition('current', function (ProgressBar $bar) {
                 return str_pad($this->formatSize($bar->getProgress()), 11, ' ', STR_PAD_LEFT);
             });
             $progressBar = new ProgressBar($this->output, $size);
             $progressBar->setFormat('%current%/%max% %bar%  %percent:3s%%');
             $progressBar->setRedrawFrequency(max(1, floor($size / 1000)));
             $progressBar->setBarWidth(60);
             if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
                 $progressBar->setEmptyBarCharacter('░');
                 // light shade character \u2591
                 $progressBar->setProgressCharacter('');
                 $progressBar->setBarCharacter('▓');
                 // dark shade character \u2593
             }
             $progressBar->start();
         }
         $progressBar->setProgress($downloaded);
     };
     $client = $this->getGuzzleClient();
     if ($progress) {
         $this->output->writeln(sprintf("\n Downloading %s...\n", $url));
         $client->getEmitter()->attach(new Progress(null, $downloadCallback));
     }
     $response = $client->get($url);
     $tmpFile = $this->filesystemHelper->newTempFilename();
     $this->fs->dumpFile($tmpFile, $response->getBody());
     if (null !== $progressBar) {
         $progressBar->finish();
         $this->output->writeln("\n");
     }
     return $tmpFile;
 }
開發者ID:gushphp,項目名稱:gush,代碼行數:51,代碼來源:DownloadHelper.php

示例14: exportIndex

 /**
  * Exports es index to provided file.
  *
  * @param Manager         $manager
  * @param string          $filename
  * @param array           $types
  * @param int             $chunkSize
  * @param OutputInterface $output
  */
 public function exportIndex(Manager $manager, $filename, $types, $chunkSize, OutputInterface $output)
 {
     $params = ['search_type' => 'scan', 'scroll' => '5m', 'size' => $chunkSize, 'source' => true, 'body' => ['query' => ['match_all' => []]], 'index' => $manager->getIndexName(), 'type' => $types];
     $results = new SearchHitIterator(new SearchResponseIterator($manager->getClient(), $params));
     $progress = new ProgressBar($output, $results->count());
     $progress->setRedrawFrequency(100);
     $progress->start();
     $metadata = ['count' => $results->count(), 'date' => date(\DateTime::ISO8601)];
     $writer = $this->getWriter($this->getFilePath($filename), $metadata);
     foreach ($results as $data) {
         $doc = array_intersect_key($data, array_flip(['_id', '_type', '_source', 'fields']));
         $writer->push($doc);
         $progress->advance();
     }
     $writer->finalize();
     $progress->finish();
     $output->writeln('');
 }
開發者ID:Nyholm,項目名稱:ElasticsearchBundle,代碼行數:27,代碼來源:ExportService.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $scanner = new Scanner($this->getHost($input, 'scan-host'), $input->getArgument('scan'));
     $indexer = new Indexer($this->getHost($input, 'index-host'), $input->getArgument('index'));
     $indexer->setBulkSize(intval($input->getOption('bulk')));
     $output->writeln('<info>Scanning & indexing...</info>');
     $progress = new ProgressBar($output);
     $progress->setFormat('debug_nomax');
     $progress->setRedrawFrequency(100);
     foreach ($scanner->scan() as $document) {
         $indexer->index($document);
         $progress->advance();
     }
     $progress->finish();
     $output->write("\n<info>Flushing...</info>");
     $indexer->ensure();
     $output->writeln('<comment>done.</comment>');
     return 0;
 }
開發者ID:martiis,項目名稱:elasticsearch-reindexer,代碼行數:22,代碼來源:ReindexCommand.php


注:本文中的Symfony\Component\Console\Helper\ProgressBar::setRedrawFrequency方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。