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


PHP ExecFuture::write方法代码示例

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


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

示例1: lintPath

 public function lintPath($path)
 {
     $bin = $this->getLintPath();
     $options = $this->getLintOptions();
     $f = new ExecFuture("%C %C -", $bin, $options);
     $f->write($this->getData($path));
     list($err, $stdout, $stderr) = $f->resolve();
     if ($err === 2) {
         throw new Exception("cpplint failed to run correctly:\n" . $stderr);
     }
     $lines = explode("\n", $stderr);
     $messages = array();
     foreach ($lines as $line) {
         $line = trim($line);
         $matches = null;
         $regex = '/^-:(\\d+):\\s*(.*)\\s*\\[(.*)\\] \\[(\\d+)\\]$/';
         if (!preg_match($regex, $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[1]);
         $message->setCode($matches[3]);
         $message->setName($matches[3]);
         $message->setDescription($matches[2]);
         $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
         $this->addLintMessage($message);
     }
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:32,代码来源:ArcanistCpplintLinter.php

示例2: lintPath

 public function lintPath($path)
 {
     $working_copy = $this->getEngine()->getWorkingCopy();
     $pyflakes_path = $working_copy->getConfig('lint.pyflakes.path');
     $pyflakes_prefix = $working_copy->getConfig('lint.pyflakes.prefix');
     // Default to just finding pyflakes in the users path
     $pyflakes_bin = 'pyflakes';
     $python_path = '';
     // If a pyflakes path was specified, then just use that as the
     // pyflakes binary and assume that the libraries will be imported
     // correctly.
     //
     // If no pyflakes path was specified and a pyflakes prefix was
     // specified, then use the binary from this prefix and add it to
     // the PYTHONPATH environment variable so that the libs are imported
     // correctly.  This is useful when pyflakes is installed into a
     // non-default location.
     if ($pyflakes_path !== null) {
         $pyflakes_bin = $pyflakes_path;
     } else {
         if ($pyflakes_prefix !== null) {
             $pyflakes_bin = $pyflakes_prefix . '/bin/pyflakes';
             $python_path = $pyflakes_prefix . '/lib/python2.6/site-packages:';
         }
     }
     $options = $this->getPyFlakesOptions();
     $f = new ExecFuture("/usr/bin/env PYTHONPATH=%s\$PYTHONPATH " . "{$pyflakes_bin} {$options}", $python_path);
     $f->write($this->getData($path));
     try {
         list($stdout, $_) = $f->resolvex();
     } catch (CommandException $e) {
         // PyFlakes will return an exit code of 1 if warnings/errors
         // are found but print nothing to stderr in this case.  Therefore,
         // if we see any output on stderr or a return code other than 1 or 0,
         // pyflakes failed.
         if ($e->getError() !== 1 || $e->getStderr() !== '') {
             throw $e;
         } else {
             $stdout = $e->getStdout();
         }
     }
     $lines = explode("\n", $stdout);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match('/^(.*?):(\\d+): (.*)$/', $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         $message->setCode($this->getLinterName());
         $message->setDescription($matches[3]);
         $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING);
         $this->addLintMessage($message);
     }
 }
开发者ID:nik-kor,项目名称:arcanist,代码行数:60,代码来源:ArcanistPyFlakesLinter.php

示例3: lintPath

 public function lintPath($path)
 {
     $rubyp = $this->getRubyPath();
     $f = new ExecFuture("%s -wc", $rubyp);
     $f->write($this->getData($path));
     list($err, $stdout, $stderr) = $f->resolve();
     if ($err === 0) {
         return;
     }
     $lines = explode("\n", $stderr);
     $messages = array();
     foreach ($lines as $line) {
         $matches = null;
         if (!preg_match("/(.*?):(\\d+): (.*?)\$/", $line, $matches)) {
             continue;
         }
         foreach ($matches as $key => $match) {
             $matches[$key] = trim($match);
         }
         $code = head(explode(',', $matches[3]));
         $message = new ArcanistLintMessage();
         $message->setPath($path);
         $message->setLine($matches[2]);
         $message->setName($this->getLinterName() . " " . $code);
         $message->setDescription($matches[3]);
         $message->setSeverity($this->getMessageCodeSeverity($code));
         $this->addLintMessage($message);
     }
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:29,代码来源:ArcanistRubyLinter.php

示例4: xhpast_get_parser_future

/**
 * @group xhpast
 */
function xhpast_get_parser_future($data)
{
    if (!xhpast_is_available()) {
        throw new Exception(xhpast_get_build_instructions());
    }
    $future = new ExecFuture('%s', xhpast_get_binary_path());
    $future->write($data);
    return $future;
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:12,代码来源:xhpast_parse.php

示例5: __construct

 /**
  * Construct an exec channel from a @{class:ExecFuture}. The future should
  * **NOT** have been started yet (e.g., with `isReady()` or `start()`),
  * because @{class:ExecFuture} closes stdin by default when futures start.
  * If stdin has been closed, you will be unable to write on the channel.
  *
  * @param ExecFuture Future to use as an underlying I/O source.
  * @task construct
  */
 public function __construct(ExecFuture $future)
 {
     // Make an empty write to keep the stdin pipe open. By default, futures
     // close this pipe when they start.
     $future->write('', $keep_pipe = true);
     // Start the future so that reads and writes work immediately.
     $future->isReady();
     $this->future = $future;
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:18,代码来源:PhutilExecChannel.php

示例6: writeAndRead

 private function writeAndRead($write, $read)
 {
     $future = new ExecFuture('cat');
     $future->write($write);
     $lines = array();
     foreach (new LinesOfALargeExecFuture($future) as $line) {
         $lines[] = $line;
     }
     $this->assertEqual($read, $lines, pht('Write: %s', id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(32)->truncateString($write)));
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:10,代码来源:LinesOfALargeExecFutureTestCase.php

示例7: writeAndRead

 private function writeAndRead($write, $read)
 {
     $future = new ExecFuture('cat');
     $future->write($write);
     $lines = array();
     foreach (new LinesOfALargeExecFuture($future) as $line) {
         $lines[] = $line;
     }
     $this->assertEqual($read, $lines, "Write: " . phutil_utf8_shorten($write, 32));
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:10,代码来源:LinesOfALargeExecFutureTestCase.php

示例8: runBootloaderTests

 private function runBootloaderTests(PhageAgentBootloader $boot)
 {
     $name = get_class($boot);
     $exec = new ExecFuture('%C', $boot->getBootCommand());
     $exec->write($boot->getBootSequence(), $keep_open = true);
     $exec_channel = new PhutilExecChannel($exec);
     $agent = new PhutilJSONProtocolChannel($exec_channel);
     $agent->write(array('type' => 'EXEC', 'key' => 1, 'command' => 'echo phage'));
     $this->agentExpect($agent, array('type' => 'RSLV', 'key' => 1, 'err' => 0, 'stdout' => "phage\n", 'stderr' => ''), "'echo phage' for {$name}");
     $agent->write(array('type' => 'EXIT'));
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:11,代码来源:PhageAgentTestCase.php

示例9: getHighlightFuture

 public function getHighlightFuture($source)
 {
     $language = idx($this->config, 'language');
     if ($language) {
         $language = $this->getPygmentsLexerNameFromLanguageName($language);
         $future = new ExecFuture('pygmentize -O stripnl=False -f html -l %s', $language);
         $future->write($source);
         return new PhutilDefaultSyntaxHighlighterEnginePygmentsFuture($future, $source);
     }
     return id(new PhutilDefaultSyntaxHighlighter())->getHighlightFuture($source);
 }
开发者ID:rmoorman,项目名称:libphutil,代码行数:11,代码来源:PhutilPygmentsSyntaxHighlighter.php

示例10: transformResource

 /**
  * @phutil-external-symbol function jsShrink
  */
 public function transformResource($path, $data)
 {
     $type = self::getResourceType($path);
     switch ($type) {
         case 'css':
             $data = $this->replaceCSSPrintRules($path, $data);
             $data = $this->replaceCSSVariables($path, $data);
             $data = preg_replace_callback('@url\\s*\\((\\s*[\'"]?.*?)\\)@s', nonempty($this->translateURICallback, array($this, 'translateResourceURI')), $data);
             break;
     }
     if (!$this->minify) {
         return $data;
     }
     // Some resources won't survive minification (like Raphael.js), and are
     // marked so as not to be minified.
     if (strpos($data, '@' . 'do-not-minify') !== false) {
         return $data;
     }
     switch ($type) {
         case 'css':
             // Remove comments.
             $data = preg_replace('@/\\*.*?\\*/@s', '', $data);
             // Remove whitespace around symbols.
             $data = preg_replace('@\\s*([{}:;,])\\s*@', '\\1', $data);
             // Remove unnecessary semicolons.
             $data = preg_replace('@;}@', '}', $data);
             // Replace #rrggbb with #rgb when possible.
             $data = preg_replace('@#([a-f0-9])\\1([a-f0-9])\\2([a-f0-9])\\3@i', '#\\1\\2\\3', $data);
             $data = trim($data);
             break;
         case 'js':
             // If `jsxmin` is available, use it. jsxmin is the Javelin minifier and
             // produces the smallest output, but is complicated to build.
             if (Filesystem::binaryExists('jsxmin')) {
                 $future = new ExecFuture('jsxmin __DEV__:0');
                 $future->write($data);
                 list($err, $result) = $future->resolve();
                 if (!$err) {
                     $data = $result;
                     break;
                 }
             }
             // If `jsxmin` is not available, use `JsShrink`, which doesn't compress
             // quite as well but is always available.
             $root = dirname(phutil_get_library_root('phabricator'));
             require_once $root . '/externals/JsShrink/jsShrink.php';
             $data = jsShrink($data);
             break;
     }
     return $data;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:54,代码来源:CelerityResourceTransformer.php

示例11: __construct

 public function __construct($sockname, $repo_root, $args, array $command)
 {
     $this->command = json_encode($command);
     $console = PhutilConsole::getConsole();
     $console->writeLog("cli query: %s\n", $this->command);
     $future = new ExecFuture("%C {$args} -U %s %s %s %s %s", "{$repo_root}/watchman", $sockname, '--no-pretty', '--no-spawn', '--no-local', '-j');
     $cwd = getcwd();
     if (!$cwd) {
         throw new Exception("can't figure out my cwd!?");
     }
     $future->setCWD($cwd);
     $future->write($this->command . "\n");
     parent::__construct($future);
 }
开发者ID:ezhangle,项目名称:watchman,代码行数:14,代码来源:WatchmanQueryFuture.php

示例12: getParserFuture

 /**
  * Constructs an @{class:ExecFuture} for XHPAST.
  *
  * @param  wild        Data to pass to the future.
  * @return ExecFuture
  */
 public static function getParserFuture($data)
 {
     if (!self::isAvailable()) {
         try {
             // Try to build XHPAST automatically. If we can't then just ask the
             // user to build it themselves.
             self::build();
         } catch (CommandException $ex) {
             throw new PhutilProxyException(self::getBuildInstructions(), $ex);
         }
     }
     $future = new ExecFuture('%s', self::getPath());
     $future->write($data);
     return $future;
 }
开发者ID:bearinchina,项目名称:libphutil,代码行数:21,代码来源:PhutilXHPASTBinary.php

示例13: xhpast_get_parser_future

/**
 * @group xhpast
 */
function xhpast_get_parser_future($data)
{
    if (!xhpast_is_available()) {
        try {
            // Try to build XHPAST automatically. If we can't then just ask the user
            // to build it themselves.
            xhpast_build();
        } catch (CommandException $e) {
            throw new Exception(xhpast_get_build_instructions());
        }
    }
    $future = new ExecFuture('%s', xhpast_get_binary_path());
    $future->write($data);
    return $future;
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:18,代码来源:xhpast_parse.php

示例14: getHighlightFuture

 public function getHighlightFuture($source)
 {
     $language = idx($this->config, 'language');
     if ($language) {
         $language = $this->getPygmentsLexerNameFromLanguageName($language);
         $future = new ExecFuture('pygmentize -O encoding=utf-8 -O stripnl=False -f html -l %s', $language);
         $scrub = false;
         if ($language == 'php' && strpos($source, '<?') === false) {
             $source = "<?php\n" . $source;
             $scrub = true;
         }
         $future->write($source);
         return new PhutilDefaultSyntaxHighlighterEnginePygmentsFuture($future, $source, $scrub);
     }
     return id(new PhutilDefaultSyntaxHighlighter())->getHighlightFuture($source);
 }
开发者ID:rwray,项目名称:libphutil,代码行数:16,代码来源:PhutilPygmentsSyntaxHighlighter.php

示例15: willParseFiles

 public function willParseFiles(array $file_map)
 {
     $root = dirname(phutil_get_library_root('javelin-diviner'));
     $bin = $root . '/jsast/jsast';
     if (!Filesystem::pathExists($bin)) {
         throw new Exception("You must build the 'jsast' binary before you can generate " . "Javelin documentation.");
     }
     $futures = array();
     foreach ($file_map as $file => $data) {
         $future = new ExecFuture($bin);
         $future->write($data);
         $futures[$file] = $future;
     }
     foreach (Futures($futures)->limit(8) as $file => $future) {
         $this->trees[$file] = $future->resolveJSON();
     }
 }
开发者ID:WilkGardariki,项目名称:javelin,代码行数:17,代码来源:JavelinDivinerEngine.php


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