コード例 #1
0
ファイル: CommandVcs.php プロジェクト: larakit/cmd-vcs
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $path = base_path('vendor');
     $vendor_paths = \File::directories($path);
     $path = rtrim(rtrim($path, '\\'), '/');
     $this->info('Сканируем установленные пакеты на наличие папок .git и .svn');
     $check_directories = [];
     foreach ($vendor_paths as $vendor_path) {
         $package_paths = File::directories($vendor_path);
         foreach ($package_paths as $package_path) {
             $check_directories[] = (string) $package_path;
         }
     }
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($check_directories));
     $progress->setFormat('debug');
     $progress->start();
     foreach ($check_directories as $directory) {
         $progress->advance();
         $is_git = $this->checkGit($directory);
         if (!$is_git) {
             $this->checkSvn($directory);
         }
     }
     $progress->finish();
     $this->info('');
     $this->info('Сканирование завершено.');
     $table = [];
     $separator = ['-', '-', '-', '-'];
     if ($this->touched_git) {
         $this->info('Имеются изменные файлы GIT: ');
         foreach ($this->touched_git as $package_path => $files) {
             $package = larasafepath($package_path);
             foreach ($files as $file => $type) {
                 $table[] = ['GIT', $package, larasafepath($file), \Illuminate\Support\Arr::get($this->git_types, $type, $type)];
             }
             $table[] = $separator;
         }
     }
     if ($this->touched_svn) {
         $this->info('Имеются изменные файлы SVN: ');
         foreach ($this->touched_svn as $package_path => $files) {
             $package = larasafepath($package_path);
             foreach ($files as $file => $type) {
                 $table[] = ['SVN', $package, trim(str_replace($package, '', larasafepath($file)), '/'), \Illuminate\Support\Arr::get($this->svn_types, $type, $type)];
             }
             $table[] = $separator;
         }
     }
     if ($table) {
         unset($table[sizeof($table) - 1]);
         $this->info('');
         $this->table(['VCS', 'package', 'file', 'type'], $table);
     }
 }
コード例 #2
0
 /**
  * Print progress on an iterator.
  *
  * @param array $items
  */
 public function progressIterator($items, Closure $closure)
 {
     $output = $this->command->getOutput();
     $iterations = count($items);
     if (class_exists('Symfony\\Component\\Console\\Helper\\ProgressBar')) {
         $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, $iterations);
         $progress->start();
     } else {
         $progress = $this->command->getHelper('progress');
         $progress->start($output, $iterations);
     }
     foreach ($items as $value) {
         $progress->advance();
         $closure($value, $progress);
     }
     $progress->finish();
 }
コード例 #3
0
ファイル: Sync.php プロジェクト: larakit/lk
 protected function dumpTables()
 {
     $this->info('Копирование информации из таблиц');
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($this->output, sizeof($this->tables));
     $progress->setFormat('debug');
     $progress->start();
     foreach ($this->tables as $table) {
         $data = \DB::connection($this->connection_name)->table($table)->get();
         $this->saveTable($table, $data);
         $progress->advance();
     }
     $progress->finish();
     $this->info('');
     $this->info('Таблицы успешно скопированы');
 }
コード例 #4
0
ファイル: CourseService.php プロジェクト: e19940604/Cyinf
 public function autoAddCourse($D0, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $NormalD1Collect = [["AC1C"], ["AC2K"], ["AC2L"], ["AC2M"], ["AC2N"], [], [], ["AE01", "AE02"], ["AH01"], ["AG01"], [], [], [], [], [], [], [], ["ASE2"], ["B101"], ["B102"], ["B10A"], ["B103"], ["M105"], ["B106"], ["B201"], ["M205"], ["B202"], ["B203"], ["B204"], ["B301"], ["M361"], ["M307"], ["B302"], ["B304"], ["B309"], ["B310"], ["M303"], ["B401"], ["B402"], ["B403"], ["M405"], [], ["B606"], ["M404"], ["M602"], ["M604"], ["B609"], ["M605"], ["M607"], ["B60A"], ["B504"], ["B502"], [], [], ["M507"], [], [], [], ["M462"], [], ["B509"]];
     $SpecialD1Collect = [10 => "AI00", 11 => "AI01", 12 => "AI02", 13 => "AI03", 14 => "AI04", 15 => "AI05", 16 => "AI06", 18 => "M101", 19 => "M102", 21 => "M103", 23 => "M107", 24 => "M201", 26 => "M202", 27 => "M203", 28 => "M204", 29 => "M301", 32 => "M302", 33 => "M304", 34 => "M309", 35 => "M310", 37 => "M411", 38 => "M402", 39 => "M403", 42 => "M606", 46 => "M609", 50 => "M504", 51 => "M502", 60 => "M509"];
     $this->initCourse();
     $bar = new \Symfony\Component\Console\Helper\ProgressBar($output, count($NormalD1Collect) + count($SpecialD1Collect));
     $bar->start();
     foreach ($NormalD1Collect as $course_department => $course_value) {
         foreach ($course_value as $key => $D1) {
             $this->fectch($D0, $D1, $course_department);
         }
         $bar->advance();
     }
     foreach ($SpecialD1Collect as $course_department => $D1) {
         $this->fectch($D0, $D1, $course_department, true);
         $bar->advance();
     }
     $bar->finish();
 }
コード例 #5
0
ファイル: Fakable.php プロジェクト: anahkiasen/fakable
 /**
  * Print progress on an iterator
  *
  * @param array    $items
  * @param callable $closure
  */
 public function progressIterator($items, callable $closure)
 {
     // Normal loop if no output
     if (!$this->command or sizeof($items) == 1) {
         foreach ($items as $value) {
             $closure($value);
         }
         return;
     }
     $output = $this->command->getOutput();
     $iterations = sizeof($items);
     // Create Progress helper
     if (class_exists('Symfony\\Component\\Console\\Helper\\ProgressBar')) {
         $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, $iterations);
         $progress->start();
     } else {
         $progress = $this->command->getHelper('progress');
         $progress->start($output, $iterations);
     }
     // Loop over items
     foreach ($items as $value) {
         $progress->advance();
         $closure($value, $progress);
     }
     $progress->finish();
 }
コード例 #6
0
ファイル: cli-core.php プロジェクト: JackWangCUMT/php.tools
                         $filesChanged = true;
                     }
                 } else {
                     file_put_contents($file . '-tmp', $fmtCode);
                     $oldchmod = fileperms($file);
                     $backup && rename($file, $file . '~');
                     rename($file . '-tmp', $file);
                     chmod($file, $oldchmod);
                 }
             }
             $chn_done->in([$cacheHitCount, $cache_miss_count, $filesChanged]);
         }, $fmt, $backup, $cache_fn, $chn, $chn_done, $lintBefore, $dryRun);
     }
 }
 $progress = new \Symfony\Component\Console\Helper\ProgressBar(new \Symfony\Component\Console\Output\StreamOutput(fopen('php://stderr', 'w')), sizeof(iterator_to_array($files)));
 $progress->start();
 foreach ($files as $file) {
     $progress->advance();
     $file = $file[0];
     if (null !== $ignore_list) {
         foreach ($ignore_list as $pattern) {
             if (false !== strpos($file, $pattern)) {
                 continue 2;
             }
         }
     }
     ++$fileCount;
     if ($concurrent) {
         $chn->in(['target_dir' => $target_dir, 'file' => $file]);
     } else {
         if (0 == $fileCount % 20) {
コード例 #7
0
 private function download($src, $target, $output)
 {
     $output->writeln("Downloading multimedia files to init the database:");
     $progress = new \Symfony\Component\Console\Helper\ProgressBar($output, 100);
     $progress->start();
     $ch = curl_init($src);
     $targetFile = fopen($target, 'wb');
     curl_setopt($ch, CURLOPT_FILE, $targetFile);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_NOPROGRESS, false);
     curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function ($c, $downloadSize, $downloaded, $uploadSize, $uploaded) use($progress) {
         $percentage = $downloaded > 0 && $downloadSize > 0 ? round($downloaded / $downloadSize, 2) : 0.0;
         $progress->setProgress($percentage * 100);
     });
     curl_exec($ch);
     $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     fclose($targetFile);
     curl_close($ch);
     $progress->finish();
     return 200 == $statusCode;
 }
コード例 #8
0
ファイル: benchmark.php プロジェクト: alekitto/serializer
        $post->addComment(new \Kcs\Serializer\Tests\Fixtures\Comment(new \Kcs\Serializer\Tests\Fixtures\Author('foo'), 'foobar'));
    }
    return $post;
}
$serializer = \Kcs\Serializer\SerializerBuilder::create()->setEventDispatcher(new \Symfony\Component\EventDispatcher\EventDispatcher())->build();
$collection = createCollection();
$metrics = [];
$f = function ($format) use($serializer, $collection) {
    $serializer->serialize($collection, $format);
};
// Load all necessary classes into memory.
$f('array');
$table = new \Symfony\Component\Console\Helper\Table($output);
$table->setHeaders(['Format', 'Direction', 'Time']);
$progressBar = new \Symfony\Component\Console\Helper\ProgressBar($output, 8);
$progressBar->start();
foreach (['array', 'json', 'yml', 'xml'] as $format) {
    $table->addRow([$format, 'serialize', benchmark($f, $format)]);
    $progressBar->advance();
}
$serialized = ['array' => $serializer->serialize($collection, 'array'), 'json' => $serializer->serialize($collection, 'json'), 'yml' => $serializer->serialize($collection, 'yml'), 'xml' => $serializer->serialize($collection, 'xml')];
$type = new \Kcs\Serializer\Type\Type('array', [\Kcs\Serializer\Type\Type::from(\Kcs\Serializer\Tests\Fixtures\BlogPost::class)]);
$d = function ($format) use($serializer, $serialized, $type) {
    $serializer->deserialize($serialized[$format], $type, $format);
};
foreach (['array', 'json', 'yml', 'xml'] as $format) {
    $table->addRow([$format, 'deserialize', benchmark($d, $format)]);
    $progressBar->advance();
}
$progressBar->finish();
$progressBar->clear();