本文整理汇总了PHP中phutil_passthru函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_passthru函数的具体用法?PHP phutil_passthru怎么用?PHP phutil_passthru使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phutil_passthru函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$roots = array();
$roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));
foreach ($roots as $lib => $root) {
echo "Upgrading {$lib}...\n";
if (!Filesystem::pathExists($root . '/.git')) {
throw new ArcanistUsageException("{$lib} must be in its git working copy to be automatically " . "upgraded. This copy of {$lib} (in '{$root}') is not in a git " . "working copy.");
}
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
$configuration_manager = clone $this->getConfigurationManager();
$configuration_manager->setWorkingCopyIdentity($working_copy);
$repository_api = ArcanistRepositoryAPI::newAPIFromConfigurationManager($configuration_manager);
$this->setRepositoryAPI($repository_api);
// Require no local changes.
$this->requireCleanWorkingCopy();
// Require the library be on master.
$branch_name = $repository_api->getBranchName();
if ($branch_name != 'master') {
throw new ArcanistUsageException("{$lib} must be on branch 'master' to be automatically upgraded. " . "This copy of {$lib} (in '{$root}') is on branch '{$branch_name}'.");
}
chdir($root);
try {
phutil_passthru('git pull --rebase');
} catch (Exception $ex) {
phutil_passthru('git rebase --abort');
throw $ex;
}
}
echo phutil_console_wrap(phutil_console_format("**Updated!** Your copy of arc is now up to date.\n"));
return 0;
}
示例2: run
public function run()
{
$roots = array();
$roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));
foreach ($roots as $lib => $root) {
echo "Upgrading {$lib}...\n";
if (!Filesystem::pathExists($root . '/.git')) {
throw new ArcanistUsageException("{$lib} must be in its git working copy to be automatically " . "upgraded. This copy of {$lib} (in '{$root}') is not in a git " . "working copy.");
}
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity($working_copy);
// Force the range to HEAD^..HEAD, which is meaningless but keeps us
// from triggering "base" rules or other commit range resolution rules
// that might prompt the user when we pull the working copy status.
$repository_api->setRelativeCommit('HEAD^');
$this->setRepositoryAPI($repository_api);
// Require no local changes.
$this->requireCleanWorkingCopy();
// Require the library be on master.
$branch_name = $repository_api->getBranchName();
if ($branch_name != 'master') {
throw new ArcanistUsageException("{$lib} must be on branch 'master' to be automatically upgraded. " . "This copy of {$lib} (in '{$root}') is on branch '{$branch_name}'.");
}
chdir($root);
try {
phutil_passthru('git pull --rebase');
} catch (Exception $ex) {
phutil_passthru('git rebase --abort');
throw $ex;
}
}
echo phutil_console_wrap(phutil_console_format("**Updated!** Your copy of arc is now up to date.\n"));
return 0;
}
示例3: run
public function run()
{
$roots = array('libphutil' => dirname(phutil_get_library_root('phutil')), 'arcanist' => dirname(phutil_get_library_root('arcanist')));
foreach ($roots as $lib => $root) {
echo phutil_console_format("%s\n", pht('Upgrading %s...', $lib));
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
$configuration_manager = clone $this->getConfigurationManager();
$configuration_manager->setWorkingCopyIdentity($working_copy);
$repository = ArcanistRepositoryAPI::newAPIFromConfigurationManager($configuration_manager);
if (!Filesystem::pathExists($repository->getMetadataPath())) {
throw new ArcanistUsageException(pht("%s must be in its git working copy to be automatically upgraded. " . "This copy of %s (in '%s') is not in a git working copy.", $lib, $lib, $root));
}
$this->setRepositoryAPI($repository);
// Require no local changes.
$this->requireCleanWorkingCopy();
// Require the library be on master.
$branch_name = $repository->getBranchName();
if ($branch_name != 'master') {
throw new ArcanistUsageException(pht("%s must be on branch '%s' to be automatically upgraded. " . "This copy of %s (in '%s') is on branch '%s'.", $lib, 'master', $lib, $root, $branch_name));
}
chdir($root);
try {
phutil_passthru('git pull --rebase');
} catch (Exception $ex) {
phutil_passthru('git rebase --abort');
throw $ex;
}
}
echo phutil_console_format("**%s** %s\n", pht('Updated!'), pht('Your copy of arc is now up to date.'));
return 0;
}
示例4: handleEvent
public function handleEvent(PhutilEvent $event)
{
$script = self::SCRIPT;
if (!file_exists($script)) {
throw new Exception(pht('%s does not exist.', $script));
}
if (!is_executable($script)) {
throw new Exception(pht('%s is not executable.', $script));
}
$err = phutil_passthru('%C', $script);
if ($err) {
throw new Exception(pht('%s exited with non-zero status: %d.', $script, $err));
}
}
示例5: execute
public function execute(PhutilArgumentParser $args)
{
$api = $this->getSingleAPI();
list($host, $port) = $this->getBareHostAndPort($api->getHost());
$flag_port = $port ? csprintf('--port %d', $port) : '';
$flag_password = '';
$password = $api->getPassword();
if ($password) {
if (strlen($password->openEnvelope())) {
$flag_password = csprintf('--password=%P', $password);
}
}
return phutil_passthru('mysql --protocol=TCP --default-character-set=utf8mb4 ' . '-u %s %C -h %s %C', $api->getUser(), $flag_password, $host, $flag_port);
}
示例6: execute
public function execute(PhutilArgumentParser $args)
{
$api = $this->getAPI();
$patches = $this->getPatches();
$applied = $api->getAppliedPatches();
if ($applied === null) {
$namespace = $api->getNamespace();
echo phutil_console_wrap(phutil_console_format("**No Storage**: There is no database storage initialized in this " . "storage namespace ('{$namespace}'). Use '**storage upgrade**' to " . "initialize storage.\n"));
return 1;
}
$databases = $api->getDatabaseList($patches);
list($host, $port) = $this->getBareHostAndPort($api->getHost());
$flag_password = $api->getPassword() ? csprintf('-p %s', $api->getPassword()) : '';
$flag_port = $port ? csprintf('--port %d', $port) : '';
return phutil_passthru('mysqldump --default-character-set=utf8 ' . '-u %s %C -h %s %C --databases %Ls', $api->getUser(), $flag_password, $host, $flag_port, $databases);
}
示例7: didExecute
public function didExecute(PhutilArgumentParser $args)
{
$api = $this->getAPI();
$patches = $this->getPatches();
$console = PhutilConsole::getConsole();
$applied = $api->getAppliedPatches();
if ($applied === null) {
$namespace = $api->getNamespace();
$console->writeErr(pht('**Storage Not Initialized**: There is no database storage ' . 'initialized in this storage namespace ("%s"). Use ' . '**%s** to initialize storage.', $namespace, './bin/storage upgrade'));
return 1;
}
$databases = $api->getDatabaseList($patches, true);
list($host, $port) = $this->getBareHostAndPort($api->getHost());
$has_password = false;
$password = $api->getPassword();
if ($password) {
if (strlen($password->openEnvelope())) {
$has_password = true;
}
}
$argv = array();
$argv[] = '--hex-blob';
$argv[] = '--single-transaction';
$argv[] = '--default-character-set=utf8';
if ($args->getArg('for-replica')) {
$argv[] = '--master-data';
}
$argv[] = '-u';
$argv[] = $api->getUser();
$argv[] = '-h';
$argv[] = $host;
if ($port) {
$argv[] = '--port';
$argv[] = $port;
}
$argv[] = '--databases';
foreach ($databases as $database) {
$argv[] = $database;
}
if ($has_password) {
$err = phutil_passthru('mysqldump -p%P %Ls', $password, $argv);
} else {
$err = phutil_passthru('mysqldump %Ls', $argv);
}
return $err;
}
示例8: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$console->getServer()->setEnableLog(true);
PhabricatorLDAPAuthProvider::assertLDAPExtensionInstalled();
$provider = PhabricatorLDAPAuthProvider::getLDAPProvider();
if (!$provider) {
$console->writeOut("%s\n", pht('The LDAP authentication provider is not enabled.'));
exit(1);
}
if (!function_exists('ldap_connect')) {
$console->writeOut("%s\n", pht('The LDAP extension is not enabled.'));
exit(1);
}
$adapter = $provider->getAdapter();
$console->writeOut("%s\n", pht('Enter LDAP Credentials'));
$username = phutil_console_prompt(pht('LDAP Username: '));
if (!strlen($username)) {
throw new PhutilArgumentUsageException(pht('You must enter an LDAP username.'));
}
phutil_passthru('stty -echo');
$password = phutil_console_prompt(pht('LDAP Password: '));
phutil_passthru('stty echo');
if (!strlen($password)) {
throw new PhutilArgumentUsageException(pht('You must enter an LDAP password.'));
}
$adapter->setLoginUsername($username);
$adapter->setLoginPassword(new PhutilOpaqueEnvelope($password));
$console->writeOut("\n");
$console->writeOut("%s\n", pht('Connecting to LDAP...'));
$account_id = $adapter->getAccountID();
if ($account_id) {
$console->writeOut("%s\n", pht('Found LDAP Account: %s', $account_id));
} else {
$console->writeOut("%s\n", pht('Unable to find LDAP account!'));
}
return 0;
}
示例9: run
public function run()
{
$repository_api = $this->getRepositoryAPI();
$project_root = $this->getWorkingCopy()->getProjectRoot();
$in_paths = $this->getArgument('paths');
$paths = array();
foreach ($in_paths as $key => $path) {
$full_path = Filesystem::resolvePath($path);
$paths[$key] = Filesystem::readablePath($full_path, $project_root);
}
if (!$paths) {
throw new ArcanistUsageException("Specify a path to browse");
}
$base_uri = $this->getBaseURI();
$browser = $this->getBrowserCommand();
foreach ($paths as $path) {
$ret_code = phutil_passthru("%s %s", $browser, $base_uri . $path);
if ($ret_code) {
throw new ArcanistUsageException("It seems we failed to open the browser; Perhaps you should try to " . "set the 'browser' config option. The command we tried to use was: " . $browser);
}
}
return 0;
}
示例10: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$api = $this->getAPI();
$patches = $this->getPatches();
$applied = $api->getAppliedPatches();
if ($applied === null) {
$namespace = $api->getNamespace();
$console->writeErr(pht('**Storage Not Initialized**: There is no database storage ' . 'initialized in this storage namespace ("%s"). Use ' . '**%s** to initialize storage.', $namespace, 'storage upgrade'));
return 1;
}
$databases = $api->getDatabaseList($patches, $only_living = true);
list($host, $port) = $this->getBareHostAndPort($api->getHost());
$flag_password = '';
$password = $api->getPassword();
if ($password) {
if (strlen($password->openEnvelope())) {
$flag_password = csprintf('-p%P', $password);
}
}
$flag_port = $port ? csprintf('--port %d', $port) : '';
return phutil_passthru('mysqldump --hex-blob --single-transaction --default-character-set=utf8 ' . '-u %s %C -h %s %C --databases %Ls', $api->getUser(), $flag_password, $host, $flag_port, $databases);
}
示例11: foreach
} else {
$have_optipng = true;
}
foreach ($sheets as $name => $sheet) {
$sheet->setBasePath($root);
$manifest_path = $root . '/resources/sprite/manifest/' . $name . '.json';
if (!$args->getArg('force')) {
if (Filesystem::pathExists($manifest_path)) {
$data = Filesystem::readFile($manifest_path);
$data = json_decode($data, true);
if (!$sheet->needsRegeneration($data)) {
continue;
}
}
}
$sheet->generateCSS($webroot . "/css/sprite-{$name}.css")->generateManifest($root . "/resources/sprite/manifest/{$name}.json");
foreach ($sheet->getScales() as $scale) {
if ($scale == 1) {
$sheet_name = "sprite-{$name}.png";
} else {
$sheet_name = "sprite-{$name}-X{$scale}.png";
}
$full_path = "{$webroot}/image/{$sheet_name}";
$sheet->generateImage($full_path, $scale);
if ($have_optipng) {
echo "Optimizing...\n";
phutil_passthru('optipng -o7 -clobber %s', $full_path);
}
}
}
echo "Done.\n";
示例12: launchDaemon
public function launchDaemon($daemon, array $argv, $debug = false)
{
$symbols = $this->loadAvailableDaemonClasses();
$symbols = ipull($symbols, 'name', 'name');
if (empty($symbols[$daemon])) {
throw new Exception("Daemon '{$daemon}' is not loaded, misspelled or abstract.");
}
$libphutil_root = dirname(phutil_get_library_root('phutil'));
$launch_daemon = $libphutil_root . '/scripts/daemon/';
foreach ($argv as $key => $arg) {
$argv[$key] = escapeshellarg($arg);
}
$flags = array();
if ($debug || PhabricatorEnv::getEnvConfig('phd.trace')) {
$flags[] = '--trace';
}
if ($debug || PhabricatorEnv::getEnvConfig('phd.verbose')) {
$flags[] = '--verbose';
}
if (!$debug) {
$flags[] = '--daemonize';
}
$bootloader = PhutilBootloader::getInstance();
foreach ($bootloader->getAllLibraries() as $library) {
if ($library == 'phutil') {
// No need to load libphutil, it's necessarily loaded implicitly by the
// daemon itself.
continue;
}
$flags[] = csprintf('--load-phutil-library=%s', phutil_get_library_root($library));
}
$flags[] = csprintf('--conduit-uri=%s', PhabricatorEnv::getURI('/api/'));
if (!$debug) {
$log_file = $this->getLogDirectory() . '/daemons.log';
$flags[] = csprintf('--log=%s', $log_file);
}
$pid_dir = $this->getPIDDirectory();
// TODO: This should be a much better user experience.
Filesystem::assertExists($pid_dir);
Filesystem::assertIsDirectory($pid_dir);
Filesystem::assertWritable($pid_dir);
$flags[] = csprintf('--phd=%s', $pid_dir);
$command = csprintf('./launch_daemon.php %s %C %C', $daemon, implode(' ', $flags), implode(' ', $argv));
if ($debug) {
// Don't terminate when the user sends ^C; it will be sent to the
// subprocess which will terminate normally.
pcntl_signal(SIGINT, array('PhabricatorDaemonControl', 'ignoreSignal'));
echo "\n libphutil/scripts/daemon/ \$ {$command}\n\n";
phutil_passthru('(cd %s && exec %C)', $launch_daemon, $command);
} else {
$future = new ExecFuture('exec %C', $command);
// Play games to keep 'ps' looking reasonable.
$future->setCWD($launch_daemon);
$future->resolvex();
}
}
示例13: phutil_console_prompt
$email = phutil_console_prompt(pht('Enter user email address:'));
$duplicate = id(new PhabricatorUserEmail())->loadOneWhere('address = %s', $email);
if ($duplicate) {
echo pht("ERROR: There is already a user with that email address. " . "Each user must have a unique email address.\n");
} else {
break;
}
} while (true);
$create_email = $email;
}
$changed_pass = false;
// This disables local echo, so the user's password is not shown as they type
// it.
phutil_passthru('stty -echo');
$password = phutil_console_prompt(pht('Enter a password for this user [blank to leave unchanged]:'));
phutil_passthru('stty echo');
if (strlen($password)) {
$changed_pass = $password;
}
$is_system_agent = $user->getIsSystemAgent();
$set_system_agent = phutil_console_confirm(pht('Is this user a bot?'), $default_no = !$is_system_agent);
$verify_email = null;
$set_verified = false;
// Allow administrators to verify primary email addresses at this time in edit
// scenarios. (Create will work just fine from here as we auto-verify email
// on create.)
if (!$is_new) {
$verify_email = $user->loadPrimaryEmail();
if (!$verify_email->getIsVerified()) {
$set_verified = phutil_console_confirm(pht('Should the primary email address be verified?'), $default_no = true);
} else {
示例14: selectWorkflow
public final function selectWorkflow(&$command, array &$args, ArcanistConfigurationManager $configuration_manager, PhutilConsole $console)
{
// First, try to build a workflow with the exact name provided. We always
// pick an exact match, and do not allow aliases to override it.
$workflow = $this->buildWorkflow($command);
if ($workflow) {
return $workflow;
}
// If the user has an alias, like 'arc alias dhelp diff help', look it up
// and substitute it. We do this only after trying to resolve the workflow
// normally to prevent you from doing silly things like aliasing 'alias'
// to something else.
$aliases = ArcanistAliasWorkflow::getAliases($configuration_manager);
list($new_command, $args) = ArcanistAliasWorkflow::resolveAliases($command, $this, $args, $configuration_manager);
$full_alias = idx($aliases, $command, array());
$full_alias = implode(' ', $full_alias);
// Run shell command aliases.
if (ArcanistAliasWorkflow::isShellCommandAlias($new_command)) {
$shell_cmd = substr($full_alias, 1);
$console->writeLog("[%s: 'arc %s' -> \$ %s]", pht('alias'), $command, $shell_cmd);
if ($args) {
$err = phutil_passthru('%C %Ls', $shell_cmd, $args);
} else {
$err = phutil_passthru('%C', $shell_cmd);
}
exit($err);
}
// Run arc command aliases.
if ($new_command) {
$workflow = $this->buildWorkflow($new_command);
if ($workflow) {
$console->writeLog("[%s: 'arc %s' -> 'arc %s']\n", pht('alias'), $command, $full_alias);
$command = $new_command;
return $workflow;
}
}
$all = array_keys($this->buildAllWorkflows());
// We haven't found a real command or an alias, so try to locate a command
// by unique prefix.
$prefixes = $this->expandCommandPrefix($command, $all);
if (count($prefixes) == 1) {
$command = head($prefixes);
return $this->buildWorkflow($command);
} else {
if (count($prefixes) > 1) {
$this->raiseUnknownCommand($command, $prefixes);
}
}
// We haven't found a real command, alias, or unique prefix. Try similar
// spellings.
$corrected = self::correctCommandSpelling($command, $all, 2);
if (count($corrected) == 1) {
$console->writeErr(pht("(Assuming '%s' is the British spelling of '%s'.)", $command, head($corrected)) . "\n");
$command = head($corrected);
return $this->buildWorkflow($command);
} else {
if (count($corrected) > 1) {
$this->raiseUnknownCommand($command, $corrected);
}
}
$this->raiseUnknownCommand($command);
}
示例15: push
private function push()
{
$repository_api = $this->getRepositoryAPI();
if ($this->isGit) {
$repository_api->execxLocal('commit -F %s', $this->messageFile);
} else {
if ($this->isHg) {
// hg rebase produces a commit earlier as part of rebase
if (!$this->useSquash) {
$repository_api->execxLocal('commit --logfile %s', $this->messageFile);
}
}
}
// We dispatch this event so we can run checks on the merged revision, right
// before it gets pushed out. It's easier to do this in arc land than to
// try to hook into git/hg.
try {
$this->dispatchEvent(ArcanistEventType::TYPE_LAND_WILLPUSHREVISION, array());
} catch (Exception $ex) {
$this->executeCleanupAfterFailedPush();
throw $ex;
}
if ($this->getArgument('hold')) {
echo phutil_console_format("Holding change in **%s**: it has NOT been pushed yet.\n", $this->onto);
} else {
echo "Pushing change...\n\n";
chdir($repository_api->getPath());
if ($this->isGitSvn) {
$err = phutil_passthru('git svn dcommit');
$cmd = "git svn dcommit";
} else {
if ($this->isGit) {
$err = phutil_passthru('git push %s %s', $this->remote, $this->onto);
$cmd = "git push";
} else {
if ($this->isHgSvn) {
// hg-svn doesn't support 'push -r', so we do a normal push
// which hg-svn modifies to only push the current branch and
// ancestors.
$err = $repository_api->execPassthru('push %s', $this->remote);
$cmd = "hg push";
} else {
if ($this->isHg) {
$err = $repository_api->execPassthru('push -r %s %s', $this->onto, $this->remote);
$cmd = "hg push";
}
}
}
}
if ($err) {
echo phutil_console_format("<bg:red>** PUSH FAILED! **</bg>\n");
$this->executeCleanupAfterFailedPush();
if ($this->isGit) {
throw new ArcanistUsageException("'{$cmd}' failed! Fix the error and run 'arc land' again.");
}
throw new ArcanistUsageException("'{$cmd}' failed! Fix the error and push this change manually.");
}
$mark_workflow = $this->buildChildWorkflow('close-revision', array('--finalize', '--quiet', $this->revision['id']));
$mark_workflow->run();
echo "\n";
}
}