progressStart() public method

public progressStart ( $max )
Esempio n. 1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $allJournals = $this->getAllJournals();
     $this->io->progressStart(count($allJournals));
     foreach ($allJournals as $journal) {
         $this->normalizeLastIssuesByJournal($journal);
     }
 }
Esempio n. 2
0
 private function removeIssues(InputInterface $input)
 {
     $this->refreshJournal($input);
     $journalIssues = $this->em->getRepository('OjsJournalBundle:Issue')->findBy(['journal' => $this->journal]);
     $this->io->progressStart(count($journalIssues));
     foreach ($journalIssues as $issue) {
         $this->io->progressAdvance();
         $this->em->remove($issue);
     }
     $this->em->flush();
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->progressStart(count($this->allJournals));
     $counter = 1;
     foreach ($this->allJournals as $journal) {
         $this->normalizeSetting($journal);
         $this->io->progressAdvance(1);
         $counter = $counter + 1;
         if ($counter % 50 == 0) {
             $this->em->flush();
         }
     }
     $this->em->flush();
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->progressStart(count($this->getJournals()));
     $counter = 1;
     foreach ($this->getJournals() as $journal) {
         $this->addTranslation($journal);
         $this->io->progressAdvance(1);
         $counter = $counter + 1;
         if ($counter % 50 == 0) {
             $this->em->flush();
         }
     }
     $this->em->flush();
     $this->io->success('All process finished');
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->progressStart(count($this->getAnnouncements()));
     $counter = 1;
     foreach ($this->getAnnouncements() as $announcement) {
         if (!$this->haveTranslation($announcement['id'])) {
             $this->addTranslation($announcement);
             $this->io->progressAdvance(1);
             $counter = $counter + 1;
             if ($counter % 50 == 0) {
                 $this->em->flush();
             }
         }
     }
     $this->em->flush();
     $this->io->success('All process finished');
 }
Esempio n. 6
0
 private function clearCache(SymfonyStyle $io, $env)
 {
     $io->section("Clearing cache ({$env})...");
     $io->progressStart(1);
     $input = $this->getEnvsInput($env);
     $command = $this->getApplication()->find('cache:clear');
     $cmdOutput = new BufferedOutput();
     $returnCode = $command->run($input, $cmdOutput);
     if ($returnCode !== 0) {
         $io->error("cache:clear command failed. You may need to manually delete the cache folders.");
         return;
     }
     $io->progressFinish();
 }
Esempio n. 7
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return null|int null or 0 if everything went fine, or an error code
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title("[ QCharts updating ]");
     //update the ones that are due
     $date = new DateTime();
     $_code = 0;
     try {
         $debugMode = $input->getOption("debug");
         $queryService = $this->getContainer()->get("qcharts.query");
         $queries = $queryService->getPreFetchedQueries();
         $dateFormat = SnapshotService::FILE_DATE_FORMAT;
         $io->note("QCharts date format: '{$dateFormat}', date now: {$date->format($dateFormat)}");
         $queriesQty = count($queries);
         $paths = $this->getContainer()->getParameter("qcharts.paths");
         $io->note("Saving in directory: {$paths['snapshots']}");
         $io->progressStart($queriesQty);
         $io->newLine(2);
         foreach ($queries as $query) {
             /** @var QueryRequest $query */
             try {
                 $this->updateQuery($query, $io, $date);
             } catch (\Exception $e) {
                 $io->error("Error updating '{$query->getTitle()}', {$e->getMessage()}, moving along...");
                 if ($debugMode && !$io->confirm("Want to continue?", true)) {
                     throw new AbortedOperationException("The operation was aborted by the user", 1);
                 }
             }
         }
     } catch (AbortedOperationException $e) {
         $_code = $e->getCode();
         $io->error($e->getMessage());
     } catch (\Exception $e) {
         $_code = 1;
         $io->error("{$e->getMessage()}");
     } finally {
         $_code ? $io->progressFinish() : null;
         $io->newLine(3);
         $io->text("[ QCharts finished with code: {$_code} ]");
     }
     $io->title("[ QCharts end updating ]");
 }
 /**
  * @{inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->application = $this->getApplication()->getApplication();
     $this->fixtureLoader = $this->getContainer()->get('demo.website_loader');
     $this->dataRepository = $this->getBundle()->getBaseDirectory() . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR;
     $output = new SymfonyStyle($input, $output);
     $output->title('BackBee Demonstration Website Importer');
     $output->progressStart(3);
     $lines = $this->loadFixtures();
     $output->progressAdvance();
     $output->note('✓ Updated BackBee Application');
     $website = $this->updateWebsite();
     $output->progressAdvance();
     $output->note(sprintf('✓ Updated Domain to ``%s`` with label ``%s``', $website['domain'], $website['label']));
     $this->importAssets();
     $output->progressAdvance();
     $output->note('✓ Imported pictures assets');
     $output->newline();
     $output->success('Website loaded with success.');
 }
Esempio n. 9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Slack import');
     $io->comment('Requesting slack history…');
     $om = $this->container->get('doctrine')->getManager();
     $slack = $this->container->get('slack.api');
     $args = ['channel' => $slack->findChannelId($this->container->getParameter('slack_web_channel')), 'count' => 1000];
     try {
         $latest = $om->getRepository(ProcessedSlackMessage::class)->findMostRecent();
         $args['oldest'] = $latest->getDate()->format('U.u');
     } catch (NoResultException $e) {
     }
     $response = $slack->request('channels.history', $args);
     $messages = json_decode($response)->messages;
     $io->progressStart(count($messages));
     foreach ($messages as $message) {
         $io->progressAdvance();
         if (!(new AndX(new IsSlackMessage(), new IsHumanMessage()))->isSatisfiedBy($message)) {
             continue;
         }
         try {
             $url = $this->container->get('parser.slack_message')->parseUrl($message->text);
             $tags = $this->container->get('parser.slack_message')->parseTags($message->text);
             $watchLink = $this->container->get('extractor.watch_link_metadata')->extract($url, $tags);
             $watchLink->setCreatedAt((new \DateTime())->setTimestamp($message->ts));
             $processedMessage = new ProcessedSlackMessage($watchLink->getCreatedAt());
             $om->persist($processedMessage);
             $om->persist($watchLink);
             // Flush required at each round for tags unicity
             $om->flush();
         } catch (\InvalidArgumentException $e) {
             $this->container->get('logger')->addNotice('Unable to insert watchlink', ['exception' => $e, 'message' => $message->text]);
         } catch (\Exception $e) {
             $this->container->get('logger')->addError('Unknow exception', ['exception' => $e, 'message' => $message->text]);
         }
     }
     $io->progressFinish();
     $io->comment('Flush links…');
     $io->comment('Done.');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $finder = new Finder();
     $finder->in(sys_get_temp_dir())->ignoreUnreadableDirs()->sortByType();
     $fs = new Filesystem();
     $files = $finder->name("backup_*");
     if (count($files) == 0) {
         $io->success('No olders backups removed');
         return;
     }
     $io->progressStart(count($files));
     foreach ($files as $file) {
         if ($fs->exists($file->getRealpath())) {
             $fs->remove($file->getRealpath());
         }
         sleep(1);
         $io->progressAdvance();
     }
     $io->progressFinish();
 }
 private function normalizePeriods()
 {
     $this->io->newLine();
     $this->io->text('normalizing periods');
     $this->getContainer()->getParameter('locale');
     $this->io->progressStart();
     $periods = $this->em->getRepository('OjsJournalBundle:Period')->findAll();
     foreach ($periods as $period) {
         $getTranslation = $this->em->getRepository('OjsJournalBundle:PeriodTranslation')->findOneBy(['translatable' => $period, 'locale' => $this->locale]);
         if (!$getTranslation) {
             $this->io->progressAdvance();
             $newPeriodTranslation = new PeriodTranslation();
             $newPeriodTranslation->setTranslatable($period);
             $newPeriodTranslation->setLocale($this->locale);
             $newPeriodTranslation->setPeriod('-');
             $this->em->persist($newPeriodTranslation);
         }
     }
     $this->em->flush();
     $this->io->newLine();
 }
Esempio n. 12
0
 private function createServerManagers()
 {
     /** @var Discord $discord */
     /* @var ObjectManager $manager */
     $discord = $this->getContainer()->get('discord');
     $manager = $this->getContainer()->get('default_manager');
     $repo = $manager->getRepository($this->getContainer()->getParameter('server_class'));
     /** @var Collection $servers */
     $servers = $discord->guilds;
     $ids = [];
     foreach ($discord->guilds as $guild) {
         $ids[] = $guild->id;
     }
     $dbServers = $repo->findBy(['identifier' => $ids]);
     $this->output->text('Creating server managers for ' . $servers->count() . ' servers.');
     $this->output->progressStart($servers->count());
     /** @var ServerManagerFactory $factory */
     $factory = $this->getContainer()->get('factory.server_manager');
     foreach ($discord->guilds as $server) {
         $dbServer = $this->findDbServer($dbServers, $server);
         try {
             $this->serverManagers[] = $factory->create($server, $dbServer);
         } catch (\Exception $e) {
             $this->output->progressFinish();
             $this->logError($e->getMessage());
             exit(0);
         }
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
     $delay = $this->getContainer()->getParameter('database_save_delay');
     if ($delay !== false) {
         $this->getContainer()->get('default_manager')->flush();
         $discord->loop->addPeriodicTimer($delay, function () {
             $this->output->note('Saving current UoW to database.');
             $this->getContainer()->get('default_manager')->flush();
         });
     }
 }
 /**
  * @return array
  */
 private function doGenerate()
 {
     $numberOfChars = count($this->possibleChars) - 1;
     $codesList = [];
     $this->io->progressStart($this->numberOfCodesToGenerate);
     for ($i = 0; $i < $this->numberOfCodesToGenerate; $i++) {
         do {
             $code = '';
             for ($j = 0; $j < $this->codeLength; $j++) {
                 $code .= $this->possibleChars[rand(0, $numberOfChars)];
             }
         } while (isset($codesList[$code]));
         $codesList[$code] = $code;
         $this->io->progressAdvance();
         if ($this->sleepTime) {
             usleep($this->sleepTime);
         }
     }
     $this->io->progressFinish();
     if ($this->sort) {
         sort($codesList);
     }
     return array_unique($codesList);
 }
Esempio n. 14
0
 /**
  * Search for open jobs and executes them
  * then show a report about the done job.
  */
 protected function executeJobs()
 {
     // Get the Jobs to be processed.
     $jobsInQueue = $this->em->getRepository('CampaignChainCoreBundle:Job')->getOpenJobsForScheduler($this->scheduler);
     if (empty($jobsInQueue)) {
         return;
     }
     $this->io->section('Executing jobs now:');
     $this->logger->info('Executing {counter} jobs now:', ['counter' => count($jobsInQueue)]);
     $this->io->progressStart(count($jobsInQueue));
     foreach ($jobsInQueue as $jobInQueue) {
         // Execute job.
         $this->executeJob($jobInQueue);
         $this->io->progressAdvance();
     }
     // ensure that the progress bar is at 100%
     $this->io->progressFinish();
     $this->em->clear();
     // Get the processed jobs.
     $jobsProcessed = $this->em->getRepository('CampaignChainCoreBundle:Job')->getProcessedJobsForScheduler($this->scheduler);
     if (empty($jobsProcessed)) {
         return;
     }
     // Display the results of the execution.
     $tableHeader = ['Job ID', 'Operation ID', 'Process ID', 'Job Name', 'Job Start Date', 'Job End Date', 'Duration', 'Status', 'Message'];
     $outputTableRows = [];
     foreach ($jobsProcessed as $jobProcessed) {
         $startDate = null;
         $endDate = null;
         if ($jobProcessed->getStartDate()) {
             $startDate = $jobProcessed->getStartDate()->format('Y-m-d H:i:s');
         }
         if ($jobProcessed->getEndDate()) {
             $endDate = $jobProcessed->getEndDate()->format('Y-m-d H:i:s');
         }
         $jobData = [$jobProcessed->getId(), $jobProcessed->getActionId(), $jobProcessed->getPid(), $jobProcessed->getName(), $startDate, $endDate, $jobProcessed->getDuration() . ' ms', $jobProcessed->getStatus(), $jobProcessed->getMessage()];
         $outputTableRows[] = $jobData;
         if (Job::STATUS_ERROR === $jobProcessed->getStatus()) {
             $context = array_combine($tableHeader, $jobData);
             $this->logger->error($jobProcessed->getMessage(), $context);
         }
     }
     $this->io->text('Results of executed actions:');
     $this->io->table($tableHeader, $outputTableRows);
 }
Esempio n. 15
-1
    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * @return void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->io->title($this->getDescription());
        $totalAuthorCount = $this->getAuthorCount();
        $this->io->progressStart($totalAuthorCount);
        $rsm = new ResultSetMapping();
        for ($count = 0; $count <= $totalAuthorCount; $count += self::STEP) {
            $sql = <<<SQL
        UPDATE author
        SET user_id = users.id
        FROM users
        WHERE author.email = users.email
        AND author.id > ?
        and author.id < ?
        and author.user_id is null
SQL;
            $query = $this->em->createNativeQuery($sql, $rsm);
            $query->setParameter(1, $count);
            $query->setParameter(2, $count + self::STEP);
            $query->getResult();
            if (self::STEP > $totalAuthorCount) {
                $this->io->progressFinish();
            } else {
                $this->io->progressAdvance(self::STEP);
            }
        }
        $this->io->newLine(2);
        $this->io->success('All process finished');
    }