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


PHP tsprintf函数代码示例

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


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

示例1: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $resource_type = $args->getArg('type');
     if (!$resource_type) {
         throw new PhutilArgumentUsageException(pht('Specify a resource type with `%s`.', '--type'));
     }
     $until = $args->getArg('until');
     if (strlen($until)) {
         $until = strtotime($until);
         if ($until <= 0) {
             throw new PhutilArgumentUsageException(pht('Unable to parse argument to "%s".', '--until'));
         }
     }
     $attributes = $args->getArg('attributes');
     if ($attributes) {
         $options = new PhutilSimpleOptions();
         $options->setCaseSensitive(true);
         $attributes = $options->parse($attributes);
     }
     $lease = id(new DrydockLease())->setResourceType($resource_type);
     if ($attributes) {
         $lease->setAttributes($attributes);
     }
     if ($until) {
         $lease->setUntil($until);
     }
     $lease->queueForActivation();
     echo tsprintf("%s\n", pht('Waiting for daemons to activate lease...'));
     $lease->waitUntilActive();
     echo tsprintf("%s\n", pht('Activated lease "%s".', $lease->getID()));
     return 0;
 }
开发者ID:remxcode,项目名称:phabricator,代码行数:33,代码来源:DrydockManagementLeaseWorkflow.php

示例2: run

 public function run()
 {
     static $color_map = array('Closed' => 'cyan', 'Needs Review' => 'magenta', 'Needs Revision' => 'red', 'Changes Planned' => 'red', 'Accepted' => 'green', 'No Revision' => 'blue', 'Abandoned' => 'default');
     $revisions = $this->getConduit()->callMethodSynchronous('differential.query', array('authors' => array($this->getUserPHID()), 'status' => 'status-open'));
     if (!$revisions) {
         echo pht('You have no open Differential revisions.') . "\n";
         return 0;
     }
     $repository_api = $this->getRepositoryAPI();
     $info = array();
     foreach ($revisions as $key => $revision) {
         $revision_path = Filesystem::resolvePath($revision['sourcePath']);
         $current_path = Filesystem::resolvePath($repository_api->getPath());
         if ($revision_path == $current_path) {
             $info[$key]['exists'] = 1;
         } else {
             $info[$key]['exists'] = 0;
         }
         $info[$key]['sort'] = sprintf('%d%04d%08d', $info[$key]['exists'], $revision['status'], $revision['id']);
         $info[$key]['statusName'] = $revision['statusName'];
         $info[$key]['color'] = idx($color_map, $revision['statusName'], 'default');
     }
     $table = id(new PhutilConsoleTable())->setShowHeader(false)->addColumn('exists', array('title' => ''))->addColumn('status', array('title' => pht('Status')))->addColumn('title', array('title' => pht('Title')));
     $info = isort($info, 'sort');
     foreach ($info as $key => $spec) {
         $revision = $revisions[$key];
         $table->addRow(array('exists' => $spec['exists'] ? tsprintf('**%s**', '*') : '', 'status' => tsprintf("<fg:{$spec['color']}>%s</fg>", $spec['statusName']), 'title' => tsprintf('**D%d:** %s', $revision['id'], $revision['title'])));
     }
     $table->draw();
     return 0;
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:31,代码来源:ArcanistListWorkflow.php

示例3: execute

 public function execute(PhutilArgumentParser $args)
 {
     $source = $this->loadSource($args, 'source');
     $definition = $source->getDefinition()->setViewer($this->getViewer())->setSource($source);
     if (!$definition->hasImportCursors()) {
         throw new PhutilArgumentUsageException(pht('This source ("%s") does not expose import cursors.', $source->getName()));
     }
     $cursors = $definition->getImportCursors();
     if (!$cursors) {
         throw new PhutilArgumentUsageException(pht('This source ("%s") does not have any import cursors.', $source->getName()));
     }
     $select = $args->getArg('cursor');
     if (strlen($select)) {
         if (empty($cursors[$select])) {
             throw new PhutilArgumentUsageException(pht('This source ("%s") does not have a "%s" cursor. Available ' . 'cursors: %s.', $source->getName(), $select, implode(', ', array_keys($cursors))));
         } else {
             echo tsprintf("%s\n", pht('Importing cursor "%s" only.', $select));
             $cursors = array_select_keys($cursors, array($select));
         }
     } else {
         echo tsprintf("%s\n", pht('Importing all cursors: %s.', implode(', ', array_keys($cursors))));
         echo tsprintf("%s\n", pht('(Use --cursor to import only a particular cursor.)'));
     }
     foreach ($cursors as $cursor) {
         $cursor->importFromSource();
     }
     return 0;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:28,代码来源:NuanceManagementImportWorkflow.php

示例4: execute

 public function execute(PhutilArgumentParser $args)
 {
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht('Specify one or more lease IDs to release with "%s".', '--id'));
     }
     $viewer = $this->getViewer();
     $drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
     $leases = id(new DrydockLeaseQuery())->setViewer($viewer)->withIDs($ids)->execute();
     PhabricatorWorker::setRunAllTasksInProcess(true);
     foreach ($ids as $id) {
         $lease = idx($leases, $id);
         if (!$lease) {
             echo tsprintf("%s\n", pht('Lease "%s" does not exist.', $id));
             continue;
         }
         if (!$lease->canRelease()) {
             echo tsprintf("%s\n", pht('Lease "%s" is not releasable.', $id));
             continue;
         }
         $command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($lease->getPHID())->setAuthorPHID($drydock_phid)->setCommand(DrydockCommand::COMMAND_RELEASE)->save();
         $lease->scheduleUpdate();
         echo tsprintf("%s\n", pht('Scheduled release of lease "%s".', $id));
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:DrydockManagementReleaseLeaseWorkflow.php

示例5: markReachable

 private function markReachable(PhabricatorRepository $repository)
 {
     if (!$repository->isGit()) {
         throw new PhutilArgumentUsageException(pht('Only Git repositories are supported, this repository ("%s") is ' . 'not a Git repository.', $repository->getDisplayName()));
     }
     $viewer = $this->getViewer();
     $commits = id(new DiffusionCommitQuery())->setViewer($viewer)->withRepository($repository)->execute();
     $flag = PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE;
     $graph = new PhabricatorGitGraphStream($repository);
     foreach ($commits as $commit) {
         $identifier = $commit->getCommitIdentifier();
         try {
             $graph->getCommitDate($identifier);
             $unreachable = false;
         } catch (Exception $ex) {
             $unreachable = true;
         }
         // The commit has proper reachability, so do nothing.
         if ($commit->isUnreachable() === $unreachable) {
             $this->untouchedCount++;
             continue;
         }
         if ($unreachable) {
             echo tsprintf("%s: %s\n", $commit->getMonogram(), pht('Marking commit unreachable.'));
             $commit->writeImportStatusFlag($flag);
         } else {
             echo tsprintf("%s: %s\n", $commit->getMonogram(), pht('Marking commit reachable.'));
             $commit->clearImportStatusFlag($flag);
         }
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:PhabricatorRepositoryManagementMarkReachableWorkflow.php

示例6: execute

 public function execute(PhutilArgumentParser $args)
 {
     $viewer = $this->getViewer();
     $argv = $args->getArg('argv');
     if (count($argv) !== 2) {
         throw new PhutilArgumentUsageException(pht('Specify a commit and a revision to attach it to.'));
     }
     $commit_name = head($argv);
     $revision_name = last($argv);
     $commit = id(new DiffusionCommitQuery())->setViewer($viewer)->withIdentifiers(array($commit_name))->executeOne();
     if (!$commit) {
         throw new PhutilArgumentUsageException(pht('Commit "%s" does not exist.', $commit_name));
     }
     $revision = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames(array($revision_name))->executeOne();
     if (!$revision) {
         throw new PhutilArgumentUsageException(pht('Revision "%s" does not exist.', $revision_name));
     }
     if (!$revision instanceof DifferentialRevision) {
         throw new PhutilArgumentUsageException(pht('Object "%s" must be a Differential revision.', $revision_name));
     }
     // Reload the revision to get the active diff.
     $revision = id(new DifferentialRevisionQuery())->setViewer($viewer)->withIDs(array($revision->getID()))->needActiveDiffs(true)->executeOne();
     $differential_phid = id(new PhabricatorDifferentialApplication())->getPHID();
     $extraction_engine = id(new DifferentialDiffExtractionEngine())->setViewer($viewer)->setAuthorPHID($differential_phid);
     $content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONSOLE, array());
     $extraction_engine->updateRevisionWithCommit($revision, $commit, array(), $content_source);
     echo tsprintf("%s\n", pht('Attached "%s" to "%s".', $commit->getMonogram(), $revision->getMonogram()));
 }
开发者ID:truSense,项目名称:phabricator,代码行数:28,代码来源:PhabricatorDifferentialAttachCommitWorkflow.php

示例7: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $tasks = $this->loadTasks($args);
     foreach ($tasks as $task) {
         $can_execute = !$task->isArchived();
         if (!$can_execute) {
             $console->writeOut("**<bg:yellow> %s </bg>** %s\n", pht('ARCHIVED'), pht('%s is already archived, and can not be executed.', $this->describeTask($task)));
             continue;
         }
         // NOTE: This ignores leases, maybe it should respect them without
         // a parameter like --force?
         $task->setLeaseOwner(null);
         $task->setLeaseExpires(PhabricatorTime::getNow());
         $task->save();
         $task_data = id(new PhabricatorWorkerTaskData())->loadOneWhere('id = %d', $task->getDataID());
         $task->setData($task_data->getData());
         echo tsprintf("%s\n", pht('Executing task %d (%s)...', $task->getID(), $task->getTaskClass()));
         $task = $task->executeTask();
         $ex = $task->getExecutionException();
         if ($ex) {
             throw $ex;
         }
     }
     return 0;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:26,代码来源:PhabricatorWorkerManagementExecuteWorkflow.php

示例8: testTsprintf

 public function testTsprintf()
 {
     $this->assertEqual('<NUL>', (string) tsprintf('%s', ""));
     $this->assertEqual('<ESC>[31mred<ESC>[39m', (string) tsprintf('%s', "[31mred[39m"));
     $block = "1\r\n2\r3\n4";
     $this->assertEqual('1<CR><LF>2<CR>3<LF>4', (string) tsprintf('%s', $block));
     $this->assertEqual("1\r\n2<CR>3\n4", (string) tsprintf('%B', $block));
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:8,代码来源:PhutilTsprintfTestCase.php

示例9: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $repos = id(new PhabricatorRepositoryQuery())->setViewer($this->getViewer())->execute();
     if (!$repos) {
         $console->writeErr("%s\n", pht('There are no repositories.'));
         return 0;
     }
     $from = $args->getArg('from');
     if (!strlen($from)) {
         throw new Exception(pht('You must specify a path prefix to move from with --from.'));
     }
     $to = $args->getArg('to');
     if (!strlen($to)) {
         throw new Exception(pht('You must specify a path prefix to move to with --to.'));
     }
     $is_force = $args->getArg('force');
     $rows = array();
     $any_changes = false;
     foreach ($repos as $repo) {
         $src = $repo->getLocalPath();
         $row = array('repository' => $repo, 'move' => false, 'monogram' => $repo->getMonogram(), 'src' => $src, 'dst' => '');
         if (strncmp($src, $from, strlen($from))) {
             $row['action'] = pht('Ignore');
         } else {
             $dst = $to . substr($src, strlen($from));
             $row['action'] = tsprintf('**%s**', pht('Move'));
             $row['dst'] = $dst;
             $row['move'] = true;
             $any_changes = true;
         }
         $rows[] = $row;
     }
     $table = id(new PhutilConsoleTable())->addColumn('action', array('title' => pht('Action')))->addColumn('monogram', array('title' => pht('Repository')))->addColumn('src', array('title' => pht('Src')))->addColumn('dst', array('title' => pht('Dst')))->setBorders(true);
     foreach ($rows as $row) {
         $display = array_select_keys($row, array('action', 'monogram', 'src', 'dst'));
         $table->addRow($display);
     }
     $table->draw();
     if (!$any_changes) {
         $console->writeOut(pht('No matching repositories.') . "\n");
         return 0;
     }
     $prompt = pht('Apply these changes?');
     if (!$is_force && !phutil_console_confirm($prompt)) {
         throw new Exception(pht('Declining to apply changes.'));
     }
     foreach ($rows as $row) {
         if (empty($row['move'])) {
             continue;
         }
         $repo = $row['repository'];
         queryfx($repo->establishConnection('w'), 'UPDATE %T SET localPath = %s WHERE id = %d', $repo->getTableName(), $row['dst'], $repo->getID());
     }
     $console->writeOut(pht('Applied changes.') . "\n");
     return 0;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:57,代码来源:PhabricatorRepositoryManagementMovePathsWorkflow.php

示例10: printStats

 private function printStats(array $old_stats, array $new_stats)
 {
     echo tsprintf("    %s\n", pht('%s: %s -> %s', pht('Stored Bytes'), new PhutilNumber($old_stats['bytes']), new PhutilNumber($new_stats['bytes'])));
     echo tsprintf("    %s\n", pht('%s: %s -> %s', pht('Stored Chunks'), new PhutilNumber($old_stats['chunks']), new PhutilNumber($new_stats['chunks'])));
     echo tsprintf("    %s\n", pht('%s: %s -> %s', pht('Data Hash'), $old_stats['hash'], $new_stats['hash']));
     if ($old_stats['hash'] !== $new_stats['hash']) {
         throw new Exception(pht('Log data hashes differ! Something is tragically wrong!'));
     }
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:9,代码来源:HarbormasterManagementArchiveLogsWorkflow.php

示例11: execute

 public function execute(PhutilArgumentParser $args)
 {
     $iterator = $this->buildIterator($args);
     if (!$iterator) {
         throw new PhutilArgumentUsageException(pht('Either specify a list of files to encode, or use --all to ' . 'encode all files.'));
     }
     $force = (bool) $args->getArg('force');
     $format_list = PhabricatorFileStorageFormat::getAllFormats();
     $format_list = array_keys($format_list);
     $format_list = implode(', ', $format_list);
     $format_key = $args->getArg('as');
     if (!strlen($format_key)) {
         throw new PhutilArgumentUsageException(pht('Use --as <format> to select a target encoding format. Available ' . 'formats are: %s.', $format_list));
     }
     $format = PhabricatorFileStorageFormat::getFormat($format_key);
     if (!$format) {
         throw new PhutilArgumentUsageException(pht('Storage format "%s" is not valid. Available formats are: %s.', $format_key, $format_list));
     }
     $key_name = $args->getArg('key');
     if (strlen($key_name)) {
         $format->selectMasterKey($key_name);
     }
     $engines = PhabricatorFileStorageEngine::loadAllEngines();
     $failed = array();
     foreach ($iterator as $file) {
         $monogram = $file->getMonogram();
         $engine_key = $file->getStorageEngine();
         $engine = idx($engines, $engine_key);
         if (!$engine) {
             echo tsprintf("%s\n", pht('%s: Uses unknown storage engine "%s".', $monogram, $engine_key));
             $failed[] = $file;
             continue;
         }
         if ($engine->isChunkEngine()) {
             echo tsprintf("%s\n", pht('%s: Stored as chunks, no data to encode directly.', $monogram));
             continue;
         }
         if ($file->getStorageFormat() == $format_key && !$force) {
             echo tsprintf("%s\n", pht('%s: Already encoded in target format.', $monogram));
             continue;
         }
         echo tsprintf("%s\n", pht('%s: Changing encoding from "%s" to "%s".', $monogram, $file->getStorageFormat(), $format_key));
         try {
             $file->migrateToStorageFormat($format);
             echo tsprintf("%s\n", pht('Done.'));
         } catch (Exception $ex) {
             echo tsprintf("%B\n", pht('Failed! %s', (string) $ex));
             $failed[] = $file;
         }
     }
     if ($failed) {
         $monograms = mpull($failed, 'getMonogram');
         echo tsprintf("%s\n", pht('Failures: %s.', implode(', ', $monograms)));
         return 1;
     }
     return 0;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:57,代码来源:PhabricatorFilesManagementEncodeWorkflow.php

示例12: execute

 public function execute(PhutilArgumentParser $args)
 {
     $key = $args->getArg('key');
     if (!strlen($key)) {
         throw new PhutilArgumentUsageException(pht('Specify an AWS S3 object key to access with --key.'));
     }
     $future = $this->newAWSFuture(new PhutilAWSS3Future())->setParametersForDeleteObject($key);
     $future->resolve();
     echo tsprintf("%s\n", pht('Deleted "%s".', $key));
     return 0;
 }
开发者ID:WilkGardariki,项目名称:libphutil,代码行数:11,代码来源:PhutilAWSS3DeleteManagementWorkflow.php

示例13: execute

 public function execute(PhutilArgumentParser $args)
 {
     $iterator = $this->buildIterator($args);
     if (!$iterator) {
         throw new PhutilArgumentUsageException(pht('Either specify a list of files to cycle, or use --all to cycle ' . 'all files.'));
     }
     $format_map = PhabricatorFileStorageFormat::getAllFormats();
     $engines = PhabricatorFileStorageEngine::loadAllEngines();
     $key_name = $args->getArg('key');
     $failed = array();
     foreach ($iterator as $file) {
         $monogram = $file->getMonogram();
         $engine_key = $file->getStorageEngine();
         $engine = idx($engines, $engine_key);
         if (!$engine) {
             echo tsprintf("%s\n", pht('%s: Uses unknown storage engine "%s".', $monogram, $engine_key));
             $failed[] = $file;
             continue;
         }
         if ($engine->isChunkEngine()) {
             echo tsprintf("%s\n", pht('%s: Stored as chunks, declining to cycle directly.', $monogram));
             continue;
         }
         $format_key = $file->getStorageFormat();
         if (empty($format_map[$format_key])) {
             echo tsprintf("%s\n", pht('%s: Uses unknown storage format "%s".', $monogram, $format_key));
             $failed[] = $file;
             continue;
         }
         $format = clone $format_map[$format_key];
         $format->setFile($file);
         if (!$format->canCycleMasterKey()) {
             echo tsprintf("%s\n", pht('%s: Storage format ("%s") does not support key cycling.', $monogram, $format->getStorageFormatName()));
             continue;
         }
         echo tsprintf("%s\n", pht('%s: Cycling master key.', $monogram));
         try {
             if ($key_name) {
                 $format->selectMasterKey($key_name);
             }
             $file->cycleMasterStorageKey($format);
             echo tsprintf("%s\n", pht('Done.'));
         } catch (Exception $ex) {
             echo tsprintf("%B\n", pht('Failed! %s', (string) $ex));
             $failed[] = $file;
         }
     }
     if ($failed) {
         $monograms = mpull($failed, 'getMonogram');
         echo tsprintf("%s\n", pht('Failures: %s.', implode(', ', $monograms)));
         return 1;
     }
     return 0;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:54,代码来源:PhabricatorFilesManagementCycleWorkflow.php

示例14: execute

 public function execute(PhutilArgumentParser $args)
 {
     $repos = $this->loadLocalRepositories($args, 'repos');
     if (!$repos) {
         throw new PhutilArgumentUsageException(pht('Specify one or more repositories to push to mirrors.'));
     }
     foreach ($repos as $repo) {
         echo tsprintf("%s\n", pht('Pushing "%s" to mirrors...', $repo->getDisplayName()));
         $engine = id(new PhabricatorRepositoryMirrorEngine())->setRepository($repo)->setVerbose($args->getArg('verbose'))->pushToMirrors();
     }
     echo tsprintf("%s\n", pht('Done.'));
     return 0;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:13,代码来源:PhabricatorRepositoryManagementMirrorWorkflow.php

示例15: didExecute

 public function didExecute(PhutilArgumentParser $args)
 {
     echo tsprintf("%s\n", pht('Committing configured partition map to databases...'));
     foreach ($this->getMasterAPIs() as $api) {
         $ref = $api->getRef();
         $conn = $ref->newManagementConnection();
         $state = $ref->getPartitionStateForCommit();
         queryfx($conn, 'INSERT INTO %T.%T (stateKey, stateValue) VALUES (%s, %s)
       ON DUPLICATE KEY UPDATE stateValue = VALUES(stateValue)', $api->getDatabaseName('meta_data'), PhabricatorStorageManagementAPI::TABLE_HOSTSTATE, 'cluster.databases', $state);
         echo tsprintf("%s\n", pht('Wrote configuration on database host "%s".', $ref->getRefKey()));
     }
     return 0;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:13,代码来源:PhabricatorStorageManagementPartitionWorkflow.php


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