当前位置: 首页>>代码示例>>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;未经允许,请勿转载。