本文整理汇总了PHP中Filesystem::binaryExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::binaryExists方法的具体用法?PHP Filesystem::binaryExists怎么用?PHP Filesystem::binaryExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::binaryExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkBinaryConfiguration
protected function checkBinaryConfiguration()
{
$binary = $this->getBinary();
if (!Filesystem::binaryExists($binary)) {
throw new ArcanistMissingLinterException(sprintf("%s\n%s", pht('Unable to locate binary "%s" to run linter %s. You may need ' . 'to install the binary, or adjust your linter configuration.', $binary, get_class($this)), pht('TO INSTALL: %s', $this->getInstallInstructions())));
}
}
示例2: executeChecks
protected function executeChecks()
{
if (phutil_is_windows()) {
$bin_name = 'where';
} else {
$bin_name = 'which';
}
if (!Filesystem::binaryExists($bin_name)) {
$message = pht("Without '%s', Phabricator can not test for the availability " . "of other binaries.", $bin_name);
$this->raiseWarning($bin_name, $message);
// We need to return here if we can't find the 'which' / 'where' binary
// because the other tests won't be valid.
return;
}
if (!Filesystem::binaryExists('diff')) {
$message = pht("Without 'diff', Phabricator will not be able to generate or render " . "diffs in multiple applications.");
$this->raiseWarning('diff', $message);
} else {
$tmp_a = new TempFile();
$tmp_b = new TempFile();
$tmp_c = new TempFile();
Filesystem::writeFile($tmp_a, 'A');
Filesystem::writeFile($tmp_b, 'A');
Filesystem::writeFile($tmp_c, 'B');
list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_b);
if ($err) {
$this->newIssue('bin.diff.same')->setName(pht("Unexpected 'diff' Behavior"))->setMessage(pht("The 'diff' binary on this system has unexpected behavior: " . "it was expected to exit without an error code when passed " . "identical files, but exited with code %d.", $err));
}
list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_c);
if (!$err) {
$this->newIssue('bin.diff.diff')->setName(pht("Unexpected 'diff' Behavior"))->setMessage(pht("The 'diff' binary on this system has unexpected behavior: " . "it was expected to exit with a nonzero error code when passed " . "differing files, but did not."));
}
}
$table = new PhabricatorRepository();
$vcses = queryfx_all($table->establishConnection('r'), 'SELECT DISTINCT versionControlSystem FROM %T', $table->getTableName());
foreach ($vcses as $vcs) {
switch ($vcs['versionControlSystem']) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$binary = 'git';
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$binary = 'svn';
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$binary = 'hg';
break;
default:
$binary = null;
break;
}
if (!$binary) {
continue;
}
if (!Filesystem::binaryExists($binary)) {
$message = pht('You have at least one repository configured which uses this ' . 'version control system. It will not work without the VCS binary.');
$this->raiseWarning($binary, $message);
}
}
}
示例3: testSvnStateParsing
public function testSvnStateParsing()
{
if (Filesystem::binaryExists('svn')) {
$this->parseState('svn_basic.svn.tgz');
} else {
$this->assertSkipped(pht('Subversion is not installed'));
}
}
示例4: executeChecks
protected function executeChecks()
{
$imagemagick = PhabricatorEnv::getEnvConfig('files.enable-imagemagick');
if ($imagemagick) {
if (!Filesystem::binaryExists('convert')) {
$message = pht("You have enabled Imagemagick in your config, but the '%s' " . "binary is not in the webserver's %s. Disable imagemagick " . "or make it available to the webserver.", 'convert', '$PATH');
$this->newIssue('files.enable-imagemagick')->setName(pht("'%s' binary not found or Imagemagick is not installed.", 'convert'))->setMessage($message)->addRelatedPhabricatorConfig('files.enable-imagemagick')->addPhabricatorConfig('environment.append-paths');
}
}
}
示例5: testBinaryExists
public function testBinaryExists()
{
// Test for the `which` binary on Linux, and the `where` binary on Windows,
// because `which which` is cute.
if (phutil_is_windows()) {
$exists = 'where';
} else {
$exists = 'which';
}
$this->assertEqual(true, Filesystem::binaryExists($exists));
// We don't expect to find this binary on any system.
$this->assertEqual(false, Filesystem::binaryExists('halting-problem-decider'));
}
示例6: getDefaultBinary
public function getDefaultBinary()
{
$binary = 'go';
if (Filesystem::binaryExists($binary)) {
// Vet is only accessible through 'go vet' or 'go tool vet'
// Let's manually try to find out if it's installed.
list($err, $stdout, $stderr) = exec_manual('go tool vet');
if ($err === 3) {
throw new ArcanistMissingLinterException(sprintf("%s\n%s", pht('Unable to locate "go vet" to run linter %s. You may need ' . 'to install the binary, or adjust your linter configuration.', get_class($this)), pht('TO INSTALL: %s', $this->getInstallInstructions())));
}
}
return $binary;
}
示例7: 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;
}
示例8: decryptSecret
public function decryptSecret(PhutilOpaqueEnvelope $secret, PhutilOpaqueEnvelope $password)
{
$tmp = new TempFile();
Filesystem::writeFile($tmp, $secret->openEnvelope());
if (!Filesystem::binaryExists('ssh-keygen')) {
throw new Exception(pht('Decrypting SSH keys requires the `ssh-keygen` binary, but it ' . 'is not available in PATH. Either make it available or strip the ' . 'password fromt his SSH key manually before uploading it.'));
}
list($err, $stdout, $stderr) = exec_manual('ssh-keygen -p -P %P -N %s -f %s', $password, '', (string) $tmp);
if ($err) {
return null;
} else {
return new PhutilOpaqueEnvelope(Filesystem::readFile($tmp));
}
}
示例9: getDefaultBinary
public function getDefaultBinary()
{
if (Filesystem::binaryExists('pep8')) {
return 'pep8';
}
$old_prefix = $this->getDeprecatedConfiguration('lint.pep8.prefix');
$old_bin = $this->getDeprecatedConfiguration('lint.pep8.bin');
if ($old_prefix || $old_bin) {
$old_bin = nonempty($old_bin, 'pep8');
return $old_prefix . '/' . $old_bin;
}
$arc_root = dirname(phutil_get_library_root('arcanist'));
return $arc_root . '/externals/pep8/pep8.py';
}
示例10: getSystemMemoryInformation
/**
* Get information about total and free memory on the system.
*
* Because "free memory" is a murky concept, the interpretation of the values
* returned from this method will vary from system to system and the numbers
* themselves may be only roughly accurate.
*
* @return map<string, wild> Dictionary of memory information.
* @task memory
*/
public static function getSystemMemoryInformation()
{
$meminfo_path = '/proc/meminfo';
if (Filesystem::pathExists($meminfo_path)) {
$meminfo_data = Filesystem::readFile($meminfo_path);
return self::parseMemInfo($meminfo_data);
} else {
if (Filesystem::binaryExists('vm_stat')) {
list($vm_stat_stdout) = execx('vm_stat');
return self::parseVMStat($vm_stat_stdout);
} else {
throw new Exception(pht('Unable to access %s or `%s` on this system to ' . 'get system memory information.', '/proc/meminfo', 'vm_stat'));
}
}
}
示例11: markupContent
public function markupContent($content, array $argv)
{
if (!Filesystem::binaryExists('dot')) {
return $this->markupError(pht('Unable to locate the `%s` binary. Install Graphviz.', 'dot'));
}
$width = $this->parseDimension(idx($argv, 'width'));
$future = id(new ExecFuture('dot -T%s', 'png'))->setTimeout(15)->write(trim($content));
list($err, $stdout, $stderr) = $future->resolve();
if ($err) {
return $this->markupError(pht('Execution of `%s` failed (#%d), check your syntax: %s', 'dot', $err, $stderr));
}
$file = PhabricatorFile::buildFromFileDataOrHash($stdout, array('name' => 'graphviz.png'));
if ($this->getEngine()->isTextMode()) {
return '<' . $file->getBestURI() . '>';
}
return phutil_tag('img', array('src' => $file->getBestURI(), 'width' => nonempty($width, null)));
}
示例12: markupContent
public function markupContent($content, array $argv)
{
if (!Filesystem::binaryExists('figlet')) {
return $this->markupError(pht('Unable to locate the `%s` binary. Install figlet.', 'figlet'));
}
$font = idx($argv, 'font', 'standard');
$safe_font = preg_replace('/[^0-9a-zA-Z-_.]/', '', $font);
$future = id(new ExecFuture('figlet -f %s', $safe_font))->setTimeout(15)->write(trim($content, "\n"));
list($err, $stdout, $stderr) = $future->resolve();
if ($err) {
return $this->markupError(pht('Execution of `%s` failed: %s', 'figlet', $stderr));
}
if ($this->getEngine()->isTextMode()) {
return $stdout;
}
return phutil_tag('div', array('class' => 'PhabricatorMonospaced remarkup-figlet'), $stdout);
}
示例13: build
/**
* Builds XHPAST automatically.
*
* Attempts to build the XHPAST binary automatically.
*
* @return void
*/
public static function build()
{
if (Filesystem::binaryExists('gmake')) {
$command = 'gmake';
} else {
$command = 'make';
}
$root = phutil_get_library_root('phutil');
$path = Filesystem::resolvePath($root . '/../support/xhpast');
// Run the build.
execx('%s -C %s %Ls', $command, $path, array('clean', 'all', 'install'));
// Test the binary.
if (!self::isAvailable()) {
throw new Exception(pht('%s is broken.', 'xhpast'));
}
self::$version = null;
}
示例14: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$root = dirname(__FILE__) . '/../../../..';
if (!Filesystem::binaryExists('mxmlc')) {
throw new PhutilArgumentUsageException(pht("The `mxmlc` binary was not found in PATH. This compiler binary " . "is required to rebuild the Aphlict client.\n\n" . "Adjust your PATH, or install the Flex SDK from:\n\n" . " http://flex.apache.org\n\n" . "You may also be able to install it with `npm`:\n\n" . " \$ npm install flex-sdk\n\n" . "(Note: you should only need to rebuild Aphlict if you are " . "developing Phabricator.)"));
}
$argv = array("-source-path={$root}/externals/vegas/src", '-static-link-runtime-shared-libraries=true', '-warnings=true', '-strict=true');
if ($args->getArg('debug')) {
$argv[] = '-debug=true';
}
list($err, $stdout, $stderr) = exec_manual('mxmlc %Ls -output=%s %s', $argv, $root . '/webroot/rsrc/swf/aphlict.swf', $root . '/support/aphlict/client/src/AphlictClient.as');
if ($err) {
$console->writeErr($stderr);
return 1;
}
$console->writeOut("Done.\n");
return 0;
}
示例15: loadEnvironment
/**
* Determines what executables and test paths to use. Between platforms this
* also changes whether the test engine is run under .NET or Mono. It also
* ensures that all of the required binaries are available for the tests to
* run successfully.
*
* @return void
*/
protected function loadEnvironment()
{
$this->projectRoot = $this->getWorkingCopy()->getProjectRoot();
// Determine build engine.
if (Filesystem::binaryExists('msbuild')) {
$this->buildEngine = 'msbuild';
} else {
if (Filesystem::binaryExists('xbuild')) {
$this->buildEngine = 'xbuild';
} else {
throw new Exception('Unable to find msbuild or xbuild in PATH!');
}
}
// Determine runtime engine (.NET or Mono).
if (phutil_is_windows()) {
$this->runtimeEngine = '';
} else {
if (Filesystem::binaryExists('mono')) {
$this->runtimeEngine = Filesystem::resolveBinary('mono');
} else {
throw new Exception('Unable to find Mono and you are not on Windows!');
}
}
// Read the discovery rules.
$this->discoveryRules = $this->getConfigurationManager()->getConfigFromAnySource('unit.csharp.discovery');
if ($this->discoveryRules === null) {
throw new Exception('You must configure discovery rules to map C# files ' . 'back to test projects (`unit.csharp.discovery` in .arcconfig).');
}
// Determine xUnit test runner path.
if ($this->xunitHintPath === null) {
$this->xunitHintPath = $this->getConfigurationManager()->getConfigFromAnySource('unit.csharp.xunit.binary');
}
$xunit = $this->projectRoot . DIRECTORY_SEPARATOR . $this->xunitHintPath;
if (file_exists($xunit) && $this->xunitHintPath !== null) {
$this->testEngine = Filesystem::resolvePath($xunit);
} else {
if (Filesystem::binaryExists('xunit.console.clr4.exe')) {
$this->testEngine = 'xunit.console.clr4.exe';
} else {
throw new Exception("Unable to locate xUnit console runner. Configure " . "it with the `unit.csharp.xunit.binary' option in .arcconfig");
}
}
}