Starts a new progress bar output in the pre-run phase.

@see \Shiyan\Iterate\Scenario\ScenarioInterface::preRun()
183996
public function preRun(): void {
    if ($output = $this->getOutput()) {
      $max = 0;
      $iterator = $this->getIterator();

      if ($iterator instanceof \SplFileObject) {
        $max = $iterator->getSize();
      }
      elseif ($iterator instanceof \Countable) {
        $max = count($iterator);
      }

      $this->progress = new ProgressBar($output, $max);
      if ($output->isDecorated()) {
        // If output is not decorated, the redraw frequency would automatically
        // be set to $max/10 by default.
        $this->progress->setRedrawFrequency($max / 100);
      }
      $this->progress->start();
    }
  }
1249131
public function run(ProgressBar $progressBar)
  {
    $faker = Factory::create($this->getLocale());

    for ($i = 0; $i < $this->count; $i++) {
      $progressBar->advance();
      $this->seed($faker, $i);
    }

    $progressBar->finish();
    echo PHP_EOL;

    return true;
  }
204336
public function start_html() {
        if ($this->bar) {
            throw new \coding_exception('Already started');
        }
        $this->bar = new \progress_bar();
        $this->bar->create();
        echo \html_writer::start_div('wibbler');
    }
305744
private function runInit($args)
    {
        $cmd = new InitCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
576318
public function update_progress() {
        // If finished...
        if (!$this->is_in_progress_section()) {
            if ($this->bar) {
                $this->end_html();
            }
        } else {
            if (!$this->bar) {
                $this->start_html();
            }
            // In case of indeterminate or small progress, update the wibbler
            // (up to once per second).
            if (time() != $this->lastwibble) {
                $this->lastwibble = time();
                echo \html_writer::div('', 'wibble state' . $this->currentstate);

                // Go on to next colour.
                $this->currentstate += $this->direction;
                if ($this->currentstate < 0 || $this->currentstate >= self::WIBBLE_STATES) {
                    $this->direction = -$this->direction;
                    $this->currentstate += 2 * $this->direction;
                }
                $buffersize = ini_get('output_buffering');
                if (!is_numeric($buffersize)) {
                    // The output_buffering setting can be a number, but can also be "On" or "Off".
                    // If "Off", there's no buffer, if "On", there's no limit to the size. In either case,
                    // there's no point in trying to fill the buffer.
                    $buffersize = 0;
                }
                if ($buffersize) {
                    // Force the buffer full.
                    echo str_pad('', $buffersize);
                }
            }

            // Get progress.
            list ($min, $max) = $this->get_progress_proportion_range();

            // Update progress bar.
            $message = '';
            if ($this->displaynames) {
                $message = $this->get_current_description();
            }
            $this->bar->update_full($min * 100, $message);

            // Flush output.
            flush();
        }
    }
467165
public function run()
    {
        parent::run();

        while (\count($this->running) || \count($this->pending)) {
            foreach ($this->running as $key => $test) {
                try {
                    if (!$this->testIsStillRunning($test)) {
                        unset($this->running[$key]);
                        $this->releaseToken($key);
                    }
                } catch (\Exception $e) {
                    if ($this->options->verbose) {
                        echo "An error for $key: {$e->getMessage()}" . PHP_EOL;
                        echo "Command: {$test->getLastCommand()}" . PHP_EOL;
                        echo 'StdErr: ' . $test->getStderr() . PHP_EOL;
                        echo 'StdOut: ' . $test->getStdout() . PHP_EOL;
                    }
                    throw $e;
                }
            }
            $this->fillRunQueue();
            usleep(10000);
        }
        $this->complete();
    }
679560
public function run()
    {
        if ($this->stage++ > 0) {
            $this->header('500 Too Busy');
            return;
        }
        $this->noncache();
        if (isset($_SERVER['HTTP_CONTENT_TYPE']) && $_SERVER['HTTP_CONTENT_TYPE'] === 'application/x-www-form-urlencoded') {
            if (!isset($_POST['d']) || !is_string($_POST['d']) || !mb_orig_strlen($_POST['d'])) {
                $this->header('500 Internal Server Error');
                echo 'Payload expected.';
                return;
            }
            if (!json_decode($_POST['d'], true)) {
                $this->header('500 Internal Server Error');
                echo 'Broken JSON encoding.';
                return;
            }
            $payload = $_POST['d'];
        } else {
            if ($this->attrs->raw === '') {
                $this->header('500 Internal Server Error');
                echo 'Payload expected.';
                return;
            }
            if (!json_decode($this->attrs->raw, true)) {
                $this->header('500 Internal Server Error');
                echo 'Broken JSON encoding.';
                return;
            }
            $payload = $this->attrs->raw;
        }
        $this->appInstance->publish('c2s:' . $this->sessId, $payload, function ($redis) {
            if ($redis->result === 0) {
                $this->header('404 Not Found');
            } else {
                echo 'ok';
            }
            $this->finish();
        });
        $this->sleep(30);
    }
36652
protected function prepareOptionProgressBar()
    {
        if (!empty($this->progressBar) && is_string($this->progressBar)) {
            return strtr($this->progressBar, ['{LOADING}' => Yii::t($this->translateCategory, 'Loading')]);
        }
        return !empty($this->bootstrapDefaults['progressBar']) ? strtr($this->bootstrapDefaults['progressBar'], ['{LOADING}' => Yii::t($this->translateCategory, 'Loading')]) : '';
    }
307268
public function preRun(){

        if(!isset($this->parameters['target']) ){
            $this->parameters['target'] = $this->parameters['t']; 
        }

        if(!isset($this->parameters['documentRoot']) ){
            $this->parameters['documentRoot'] = $this->parameters['d'];
        }
        if(!isset($this->parameters['serverName']) ){
            $this->parameters['serverName'] = $this->parameters['s'];
        }
        if(!isset($this->parameters['tpl']) ){
            $this->parameters['tpl'] = dirname(__FILE__). '/sample/sample.conf';
        }
        
        $fileinfo =pathinfo($this->parameters['target']);
        
        if($fileinfo['extension'] != 'conf'){
            $this->err('Extension of target file has to be conf', true);
        }
    }
328176
public function run()
    {
        try {
            return $this
                ->preRun()
                ->check();
        } catch (Exception $e) {
            return $this
                ->setMessage($e->getMessage())
                ->setCode($e->getCode());
        }
    }
876548
public function start() {
		if($this->isStarted) {
			throw new \Exception(get_called_class() . ' is already started, use ' . get_called_class() . '::getInstance()->isStarted() to check it.');
		}
		$this->isStarted = true;

		if($this->handleErrors) {
			$this->initErrorsHandler();
		}
		if($this->handleExceptions) {
			$this->initExceptionsHandler();
		}
	}
1174546
protected function run()
    {
        $constant2 = pack('c*', 0x9A, 0x99, 0x99, 0x99, 0x99, 0x99, 0xF9, 0x3F);
        $separator = pack('c*', 0x9D, 0xFF, 0xFF, 0xFF);
        $scenarioConstant = pack('c*', 0xF6, 0x28, 0x9C, 0x3F);
        $aokSeparator = pack('c*', 0x9A, 0x99, 0x99, 0x3F);
        $aoe2recordScenarioSeparator = pack('c*', 0xAE, 0x47, 0xA1, 0x3F);
        $aoe2recordHeaderSeparator = pack('c*', 0xA3, 0x5F, 0x02, 0x00);

        $rec = $this->rec;
        $this->analysis = new \StdClass;
        $analysis = $this->analysis;

        $playersByIndex = [];
        $gameType = -1;

        $size = strlen($this->header);
        $this->position = 0;

        $this->version = $this->read(VersionAnalyzer::class);
        $version = $this->version;

        $triggerInfoPos = strrpos($this->header, $constant2, $this->position) + strlen($constant2);
        $gameSettingsPos = strrpos($this->header, $separator, -($size - $triggerInfoPos)) + strlen($separator);
        $scenarioSeparator = $scenarioConstant;
        if ($version->isAoK) {
            $scenarioSeparator = $aokSeparator;
        }
        if ($version->isAoe2Record) {
            $scenarioSeparator = $aoe2recordScenarioSeparator;
        }
        $scenarioHeaderPos = strrpos($this->header, $scenarioSeparator, -($size - $gameSettingsPos));
        if ($scenarioHeaderPos !== false) {
            $scenarioHeaderPos -= 4;
        }

        if ($version->isAoe2Record) {
            $aoe2recordHeader = $this->read(Aoe2RecordHeaderAnalyzer::class);
        }

        $includeAi = $this->readHeader('L', 4);
        if ($includeAi !== 0) {
            $this->skipAi();
        }

        $this->position += 4;
        if ($version->isAoe2Record) {
            $this->position += 4;
            $gameSpeed = $aoe2recordHeader['gameSpeed'];
        } else {
            $gameSpeed = $this->readHeader('l', 4);
        }
        // These bytes contain the game speed again several times over, as ints
        // and as floats (On normal speed: 150, 1.5 and 0.15). Why?!
        $this->position += 37;
        $pov = $this->readHeader('v', 2);
        if ($version->isAoe2Record) {
            $numPlayers = $aoe2recordHeader['numPlayers'];
            $gameMode = $aoe2recordHeader['isMultiPlayer'];
            $this->position += 5;
        } else {
            $numPlayers = ord($this->header[$this->position++]);
            $numPlayers -= 1;
            // - 1, because player #0 is GAIA.
            if ($version->isMgx) {
                $this->position += 1; // Is instant building enabled? (cheat "aegis")
                $this->position += 1; // Are cheats enabled?
            }
            $gameMode = $this->readHeader('v', 2);
        }

        // TODO what are these?
        // Something is up here because we do `+=46` just below which makes for `+=58` anyway.
        // For some reason PHP runs out of memory if I do it differently…
        if ($version->subVersion >= 12.50) {
            $this->position += 12;
        }

        $analysis->numPlayers = $numPlayers;

        if ($version->isAoe2Record && $version->subVersion >= 12.49) {
            $this->position += 46;
        } else {
            $this->position += 58;
        }

        $mapData = $this->read(MapDataAnalyzer::class);
        $analysis->mapSize = $mapData->mapSize;

        // int. Value is 10060 in AoK recorded games, 40600 in AoC and on.
        $this->position += 4;

        $playerInfoPos = $this->position;

        $this->analysis->scenarioFilename = null;
        if ($scenarioHeaderPos > 0) {
            $this->position = $scenarioHeaderPos;
            $this->readScenarioHeader();
            // Set game type here, it will be overwritten by data from the
            // recorded game settings later. In MGL files there is no game
            // type field in the recorded game, so this one will be used.
            $gameType = GameSettings::TYPE_SCENARIO;
        }

        $analysis->messages = $this->readMessages();

        // Skip two separators to find the victory condition block.
        $this->position = strpos($this->header, $separator, $this->position);
        $this->position = strpos($this->header, $separator, $this->position + 4);

        $analysis->victory = $this->read(VictorySettingsAnalyzer::class);

        $this->position = $gameSettingsPos + 8;

        // TODO Is 12.3 the correct cutoff point?
        if ($version->subVersion >= 12.3) {
            // TODO what are theeeese?
            $this->position += 16;
        }

        if ($version->isAoe2Record) {
            // Always 0? Map ID is now in the aoe2record front matter and gets
            // parsed below.
            $this->position += 4;
            $mapId = $aoe2recordHeader['mapId'];
        } else if (!$version->isAoK) {
            $mapId = $this->readHeader('l', 4);
        }
        $difficulty = $this->readHeader('l', 4);
        $lockTeams = $this->readHeader('L', 4);

        $players = $this->read(PlayerMetaAnalyzer::class);
        foreach ($players as $player) {
            $playersByIndex[$player->index] = $player;
            if ($player->index === $pov) {
                $player->owner = true;
            }
        }

        // Merge in player from the aoe2record header if it exists.
        // In some cases (eg. civId) the places where the data was originally stored is now empty,
        // with the data instead only being stored in the aoe2record header.
        // Other player analyzers will fall back to this data in those cases.
        if ($version->isAoe2Record && array_key_exists('players', $aoe2recordHeader)) {
            foreach ($players as $i => $player) {
                foreach ($aoe2recordHeader['players'][$i] as $key => $value) {
                    $player->$key = $value;
                }
            }
        }

        $analysis->players = $players;

        $this->position = $triggerInfoPos + 1;
        $this->skipTriggerInfo();

        $teamIndices = [];
        for ($i = 0; $i < 8; $i += 1) {
            $teamIndices[$i] = ord($this->header[$this->position + $i]);
        }
        $this->position += 8;

        foreach ($analysis->players as $i => $player) {
            $player->team = $teamIndices[$i] - 1;
        }

        $restore = $this->position;

        $this->position = $playerInfoPos;
        $playerInfo = $this->read(PlayerInfoBlockAnalyzer::class, $analysis);

        $this->position = $restore;

        if ($version->subVersion < 12.3) {
            $this->position += 1;
        }
        $revealMap = $this->readHeader('l', 4);

        $this->position += 4;
        $mapSize = $this->readHeader('l', 4);
        $popLimit = $this->readHeader('l', 4);

        if ($version->isMgx) {
            $gameType = ord($this->header[$this->position]);
            $lockDiplomacy = ord($this->header[$this->position + 1]);
            $this->position += 2;
        }

        if ($version->subVersion >= 11.96) {
            $this->position += 1;
        }

        if ($version->isHDEdition) {
            $this->position += 4;
        }

        $pregameChat = [];
        if ($version->isMgx) {
            $pregameChat = $this->readChat($players);
        }

        $analysis->teams = $this->buildTeams($players);

        $gameSettings = [
            'gameType' => $gameType,
            'gameSpeed' => $gameSpeed,
            'mapSize' => $mapSize,
            'difficultyLevel' => $difficulty,
            // UserPatch stores the actual population limit divided by 25.
            'popLimit' => $version->isUserPatch ? $popLimit * 25 : $popLimit,
        ];

        if (!$version->isAoK) {
            $gameSettings = array_merge($gameSettings, [
                'mapId' => $mapId,
                'lockDiplomacy' => $lockDiplomacy,
            ]);
        }

        $gameInfo = new GameInfo($this->rec);

        $analysis->mapData = $mapData->terrain;
        $analysis->pregameChat = $pregameChat;
        $analysis->gameSettings = new GameSettings($this->rec, $gameSettings);
        $analysis->gameInfo = $gameInfo;
        $analysis->playerInfo = $playerInfo;

        return $analysis;
    }
1261602
public function progressBar($useProgressBar = true)
    {
        if ($useProgressBar) {
            $this->progressbar = true;
        } else {
            $this->progressbar = false;
        }

        // If they set this true after saying they want tiny, they actually want small.
        if ($useProgressBar && $this->getSize() == static::SIZE_TINY) {
            $this->size(static::SIZE_SMALL);
        }
        // If they set this true after saying they want invisible, they're being silly and I refuse to handle it.

        return $this;
    }
219726
public function run()
	{
		$this->say('Updating ' . $this->getJConfig()->extension . " to " . $this->getJConfig()->version);

		// Reusing the header config here
		$exclude = explode(",", trim($this->getJConfig()->header->exclude));

		$path      = realpath($this->getJConfig()->source);
		$fileTypes = explode(",", trim($this->getJConfig()->header->files));

		$changedFiles = 0;

		foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)) as $filename)
		{
			if (substr($filename, 0, 1) == '.')
			{
				continue;
			}

			$file = new \SplFileInfo($filename);

			if (!in_array($file->getExtension(), $fileTypes))
			{
				continue;
			}

			// Skip directories in exclude list
			if (isset($exclude) && count($exclude))
			{
				$relative = str_replace(realpath($path), "", $file->getPath());

				// It is possible to have multiple exclude directories
				foreach ($exclude as $e)
				{
					if (stripos($relative, $e) !== false)
					{
						$this->say("Excluding " . $filename);
						continue 2;
					}
				}
			}

			// Load the file
			$fileContents = file_get_contents($file->getRealPath());

			if (preg_match('#__DEPLOY_VERSION__#', $fileContents))
			{
				$fileContents = preg_replace('#__DEPLOY_VERSION__#', $this->getJConfig()->version, $fileContents);

				$this->say('Updating file: ' . $file->getRealPath());

				file_put_contents($file->getRealPath(), $fileContents);

				$changedFiles++;
			}
		}

		$this->say('Updated ' . $changedFiles . ' files');

		return true;
	}
751455
function run()
    {
        if ( $this->HTTP->hasPostVariable( 'PreviousButton' ) )
        {
            return $this->previousStep();
        }

        switch( $this->metaData( 'current_stage' ) )
        {
            case eZWizardBase::STAGE_PRE:
            {
                $this->preCheck();
                $this->nextStep();
                if ( $this->skip() )
                {
                    return $this->nextStep();
                }
                return $this->process();
            } break;

            case eZWizardBase::STAGE_POST:
            {
                if ( $this->postCheck() )
                {
                    return $this->nextStep();
                }
                else
                {
                    return $this->process();
                }
            } break;
        }
    }
683775
public function start() {
        if ($this->running === true) {
            throw new xml_writer_exception('xml_writer_already_started');
        }
        if ($this->running === false) {
            throw new xml_writer_exception('xml_writer_already_stopped');
        }
        $this->output->start(); // Initialize whatever we need in output
        if (!is_null($this->prologue)) { // Output prologue
            $this->write($this->prologue);
        } else {
            $this->write($this->get_default_prologue());
        }
        $this->running = true;
    }
1363474
def output_before_run(self, run):
        
        # output in terminal
        runSet = run.runSet
        try:
            OutputHandler.print_lock.acquire()

            try:
                runSet.started_runs += 1
            except AttributeError:
                runSet.started_runs = 1

            timeStr = time.strftime("%H:%M:%S", time.localtime()) + "   "
            progressIndicator = " ({0}/{1})".format(runSet.started_runs, len(runSet.runs))
            terminalTitle = TERMINAL_TITLE.format(runSet.full_name + progressIndicator)
            if self.benchmark.num_of_threads == 1:
                util.printOut(terminalTitle + timeStr + self.format_sourcefile_name(run.identifier, runSet), '')
            else:
                util.printOut(terminalTitle + timeStr + "starting   " + self.format_sourcefile_name(run.identifier, runSet))
        finally:
            OutputHandler.print_lock.release()