当前位置: 首页>>代码示例>>PHP>>正文


PHP Maintenance::posix_isatty方法代码示例

本文整理汇总了PHP中Maintenance::posix_isatty方法的典型用法代码示例。如果您正苦于以下问题:PHP Maintenance::posix_isatty方法的具体用法?PHP Maintenance::posix_isatty怎么用?PHP Maintenance::posix_isatty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Maintenance的用法示例。


在下文中一共展示了Maintenance::posix_isatty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     if ($this->hasArg()) {
         $fileName = $this->getArg();
         $file = fopen($fileName, 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     while (($line = Maintenance::readconsole()) !== false) {
         $done = $dbw->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             continue;
         }
         if ($useReadline) {
             readline_add_history($wholeLine);
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $this->error($e, true);
         }
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:42,代码来源:sql.php

示例2: execute

 public function execute()
 {
     $wiki = $this->getOption('wikidb') ?: false;
     // Get the appropriate load balancer (for this wiki)
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'), $wiki);
     } else {
         $lb = wfGetLB($wiki);
     }
     // Figure out which server to use
     if ($this->hasOption('slave')) {
         $server = $this->getOption('slave');
         if ($server === 'any') {
             $index = DB_SLAVE;
         } else {
             $index = null;
             for ($i = 0; $i < $lb->getServerCount(); ++$i) {
                 if ($lb->getServerName($i) === $server) {
                     $index = $i;
                     break;
                 }
             }
             if ($index === null) {
                 $this->error("No slave server configured with the name '{$server}'.", 1);
             }
         }
     } else {
         $index = DB_MASTER;
     }
     // Get a DB handle (with this wiki's DB selected) from the appropriate load balancer
     $db = $lb->getConnection($index, array(), $wiki);
     if ($this->hasOption('slave') && $db->getLBInfo('master') !== null) {
         $this->error("The server selected ({$db->getServer()}) is not a slave.", 1);
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $db->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $db->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $db->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $db->query($wholeLine);
             $this->sqlPrintResult($res, $db);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
     wfWaitForSlaves();
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:85,代码来源:sql.php

示例3: wfGetLB

        $wgDebugLogFile = '/dev/stdout';
    }
    if ($d > 1) {
        $lb = wfGetLB();
        $serverCount = $lb->getServerCount();
        for ($i = 0; $i < $serverCount; $i++) {
            $server = $lb->getServerInfo($i);
            $server['flags'] |= DBO_DEBUG;
            $lb->setServerInfo($i, $server);
        }
    }
    if ($d > 2) {
        $wgDebugFunctionEntry = true;
    }
}
$useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
if ($useReadline) {
    $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mweval_history" : "{$IP}/maintenance/.mweval_history";
    readline_read_history($historyFile);
}
while (($line = Maintenance::readconsole()) !== false) {
    if ($useReadline) {
        readline_add_history($line);
        readline_write_history($historyFile);
    }
    $val = eval($line . ";");
    if (wfIsHipHop() || is_null($val)) {
        echo "\n";
    } elseif (is_string($val) || is_numeric($val)) {
        echo "{$val}\n";
    } else {
开发者ID:mangowi,项目名称:mediawiki,代码行数:31,代码来源:eval.php

示例4: execute

 public function execute()
 {
     // Get a DB handle (with this wiki's DB select) from the appropriate load balancer
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'));
         $dbw = $lb->getConnection(DB_MASTER);
         // master for external LB
     } else {
         $dbw = wfGetDB(DB_MASTER);
         // master for primary LB for this wiki
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $dbw->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $dbw->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
     wfWaitForSlaves();
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:62,代码来源:sql.php

示例5: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     if ($this->hasArg()) {
         $fileName = $this->getArg();
         $file = fopen($fileName, 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $dbw->sourceStream($file, false, array($this, 'sqlPrintResult'));
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     $useReadline = function_exists('readline_add_history') && Maintenance::posix_isatty(0);
     if ($useReadline) {
         global $IP;
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $dbw->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($useReadline) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . $dbw->getDelimiter());
             readline_write_history($historyFile);
         }
         try {
             $res = $dbw->query($wholeLine);
             $this->sqlPrintResult($res, $dbw);
             $prompt = $newPrompt;
             $wholeLine = '';
         } catch (DBQueryError $e) {
             $doDie = !Maintenance::posix_isatty(0);
             $this->error($e, $doDie);
         }
     }
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:54,代码来源:sql.php

示例6: execute

 public function execute()
 {
     global $IP;
     // We wan't to allow "" for the wikidb, meaning don't call select_db()
     $wiki = $this->hasOption('wikidb') ? $this->getOption('wikidb') : false;
     // Get the appropriate load balancer (for this wiki)
     if ($this->hasOption('cluster')) {
         $lb = wfGetLBFactory()->getExternalLB($this->getOption('cluster'), $wiki);
     } else {
         $lb = wfGetLB($wiki);
     }
     // Figure out which server to use
     $replicaDB = $this->getOption('replicadb', $this->getOption('slave', ''));
     if ($replicaDB === 'any') {
         $index = DB_REPLICA;
     } elseif ($replicaDB != '') {
         $index = null;
         $serverCount = $lb->getServerCount();
         for ($i = 0; $i < $serverCount; ++$i) {
             if ($lb->getServerName($i) === $replicaDB) {
                 $index = $i;
                 break;
             }
         }
         if ($index === null) {
             $this->error("No replica DB server configured with the name '{$replicaDB}'.", 1);
         }
     } else {
         $index = DB_MASTER;
     }
     /** @var Database $db DB handle for the appropriate cluster/wiki */
     $db = $lb->getConnection($index, [], $wiki);
     if ($replicaDB != '' && $db->getLBInfo('master') !== null) {
         $this->error("The server selected ({$db->getServer()}) is not a replica DB.", 1);
     }
     if ($index === DB_MASTER) {
         $updater = DatabaseUpdater::newForDB($db, true, $this);
         $db->setSchemaVars($updater->getSchemaVars());
     }
     if ($this->hasArg(0)) {
         $file = fopen($this->getArg(0), 'r');
         if (!$file) {
             $this->error("Unable to open input file", true);
         }
         $error = $db->sourceStream($file, null, [$this, 'sqlPrintResult']);
         if ($error !== true) {
             $this->error($error, true);
         } else {
             exit(0);
         }
     }
     if ($this->hasOption('query')) {
         $query = $this->getOption('query');
         $this->sqlDoQuery($db, $query, true);
         wfWaitForSlaves();
         return;
     }
     if (function_exists('readline_add_history') && Maintenance::posix_isatty(0)) {
         $historyFile = isset($_ENV['HOME']) ? "{$_ENV['HOME']}/.mwsql_history" : "{$IP}/maintenance/.mwsql_history";
         readline_read_history($historyFile);
     } else {
         $historyFile = null;
     }
     $wholeLine = '';
     $newPrompt = '> ';
     $prompt = $newPrompt;
     $doDie = !Maintenance::posix_isatty(0);
     while (($line = Maintenance::readconsole($prompt)) !== false) {
         if (!$line) {
             # User simply pressed return key
             continue;
         }
         $done = $db->streamStatementEnd($wholeLine, $line);
         $wholeLine .= $line;
         if (!$done) {
             $wholeLine .= ' ';
             $prompt = '    -> ';
             continue;
         }
         if ($historyFile) {
             # Delimiter is eated by streamStatementEnd, we add it
             # up in the history (bug 37020)
             readline_add_history($wholeLine . ';');
             readline_write_history($historyFile);
         }
         $this->sqlDoQuery($db, $wholeLine, $doDie);
         $prompt = $newPrompt;
         $wholeLine = '';
     }
     wfWaitForSlaves();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:91,代码来源:sql.php

示例7: execute

 public function execute()
 {
     global $wgParserTestFiles, $wgDBtype;
     // Cases of weird db corruption were encountered when running tests on earlyish
     // versions of SQLite
     if ($wgDBtype == 'sqlite') {
         $db = wfGetDB(DB_MASTER);
         $version = $db->getServerVersion();
         if (version_compare($version, '3.6') < 0) {
             die("Parser tests require SQLite version 3.6 or later, you have {$version}\n");
         }
     }
     // Print out software version to assist with locating regressions
     $version = SpecialVersion::getVersion('nodb');
     echo "This is MediaWiki version {$version}.\n\n";
     // Only colorize output if stdout is a terminal.
     $color = !wfIsWindows() && Maintenance::posix_isatty(1);
     if ($this->hasOption('color')) {
         switch ($this->getOption('color')) {
             case 'no':
                 $color = false;
                 break;
             case 'yes':
             default:
                 $color = true;
                 break;
         }
     }
     $record = $this->hasOption('record');
     $compare = $this->hasOption('compare');
     $regex = $this->getOption('filter', $this->getOption('regex', false));
     if ($regex !== false) {
         $regex = "/{$regex}/i";
         if ($record) {
             echo "Warning: --record cannot be used with --regex, disabling --record\n";
             $record = false;
         }
     }
     $term = $color ? new AnsiTermColorer() : new DummyTermColorer();
     $recorder = new MultiTestRecorder();
     $recorder->addRecorder(new ParserTestPrinter($term, ['showDiffs' => !$this->hasOption('quick'), 'showProgress' => !$this->hasOption('quiet'), 'showFailure' => !$this->hasOption('quiet') || !$record && !$compare, 'showOutput' => $this->hasOption('show-output'), 'useDwdiff' => $this->hasOption('dwdiff'), 'markWhitespace' => $this->hasOption('mark-ws')]));
     $recorderLB = false;
     if ($record || $compare) {
         $recorderLB = wfGetLBFactory()->newMainLB();
         // This connection will have the wiki's table prefix, not parsertest_
         $recorderDB = $recorderLB->getConnection(DB_MASTER);
         // Add recorder before previewer because recorder will create the
         // DB table if it doesn't exist
         if ($record) {
             $recorder->addRecorder(new DbTestRecorder($recorderDB));
         }
         $recorder->addRecorder(new DbTestPreviewer($recorderDB, function ($name) use($regex) {
             // Filter reports of old tests by the filter regex
             if ($regex === false) {
                 return true;
             } else {
                 return (bool) preg_match($regex, $name);
             }
         }));
     }
     // Default parser tests and any set from extensions or local config
     $files = $this->getOption('file', $wgParserTestFiles);
     $norm = $this->hasOption('norm') ? explode(',', $this->getOption('norm')) : [];
     $tester = new ParserTestRunner($recorder, ['norm' => $norm, 'regex' => $regex, 'keep-uploads' => $this->hasOption('keep-uploads'), 'run-disabled' => $this->hasOption('run-disabled'), 'run-parsoid' => $this->hasOption('run-parsoid'), 'use-tidy-config' => $this->hasOption('use-tidy-config'), 'file-backend' => $this->getOption('file-backend'), 'upload-dir' => $this->getOption('upload-dir')]);
     $ok = $tester->runTestsFromFiles($files);
     if ($recorderLB) {
         $recorderLB->closeAll();
     }
     if (!$ok) {
         exit(1);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:72,代码来源:parserTests.php


注:本文中的Maintenance::posix_isatty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。