コード例 #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
ファイル: Command.php プロジェクト: allejo/bzion
 /**
  * Return a function that can be used by Symfony's process to show the output
  * of a process live on our screen
  *
  * @param  Output $output The console output
  *
  * @return null|\Closure
  */
 protected function getBufferFunction($output)
 {
     if (!$output->isVerbose()) {
         return null;
     }
     return function ($type, $buffer) {
         if (Process::ERR === $type) {
             echo 'ERR > ' . $buffer;
         } else {
             echo 'OUT > ' . $buffer;
         }
     };
 }
コード例 #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
ファイル: 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);
     }
 }
コード例 #5
0
 /**
  * @param int $verbosity
  * @param null $decorated
  * @param \Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter
  */
 public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
 {
     if (null === $decorated) {
         $decorated = $this->hasColorSupport();
     }
     parent::__construct($verbosity, $decorated, $formatter);
 }
コード例 #6
0
 /**
  * Constructor.
  *
  * @param mixed                    $stream
  * @param bool|int                 $verbosity
  * @param null                     $decorated
  * @param OutputFormatterInterface $formatter
  */
 public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
 {
     if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) {
         throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
     }
     $this->stream = $stream;
     parent::__construct($verbosity, $decorated, $formatter);
 }
コード例 #7
0
ファイル: NCursesOutput.php プロジェクト: jean-pasqualini/ia
 public function __construct()
 {
     parent::__construct();
     $this->setFormatter(new OutputFormatter());
     ncurses_init();
     //ncurses_mvaddstr(55,1,"My first ncurses application");
     $this->window = ncurses_newwin(40, 30, 0, 0);
     ncurses_wborder($this->window, 0, 0, 0, 0, 0, 0, 0, 0);
 }
コード例 #8
0
ファイル: StreamOutput.php プロジェクト: bangpound/pecan
 /**
  * Constructor.
  *
  * @param Stream $stream
  * @param bool|int $verbosity
  * @param null $decorated
  * @param OutputFormatterInterface $formatter
  */
 public function __construct(Stream $stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
 {
     $this->stream = $stream;
     $this->stream->on('error', function ($error) {
         $this->emit('error', [$error, $this]);
     });
     if (null === $decorated) {
         $decorated = $this->hasColorSupport();
     }
     parent::__construct($verbosity, $decorated, $formatter);
 }
コード例 #9
0
 /**
  * @param \Mapstorming\Commands\OutputInterface|\Symfony\Component\Console\Output\Output $output
  * @return \Symfony\Component\Console\Output\OutputInterface
  */
 public function setOutputFormat(Output $output)
 {
     $style = new OutputFormatterStyle('cyan', 'black', array('bold'));
     $output->getFormatter()->setStyle('high', $style);
     $style = new OutputFormatterStyle('blue', 'black', array('bold'));
     $output->getFormatter()->setStyle('say', $style);
     $style = new OutputFormatterStyle('green', 'black', array('bold'));
     $output->getFormatter()->setStyle('ask', $style);
     $style = new OutputFormatterStyle('white', 'black', array('bold'));
     $output->getFormatter()->setStyle('star', $style);
     $style = new OutputFormatterStyle('red', 'black', array('bold'));
     $output->getFormatter()->setStyle('bk', $style);
     $style = new OutputFormatterStyle('cyan', 'black', array('bold', 'blink'));
     $output->getFormatter()->setStyle('blink', $style);
     return $output;
 }
コード例 #10
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();
         }
     }
 }
コード例 #11
0
ファイル: CatchOutput.php プロジェクト: mjphaynes/php-resque
 /**
  * Writes a message to the output.
  *
  * @param string|array $messages The message as an array of lines or a single string
  * @param Boolean      $newline  Whether to add a newline
  * @param integer      $type     The type of output (one of the OUTPUT constants)
  *
  * @throws \InvalidArgumentException When unknown output type is given
  */
 public function write($messages, $newline = false, $type = self::OUTPUT_RAW)
 {
     parent::write($messages, $newline, $type);
 }
コード例 #12
0
 /**
  * @param CommunityInterface $community
  * @param Output             $output
  */
 private function updateCommunityMembers(CommunityInterface $community, Output $output)
 {
     $this->logger->addInfo(sprintf('Checking community "%s" with %s', $community->getName(), $community->getId()));
     $today = new \DateTime('-4 hour');
     $loopTimeStart = microtime(true);
     $failsCount = 0;
     $members = $community->getMembers();
     if ($output->isVerbose()) {
         $this->logger->addInfo(sprintf('Found %s members', count($members)));
     }
     foreach ($members as $player) {
         $memberTimeStart = microtime(true);
         $this->logger->addInfo(sprintf('Checking user "%s" with id "%s"', $player->getNick(), $player->getId()));
         $alreadyParseCheckTime = microtime(true);
         if (count($player->getDateStat()) && $player->getDateStat()->first()->getDate()->format('Y:m:d') == $today->format('Y:m:d')) {
             $this->logger->addInfo(sprintf('Player "%s" with id %s already parsed today', $player->getNick(), $player->getId()));
             if ($output->isVerbose()) {
                 $this->logger->addInfo(sprintf('Already parse check take %s sec to process', microtime(true) - $alreadyParseCheckTime));
             }
             continue;
         }
         if ($output->isVerbose()) {
             $this->logger->addInfo(sprintf('Already parse check take %s sec to process', microtime(true) - $alreadyParseCheckTime));
         }
         $playerUpdateTimeStart = microtime(true);
         try {
             $this->statService->updatePlayer($player->getId());
         } catch (RuntimeException $e) {
             if ($e->getCode() == 403) {
                 $failsCount++;
                 if ($failsCount >= 10) {
                     throw $e;
                 }
                 $this->logger->addWarning(sprintf('Fail to update player "%s" with id %s', $player->getNick(), $player->getId()));
             } else {
                 throw $e;
             }
         }
         if ($output->isVerbose()) {
             $this->logger->addInfo(sprintf('Player parse take %s sec to process', microtime(true) - $playerUpdateTimeStart));
         }
         $sleepMicroTime = rand(500, 1500) * 1000;
         if ($output->isVerbose()) {
             $this->logger->addInfo(sprintf('Member take %s sec to process', microtime(true) - $memberTimeStart));
             $this->logger->addInfo(sprintf('Sleep for %s sec', $sleepMicroTime / 1000 / 1000));
         }
         usleep($sleepMicroTime);
     }
     if ($output->isVerbose()) {
         $this->logger->addInfo(sprintf('Loop take %s sec to process', microtime(true) - $loopTimeStart));
     }
 }
コード例 #13
0
ファイル: Output.php プロジェクト: m3dweb/bcnbit
 public function __construct($verbosity = self::VERBOSITY_NORMAL)
 {
     parent::__construct($verbosity, TRUE, new OutputFormatter(TRUE));
 }
コード例 #14
0
ファイル: FileOutput.php プロジェクト: int3rlop3r/phron
 /**
  * @param string $filepath Path to the output file
  */
 public function __construct($filepath = null)
 {
     parent::__construct(self::VERBOSITY_NORMAL, false, null);
     $this->filepath = $filepath;
     file_put_contents($filepath, "");
 }
コード例 #15
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);
 }
 /**
  * Constructor.
  *
  * @param \LeLogger                     $logger    A logentries logger instance
  * @param int                           $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
  * @param bool|null                     $decorated Whether to decorate messages (null for auto-guessing)
  * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter)
  *
  * @throws \InvalidArgumentException When first argument is not a real logger
  *
  * @api
  */
 public function __construct(\LeLogger $logger, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
 {
     $this->logger = $logger;
     parent::__construct($verbosity, $decorated, $formatter);
 }
コード例 #17
0
ファイル: TgTest.php プロジェクト: twhiston/tg
 public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
 {
     parent::__construct($verbosity, $decorated, $formatter);
     $this->messages = [];
 }
コード例 #18
0
ファイル: OutputTest.php プロジェクト: rooster/symfony
 public function testSetStyle()
 {
     Output::setStyle('FOO', array('bg' => 'red', 'fg' => 'yellow', 'blink' => true));
     $this->assertEquals(array('bg' => 'red', 'fg' => 'yellow', 'blink' => true), TestOutput::getStyle('foo'), '::setStyle() sets a new style');
 }
コード例 #19
0
 public function __construct($verbosity = self::VERBOSITY_NORMAL)
 {
     parent::__construct($verbosity);
 }
コード例 #20
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;
         }
     }
 }
コード例 #21
0
ファイル: RemoteOutput.php プロジェクト: modera/module
 /**
  * @param callable $closure
  * @param bool|int $verbosity
  * @param bool $decorated
  * @param OutputFormatterInterface $formatter
  */
 public function __construct(\Closure $closure, $verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
 {
     $this->closure = $closure;
     parent::__construct($verbosity, $decorated, $formatter);
 }
コード例 #22
0
ファイル: JobOutput.php プロジェクト: theus77/ElasticMS
 public function __construct(Registry $doctrine, Job $job)
 {
     $this->doctrine = $doctrine;
     $this->job = $job;
     parent::__construct();
 }