• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP execx函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中execx函数的典型用法代码示例。如果您正苦于以下问题:PHP execx函数的具体用法?PHP execx怎么用?PHP execx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: executeQuery

 protected function executeQuery()
 {
     $drequest = $this->getRequest();
     $repository = $drequest->getRepository();
     if (!$drequest->getRawCommit()) {
         $effective_commit = $this->getEffectiveCommit();
         if (!$effective_commit) {
             return null;
         }
         // TODO: This side effect is kind of skethcy.
         $drequest->setCommit($effective_commit);
     } else {
         $effective_commit = $drequest->getCommit();
     }
     $options = array('-M', '-C', '--no-ext-diff', '--no-color', '--src-prefix=a/', '--dst-prefix=b/', '-U65535');
     $options = implode(' ', $options);
     list($raw_diff) = execx("(cd %s && git diff {$options} %s^ %s -- %s)", $repository->getDetail('local-path'), $effective_commit, $effective_commit, $drequest->getPath());
     $parser = new ArcanistDiffParser();
     $parser->setDetectBinaryFiles(true);
     $changes = $parser->parseDiff($raw_diff);
     $diff = DifferentialDiff::newFromRawChanges($changes);
     $changesets = $diff->getChangesets();
     $changeset = reset($changesets);
     $this->renderingReference = $drequest->getBranchURIComponent($drequest->getBranch()) . $drequest->getPath() . ';' . $drequest->getCommit();
     return $changeset;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:26,代码来源:DiffusionGitDiffQuery.php


示例2: run

 public final function run()
 {
     $repository = $this->loadRepository();
     $expected_type = $this->getSupportedRepositoryType();
     $repo_type = $repository->getVersionControlSystem();
     if ($repo_type != $expected_type) {
         $repo_type_name = PhabricatorRepositoryType::getNameForRepositoryType($repo_type);
         $expected_type_name = PhabricatorRepositoryType::getNameForRepositoryType($expected_type);
         $repo_name = $repository->getName() . ' (' . $repository->getCallsign() . ')';
         throw new Exception("This daemon pulls '{$expected_type_name}' repositories, but the " . "repository '{$repo_name}' is a '{$repo_type_name}' repository.");
     }
     $tracked = $repository->isTracked();
     if (!$tracked) {
         throw new Exception("Tracking is not enabled for this repository.");
     }
     $local_path = $repository->getDetail('local-path');
     if (!$local_path) {
         throw new Exception("No local path is available for this repository.");
     }
     while (true) {
         if (!Filesystem::pathExists($local_path)) {
             execx('mkdir -p %s', dirname($local_path));
             $this->executeCreate($repository, $local_path);
         } else {
             $this->executeUpdate($repository, $local_path);
         }
         $this->sleep($repository->getDetail('pull-frequency', 15));
     }
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:29,代码来源:PhabricatorRepositoryPullLocalDaemon.php


示例3: executeQuery

 protected function executeQuery()
 {
     $drequest = $this->getRequest();
     $repository = $drequest->getRepository();
     $path = $drequest->getPath();
     $commit = $drequest->getCommit();
     $remote_uri = $repository->getDetail('remote-uri');
     try {
         list($corpus) = execx('svn --non-interactive %s %s%s@%s', $this->getNeedsBlame() ? 'blame' : 'cat', $remote_uri, $path, $commit);
     } catch (CommandException $ex) {
         $stderr = $ex->getStdErr();
         if (preg_match('/path not found$/', trim($stderr))) {
             // TODO: Improve user experience for this. One way to end up here
             // is to have the parser behind and look at a file which was recently
             // nuked; Diffusion will think it still exists and try to grab content
             // at HEAD.
             throw new Exception("Failed to retrieve file content from Subversion. The file may " . "have been recently deleted, or the Diffusion cache may be out of " . "date.");
         } else {
             throw $ex;
         }
     }
     $file_content = new DiffusionFileContent();
     $file_content->setCorpus($corpus);
     return $file_content;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:25,代码来源:DiffusionSvnFileContentQuery.php


示例4: testTwoDeep

 function testTwoDeep()
 {
     $dir = PhutilDirectoryFixture::newEmptyFixture();
     $root = realpath($dir->getPath());
     $watch = $this->watch($root);
     $this->assertFileList($root, array());
     $this->assertEqual(true, mkdir("{$root}/foo"));
     $this->assertEqual(true, mkdir("{$root}/foo/bar"));
     // Guarantee that 111's mtime is greater than its directory's
     sleep(1);
     $this->assertEqual(3, file_put_contents("{$root}/foo/bar/111", "111"));
     $this->watchmanCommand('log', 'debug', 'XXX: created 111');
     $this->assertFileList($root, array("foo", "foo/bar", "foo/bar/111"));
     $query = $this->watchmanCommand('find', $root, 'foo/bar/111');
     $wfile = $query['files'][0];
     clearstatcache();
     $sfile = stat("{$root}/foo/bar/111");
     $query = $this->watchmanCommand('find', $root, 'foo/bar');
     $wdir = $query['files'][0];
     clearstatcache();
     $sdir = stat("{$root}/foo/bar");
     $this->watchmanCommand('log', 'debug', 'XXX: perform assertions');
     $compare_fields = array('size', 'mode', 'uid', 'gid', 'ino', 'dev', 'nlink', 'mtime', 'ctime');
     foreach ($compare_fields as $field) {
         $this->assertEqual($sfile[$field], $wfile[$field], "file: {$field} {$sfile[$field]} vs watchman {$wfile[$field]}");
         $this->assertEqual($sdir[$field], $wdir[$field], "dir: {$field} {$sdir[$field]} vs watchman {$wdir[$field]}");
     }
     $this->watchmanCommand('log', 'debug', 'XXX: remove it all');
     execx('rm -rf %s', "{$root}/foo/bar");
     $this->assertFileList($root, array("foo"));
 }
开发者ID:rogerwangzy,项目名称:watchman,代码行数:31,代码来源:twodeep.php


示例5: getPublicKey

 public function getPublicKey(PhabricatorUser $viewer, PassphraseCredential $credential)
 {
     $key = PassphraseSSHKey::loadFromPHID($credential->getPHID(), $viewer);
     $file = $key->getKeyfileEnvelope();
     list($stdout) = execx('ssh-keygen -y -f %P', $file);
     return $stdout;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PassphraseSSHPrivateKeyCredentialType.php


示例6: testPasswords

 public function testPasswords()
 {
     // Normal "%s" doesn't do anything special.
     $command = csprintf('echo %s', 'hunter2trustno1');
     $this->assertTrue(strpos($command, 'hunter2trustno1') !== false);
     // "%P" takes a PhutilOpaqueEnvelope.
     $caught = null;
     try {
         csprintf('echo %P', 'hunter2trustno1');
     } catch (Exception $ex) {
         $caught = $ex;
     }
     $this->assertTrue($caught instanceof Exception);
     // "%P" masks the provided value.
     $command = csprintf('echo %P', new PhutilOpaqueEnvelope('hunter2trustno1'));
     $this->assertFalse(strpos($command, 'hunter2trustno1'));
     // Executing the command works as expected.
     list($out) = execx('%C', $command);
     $this->assertTrue(strpos($out, 'hunter2trustno1') !== false);
     // Escaping should be robust even when used to escape commands which take
     // other commands.
     if (!phutil_is_windows()) {
         list($out) = execx('sh -c %s', csprintf('sh -c %s', csprintf('sh -c %s', csprintf('echo %P', new PhutilOpaqueEnvelope('!@#$%^&*()')))));
         $this->assertTrue(strpos($out, '!@#$%^&*()') !== false);
     }
 }
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:26,代码来源:PhutilcsprintfTestCase.php


示例7: run

 public function run()
 {
     while (true) {
         execx('true');
         $this->stillWorking();
     }
 }
开发者ID:lsubra,项目名称:libphutil,代码行数:7,代码来源:PhutilExcessiveServiceCallsDaemon.php


示例8: run

 public function run()
 {
     $repository = $this->loadRepository();
     if ($repository->getVersionControlSystem() != 'git') {
         throw new Exception("Not a git repository!");
     }
     $tracked = $repository->getDetail('tracking-enabled');
     if (!$tracked) {
         throw new Exception("Tracking is not enabled for this repository.");
     }
     $local_path = $repository->getDetail('local-path');
     $remote_uri = $repository->getDetail('remote-uri');
     if (!$local_path) {
         throw new Exception("No local path is available for this repository.");
     }
     while (true) {
         if (!Filesystem::pathExists($local_path)) {
             if (!$remote_uri) {
                 throw new Exception("No remote URI is available.");
             }
             execx('mkdir -p %s', dirname($local_path));
             execx('git clone %s %s', $remote_uri, rtrim($local_path, '/'));
         } else {
             execx('(cd %s && git fetch --all)', $local_path);
         }
         $this->sleep($repository->getDetail('pull-frequency', 15));
     }
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:28,代码来源:PhabricatorRepositoryGitFetchDaemon.php


示例9: executeQuery

 protected function executeQuery()
 {
     $drequest = $this->getRequest();
     $repository = $drequest->getRepository();
     $path = $drequest->getPath();
     $commit = $drequest->getCommit();
     $local_path = $repository->getDetail('local-path');
     if ($path == '') {
         // Fast path to improve the performance of the repository view; we know
         // the root is always a tree at any commit and always exists.
         $stdout = 'tree';
     } else {
         try {
             list($stdout) = execx("(cd %s && git cat-file -t %s:%s)", $local_path, $commit, $path);
         } catch (CommandException $e) {
             $stderr = $e->getStdErr();
             if (preg_match('/^fatal: Not a valid object name/', $stderr)) {
                 // Grab two logs, since the first one is when the object was deleted.
                 list($stdout) = execx('(cd %s && git log -n2 --format="%%H" %s -- %s)', $local_path, $commit, $path);
                 $stdout = trim($stdout);
                 if ($stdout) {
                     $commits = explode("\n", $stdout);
                     $this->reason = self::REASON_IS_DELETED;
                     $this->deletedAtCommit = idx($commits, 0);
                     $this->existedAtCommit = idx($commits, 1);
                     return array();
                 }
                 $this->reason = self::REASON_IS_NONEXISTENT;
                 return array();
             } else {
                 throw $e;
             }
         }
     }
     if (trim($stdout) == 'blob') {
         $this->reason = self::REASON_IS_FILE;
         return array();
     }
     if ($this->shouldOnlyTestValidity()) {
         return true;
     }
     list($stdout) = execx("(cd %s && git ls-tree -l %s:%s)", $local_path, $commit, $path);
     $results = array();
     foreach (explode("\n", rtrim($stdout)) as $line) {
         list($mode, $type, $hash, $size, $name) = preg_split('/\\s+/', $line);
         if ($type == 'tree') {
             $file_type = DifferentialChangeType::FILE_DIRECTORY;
         } else {
             $file_type = DifferentialChangeType::FILE_NORMAL;
         }
         $result = new DiffusionRepositoryPath();
         $result->setPath($name);
         $result->setHash($hash);
         $result->setFileType($file_type);
         $result->setFileSize($size);
         $results[] = $result;
     }
     return $results;
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:59,代码来源:DiffusionGitBrowseQuery.php


示例10: getVersion

 protected function getVersion()
 {
     $cmd = csprintf('%s version', $this->getBinary());
     list($stdout) = execx('%C', $cmd);
     $matches = array();
     preg_match('/^go version go(?P<version>[0-9\\.]+).*/', $stdout, $matches);
     return $matches['version'];
 }
开发者ID:kalbasit,项目名称:arcanist-go,代码行数:8,代码来源:GoTestEngine.php


示例11: getVersion

 public function getVersion()
 {
     list($stdout, $stderr) = execx('%C --version', $this->getExecutableCommand());
     $matches = null;
     if (preg_match('@HLint v(.*),@', $stdout, $matches)) {
         return $matches[1];
     }
     return null;
 }
开发者ID:ivoryxiong,项目名称:arcanist,代码行数:9,代码来源:ArcanistHLintLinter.php


示例12: destroy

 public function destroy()
 {
     PhabricatorLiskDAO::popStorageNamespace();
     // NOTE: We need to close all connections before destroying the databases.
     // If we do not, the "DROP DATABASE ..." statements may hang, waiting for
     // our connections to close.
     PhabricatorLiskDAO::closeAllConnections();
     execx('php %s destroy --force --namespace %s', $this->getStorageBinPath(), $this->name);
 }
开发者ID:AbhishekGhosh,项目名称:phabricator,代码行数:9,代码来源:PhabricatorStorageFixtureScopeGuard.php


示例13: saveToArchive

 public function saveToArchive($path)
 {
     $tmp = new TempFile();
     execx('tar -C %s -czvvf %s .', $this->getPath(), $tmp);
     $ok = rename($tmp, Filesystem::resolvePath($path));
     if (!$ok) {
         throw new FilesystemException($path, 'Failed to overwrite file.');
     }
     return $this;
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:10,代码来源:PhutilDirectoryFixture.php


示例14: generateKeypair

 public static function generateKeypair()
 {
     self::assertCanGenerateKeypair();
     $tempfile = new TempFile();
     $keyfile = dirname($tempfile) . DIRECTORY_SEPARATOR . 'keytext';
     execx('ssh-keygen -t rsa -N %s -f %s', '', $keyfile);
     $public_key = Filesystem::readFile($keyfile . '.pub');
     $private_key = Filesystem::readFile($keyfile);
     return array($public_key, $private_key);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:10,代码来源:PhabricatorSSHKeyGenerator.php


示例15: getVersion

 public function getVersion()
 {
     list($stdout) = execx('%C --version', $this->getExecutableCommand());
     $matches = array();
     if (preg_match('/^(?P<version>\\d+\\.\\d+\\.\\d+)$/', $stdout, $matches)) {
         return $matches['version'];
     } else {
         return false;
     }
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:10,代码来源:ArcanistRuboCopLinter.php


示例16: testEscapingIsRobust

 public function testEscapingIsRobust()
 {
     if (phutil_is_windows()) {
         $this->assertSkipped(pht("This test doesn't work on Windows."));
     }
     // Escaping should be robust even when used to escape commands which take
     // other commands.
     list($out) = execx('sh -c %s', csprintf('sh -c %s', csprintf('sh -c %s', csprintf('echo %P', new PhutilOpaqueEnvelope('!@#$%^&*()')))));
     $this->assertTrue(strpos($out, '!@#$%^&*()') !== false);
 }
开发者ID:pritambaral,项目名称:libphutil,代码行数:10,代码来源:PhutilCsprintfTestCase.php


示例17: getVersion

 public function getVersion()
 {
     list($stdout) = execx('%C --version', $this->getExecutableCommand());
     $matches = array();
     $regex = '/^PHP_CodeSniffer version (?P<version>\\d+\\.\\d+\\.\\d+)\\b/';
     if (preg_match($regex, $stdout, $matches)) {
         return $matches['version'];
     } else {
         return false;
     }
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:11,代码来源:ArcanistPhpcsLinter.php


示例18: getVersion

 public function getVersion()
 {
     list($stdout) = execx('%C version', $this->getExecutableCommand());
     $pattern = '/^go version go(?P<version>\\d+\\.\\d+\\.\\d+).*$/';
     $matches = array();
     if (preg_match($pattern, $stdout, $matches)) {
         return $matches['version'];
     } else {
         return false;
     }
 }
开发者ID:voznesenskym,项目名称:arcanist,代码行数:11,代码来源:ArcanistGoVetLinter.php


示例19: getVersion

 public function getVersion()
 {
     // NOTE: `jshint --version` emits version information on stderr, not stdout.
     list($stdout, $stderr) = execx('%C --version', $this->getExecutableCommand());
     $matches = array();
     $regex = '/^jshint v(?P<version>\\d+\\.\\d+\\.\\d+)$/';
     if (preg_match($regex, $stderr, $matches)) {
         return $matches['version'];
     } else {
         return false;
     }
 }
开发者ID:milindc2031,项目名称:Test,代码行数:12,代码来源:ArcanistJSHintLinter.php


示例20: executeQuery

 protected function executeQuery()
 {
     $drequest = $this->getRequest();
     $repository = $drequest->getRepository();
     list($hash) = execx("(cd %s && git log -n1 --format=%%H %s -- %s)", $repository->getDetail('local-path'), $drequest->getCommit(), $drequest->getPath());
     $hash = trim($hash);
     $commit_data = null;
     $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere('repositoryID = %d AND commitIdentifier = %s', $repository->getID(), $hash);
     if ($commit) {
         $commit_data = id(new PhabricatorRepositoryCommitData())->loadOneWhere('commitID = %d', $commit->getID());
     }
     return array($commit, $commit_data);
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:13,代码来源:DiffusionGitLastModifiedQuery.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP exequery函数代码示例发布时间:2022-05-15
下一篇:
PHP execute_sql_file函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap