示例#1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $images = $this->images();
     $map = $this->map($images);
     $this->makeDirectory(public_path(static::DESTINATION));
     $this->cleanDirectory(public_path(static::DESTINATION));
     $this->progress = $this->output->createProgressBar(count($map));
     $this->copyImages($map);
     $this->progress->finish();
     $this->printMessage();
 }
示例#2
0
 /**
  * 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);
     }
 }
示例#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
 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
                     chmod($file, $oldchmod);
                 }
             }
         }
         if ($concurrent) {
             for ($i = 0; $i < $workers; ++$i) {
                 $chn->in(null);
             }
             for ($i = 0; $i < $workers; ++$i) {
                 list($cache_hit, $cache_miss, $filesChanged) = $chn_done->out();
                 $cacheHitCount += $cache_hit;
             }
             $chn_done->close();
             $chn->close();
         }
         $progress->finish();
         fwrite(STDERR, PHP_EOL);
         continue;
     } elseif (!is_file($arg) && ('--' != substr($arg, 0, 2) || $hasFnSeparator)) {
         $fileNotFound = true;
         $missingFiles[] = $arg;
         fwrite(STDERR, '!');
     }
     if (0 == $fileCount % 20) {
         fwrite(STDERR, ' ' . $fileCount . PHP_EOL);
     }
 }
 fwrite(STDERR, PHP_EOL);
 if (null !== $cache) {
     fwrite(STDERR, ' ' . $cacheHitCount . ' files untouched (cache hit)' . PHP_EOL);
 }
 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;
 }
示例#7
0
    }
    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();
$table->render();