getStartTime() public method

Gets the progress bar start time.
public getStartTime ( ) : integer
return integer The progress bar start time
示例#1
0
 /**
  * @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);
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pBar = new ProgressBar($output, 10);
     $pBar->start();
     $showOutput = false;
     try {
         $sugarKernel = new SugarKernel('cli', 'dev', false);
         $sugarKernel->boot();
     } catch (\Exception $e) {
         $output->writeln($e->getMessage());
     }
     $pBar->advance(2);
     /** @var \User $user */
     $user = $sugarKernel->getG('current_user');
     $user->getSystemUser();
     $modules = $sugarKernel->getG('mod_strings');
     $pBar->advance();
     $qrr = new Qrr();
     if ($input->getOption('yell')) {
         $showOutput = true;
         $output->writeln('QRR output: ');
     }
     $qrr->repairAndClearAll(['clearAll'], [$modules['LBL_ALL_MODULES']], true, $showOutput);
     $pBar->advance(5);
     $sugarKernel->shutdown();
     $pBar->finish();
     $elapsed = time() - $pBar->getStartTime();
     $output->writeln(' ');
     $output->writeln(" Executed in: {$elapsed} s");
 }
 /**
  * @param \FlickrDownloadr\Photo\Photo $photo
  * @param string $filename
  * @param string $dirname
  * @return int Number of bytes that were written to the file, or FALSE on failure
  */
 public function download(Photo $photo, $filename, $dirname)
 {
     $url = $photo->getUrl();
     if ($this->dryRun) {
         return 0;
     }
     \Nette\Utils\FileSystem::createDir($dirname . '/' . dirname($filename));
     $this->setupProgressBar();
     $ctx = stream_context_create();
     stream_context_set_params($ctx, array("notification" => $this->getNotificationCallback($filename)));
     $bytes = file_put_contents($dirname . '/' . $filename, fopen($url, 'r', FALSE, $ctx));
     if ($bytes === FALSE) {
         $this->progress->setMessage('<error>Error!</error>', 'final_report');
     } else {
         list($time, $size, $speed) = $this->getFinalStats($this->progress->getMaxSteps(), $this->progress->getStartTime());
         $this->progress->setMessage('<comment>[' . $size . ' in ' . $time . ' (' . $speed . ')]</comment>', 'final_report');
         $this->progress->setFormat('%message% %final_report%' . "\n");
     }
     $this->progress->finish();
     $this->output->writeln('');
     return $bytes;
 }
示例#4
0
 /**
  */
 public function testSetCurrentBeforeStarting()
 {
     $bar = new ProgressBar($this->getOutputStream());
     $bar->setProgress(15);
     $this->assertNotNull($bar->getStartTime());
 }
示例#5
0
 public function reDrawProgressBar()
 {
     if ($this->progress !== null && $this->progress->getStartTime() !== null) {
         $this->progress->display();
     }
 }
示例#6
0
 public function reDrawProgressBar()
 {
     if ($this->progress !== null && $this->progress->getStartTime() !== null && $this->progress->getProgress() !== $this->progress->getMaxSteps() && $this->progresseBar === true) {
         $this->progress->display();
     }
 }