コード例 #1
0
ファイル: Copy.php プロジェクト: Catapush/Idephix
 /**
  * Main deploy method
  * @return string commands output
  */
 public function deploy()
 {
     $this->output->writeln("Copy code to the next release dir");
     $this->remoteCopyRecursive($this->target->get('deploy.current_release_dir') . '/.', $this->target->get('deploy.next_release_dir'));
     $out = $this->sshClient->getLastOutput();
     $this->output->writeln("Sync code to the next release");
     $this->rsync($this->target->getFixedPath('deploy.local_base_dir'), $this->target->get('deploy.dry_run') ? $this->target->get('deploy.current_release_dir') . '/' : $this->target->get('deploy.next_release_dir'));
     $out .= $this->sshClient->getLastOutput();
     return $out;
 }
コード例 #2
0
ファイル: ForexCommand.php プロジェクト: erpk/erbot
 protected function loop()
 {
     $this->output->writeln('Starting...');
     while (true) {
         try {
             $offers = $this->exchangeModule->scan($this->buy);
             $this->pingLoader();
             $accounts = array(ExchangeModule::CURRENCY => $offers->getCurrencyAmount(), ExchangeModule::GOLD => $offers->getGoldAmount());
             foreach ($offers as $offer) {
                 if ($offer->rate <= $this->priceLimit) {
                     $this->output->writeln("[ID: {$offer->id}][Amount: {$offer->amount}]" . "[Rate: {$offer->rate}][{$offer->sellerId}:{$offer->sellerName}]");
                     $toBuy = $offer->amount;
                     if ($this->buy == ExchangeModule::GOLD && $toBuy > 10) {
                         $toBuy = 10;
                     }
                     if ($toBuy * $offer->rate > $accounts[$this->sell]) {
                         $toBuy = round($accounts[$this->sell] / $offer->rate, 2) - 0.01;
                     }
                     if ($toBuy > 0) {
                         $this->buy($offer, $toBuy);
                     }
                 }
             }
         } catch (\Exception $e) {
             if ($this->output->isVerbose()) {
                 $this->output->writeln('<error>' . $e->getMessage() . '</error>');
             }
         }
         usleep($this->scanInterval * 1000000);
     }
 }
コード例 #3
0
ファイル: Runner.php プロジェクト: vysinsky/babylon
    private function printHeader()
    {
        $header = <<<TEXT

Welcome to
 _____ _____ _____ __ __ __    _____ _____
| __  |  _  | __  |  |  |  |  |     |   | |
| __ -|     | __ -|_   _|  |__|  |  | | | |
|_____|__|__|_____| |_| |_____|_____|_|___| 1.0.0 alpha

The transpiler for writing PHP 7 today


TEXT;
        $this->output->writeln($header);
    }
コード例 #4
0
ファイル: HunterCommand.php プロジェクト: erpk/erbot
 protected function scan()
 {
     try {
         $offers = $this->marketModule->scan($this->country, $this->industry, $this->quality);
     } catch (\Exception $e) {
         $this->output->writeln('<error>' . $e->getMessage() . '</error>');
         return;
     }
     $first = true;
     foreach ($offers as $offer) {
         if ($offer->price <= $this->priceLimit && $offer->amount >= $this->minimumAmount) {
             $startTime = microtime(true);
             $this->output->writeln('<info>Found offer: [ID: ' . $offer->id . '][Amount: ' . $offer->amount . ']</info>');
             $amount = $offer->amount;
             while ($this->toBuy > 0 && $amount > 0) {
                 if ($amount < 100000) {
                     if ($amount > $this->toBuy) {
                         $n = $this->toBuy;
                     } else {
                         $n = $amount;
                     }
                 } else {
                     if ($this->toBuy < 100000) {
                         $n = $this->toBuy;
                     } else {
                         $n = 99999;
                     }
                 }
                 $result = $this->marketModule->buy($offer, $n);
                 $msPassed = round((microtime(true) - $startTime) * 1000, 0);
                 $successful = fnmatch('You have successfully bought*', $result);
                 if ($successful) {
                     $amount -= $n;
                     $this->toBuy -= $n;
                 }
                 $this->output->writeln('<info>[' . $msPassed . ' ms passed][' . $result . '][Left: ' . $this->toBuy . ']</info>');
                 if (!$successful) {
                     break;
                 }
             }
         } elseif ($first) {
             $first = false;
             $this->pingLoader();
         }
     }
 }
コード例 #5
0
 private function askToProcessAllLayers($layers, Input $input, Output $output, Helper $helper)
 {
     $output->writeln("\n<say>These are all the datasets ready to be processed:</say>");
     foreach ($layers as $layer) {
         $output->writeln("- {$layer}");
     }
     $question = new ConfirmationQuestion("\n<ask>Do you want to process all of them? (yes/no): </ask>", false);
     return $helper->ask($input, $output, $question);
 }
コード例 #6
0
ファイル: Import.php プロジェクト: Silwereth/sulu
 /**
  * Imports a single file.
  *
  * @param Package         $package  the package to import the file into
  * @param LoaderInterface $loader
  * @param string          $path     The path to the file
  * @param string          $filename The filename
  * @param bool            $backend  True to make the file available in the backend
  * @param bool            $frontend True to make the file available in the frontend
  * @param bool            $throw    If true the methods throws exception if the a file cannot be found
  *
  * @throws \Exception
  * @throws \InvalidArgumentException
  * @throws \Symfony\Component\Translation\Exception\NotFoundResourceException
  */
 private function importFile($package, $loader, $path, $filename, $backend = true, $frontend = false, $throw = false)
 {
     try {
         $this->output->writeln($filename);
         $filePath = $path ? $path . '/' . $filename : $filename;
         $file = $loader->load($filePath, $this->locale);
         // find the catalogue from this package matching the given locale
         $catalogue = null;
         $newCatalogue = true;
         foreach ($package->getCatalogues() as $packageCatalogue) {
             /** @var $packageCatalogue Catalogue */
             if ($packageCatalogue->getLocale() === $this->locale) {
                 $catalogue = $packageCatalogue;
                 $newCatalogue = false;
             }
         }
         // if no catalogue is found create a new one
         if ($newCatalogue === true) {
             $catalogue = new Catalogue();
             if ($this->locale === $this->defaultLocale) {
                 $catalogue->setIsDefault(true);
             } else {
                 $catalogue->setIsDefault(false);
             }
             $catalogue->setPackage($package);
             $package->addCatalogue($catalogue);
             $catalogue->setLocale($this->locale);
             $this->em->persist($catalogue);
             $this->em->flush();
         }
         $allMessages = $file->all()['messages'];
         $progress = new ProgressHelper();
         $progress->start($this->output, count($allMessages));
         // loop through all translation units in the file
         foreach ($allMessages as $key => $message) {
             // Check if code is already existing in current catalogue
             if (!$newCatalogue && ($translate = $catalogue->findTranslation($key))) {
                 // Update the old translate
                 $translate->setValue($message);
             } else {
                 // Create new code, if not already existing
                 $code = $package->findCode($key);
                 if (!$code) {
                     $code = new Code();
                     $code->setPackage($package);
                     $code->setCode($key);
                     $code->setBackend($backend);
                     $code->setFrontend($frontend);
                     $this->em->persist($code);
                     $this->em->flush();
                 }
                 // Create new translate
                 $translate = new Translation();
                 $translate->setCode($code);
                 $translate->setValue($message);
                 $translate->setCatalogue($catalogue);
                 $this->em->persist($translate);
             }
             $progress->advance();
         }
         $this->em->flush();
         $progress->finish();
     } catch (\InvalidArgumentException $e) {
         if ($e instanceof NotFoundResourceException) {
             if ($throw === true) {
                 throw $e;
             }
         } else {
             throw $e;
         }
     }
 }