本文整理汇总了PHP中pts_client::terminal_width方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::terminal_width方法的具体用法?PHP pts_client::terminal_width怎么用?PHP pts_client::terminal_width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::terminal_width方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: string_header
protected static function string_header($heading, $char = '=')
{
// Return a string header
if (!isset($heading[1])) {
return null;
}
$header_size = 40;
foreach (explode(PHP_EOL, $heading) as $line) {
if (isset($line[$header_size + 1])) {
$header_size = strlen($line);
}
}
if (($terminal_width = pts_client::terminal_width()) < $header_size && $terminal_width > 0) {
$header_size = $terminal_width;
}
return PHP_EOL . str_repeat($char, $header_size) . PHP_EOL . $heading . PHP_EOL . str_repeat($char, $header_size) . PHP_EOL . PHP_EOL;
}
示例2: test_install_download_file
public function test_install_download_file($process, &$pts_test_file_download)
{
$expected_time = 0;
$progress_prefix = null;
switch ($process) {
case 'DOWNLOAD_FROM_CACHE':
$process_string = 'Downloading From Cache';
$progress_prefix = 'Downloading';
break;
case 'LINK_FROM_CACHE':
$process_string = 'Linking From Cache';
break;
case 'COPY_FROM_CACHE':
$process_string = 'Copying From Cache';
$progress_prefix = 'Copying';
break;
case 'FILE_FOUND':
$process_string = 'File Found';
break;
case 'DOWNLOAD':
$process_string = 'Downloading';
$progress_prefix = 'Downloading';
if (($avg_speed = pts_download_speed_manager::get_average_download_speed()) > 0 && ($this_size = $pts_test_file_download->get_filesize()) > 0) {
$expected_time = $this_size / $avg_speed;
}
break;
}
$expected_time = is_numeric($expected_time) && $expected_time > 0 ? pts_strings::format_time($expected_time, 'SECONDS', false, 60) : null;
// TODO: handle if file-name is too long for terminal width
$download_string = $this->tab . $this->tab . $process_string . ': ' . $pts_test_file_download->get_filename();
$download_size_string = $pts_test_file_download->get_filesize() > 0 ? ' [' . self::bytes_to_download_size($pts_test_file_download->get_filesize()) . 'MB]' : null;
$offset_length = pts_client::terminal_width() > 1 ? pts_client::terminal_width() : pts_test_file_download::$longest_file_name_length;
$offset_length = $offset_length - strlen($download_string) - strlen($download_size_string) - 2;
if ($offset_length < 2) {
$offset_length = 2;
}
$download_string .= str_repeat(' ', $offset_length - 2);
$download_string .= $download_size_string;
echo $download_string . PHP_EOL;
$this->progress_line_prefix = $expected_time != null ? 'Estimated Download Time: ' . $expected_time : $progress_prefix;
$this->progress_last_float = -1;
$this->progress_tab_count = 2;
$this->progress_string_length = strlen($download_string);
}
示例3: run
public static function run($r)
{
pts_client::$display->generic_heading('Available Tests');
$available_tests = pts_openbenchmarking::available_tests(false);
$available_suites = pts_openbenchmarking::available_suites(false);
$test_count = count($available_tests);
$suite_count = count($available_suites);
$total_count = $test_count + $suite_count;
$total_cache_count = 0;
$total_cache_size = 0;
if ($test_count == 0 || !pts_network::internet_support_available()) {
echo PHP_EOL . 'No tests found. Please check that you have Internet connectivity to download test profile data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
return false;
}
$terminal_width = pts_client::terminal_width();
// Cache test profiles
foreach ($available_tests as $i => $identifier) {
$repo = substr($identifier, 0, strpos($identifier, '/'));
$test = substr($identifier, strlen($repo) + 1);
$repo_index = pts_openbenchmarking::read_repository_index($repo);
echo $i . '/' . $total_count . ': ' . ($repo_index['tests'][$test]['title'] != null ? $repo_index['tests'][$test]['title'] . ' [' . $repo_index['tests'][$test]['test_type'] . ']' : null) . PHP_EOL;
foreach ($repo_index['tests'][$test]['versions'] as $version) {
$qualified_identifier = $repo . '/' . $test . '-' . $version;
echo $qualified_identifier;
$success = pts_openbenchmarking::download_test_profile($repo . '/' . $test . '-' . $version);
if ($success && is_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip')) {
$file_size = round(filesize(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip') / 1024, 2);
$info = $file_size . 'KB - ' . sha1_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip');
$r_size = $terminal_width - strlen($qualified_identifier) - 3 - strlen($info);
if ($r_size > 0) {
echo ' ' . str_repeat('.', $terminal_width - strlen($qualified_identifier) - 3 - strlen($info)) . ' ' . $info . PHP_EOL;
}
$total_cache_count++;
$total_cache_size += $file_size;
}
}
echo PHP_EOL;
}
// Cache test suites
foreach ($available_suites as $i => $identifier) {
$repo = substr($identifier, 0, strpos($identifier, '/'));
$test = substr($identifier, strlen($repo) + 1);
$repo_index = pts_openbenchmarking::read_repository_index($repo);
echo $i + $test_count . '/' . $total_count . ': ' . $repo_index['suites'][$test]['title'] . PHP_EOL;
foreach ($repo_index['suites'][$test]['versions'] as $version) {
$qualified_identifier = $repo . '/' . $test . '-' . $version;
echo $qualified_identifier;
$success = pts_openbenchmarking::download_test_suite($repo . '/' . $test . '-' . $version);
if ($success && is_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip')) {
$file_size = round(filesize(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip') / 1024, 2);
$info = $file_size . 'KB - ' . sha1_file(PTS_OPENBENCHMARKING_SCRATCH_PATH . $qualified_identifier . '.zip');
$dot_size = $terminal_width - strlen($qualified_identifier) - 3 - strlen($info);
echo ' ' . str_repeat('.', $dot_size >= 0 ? $dot_size : 0) . ' ' . $info . PHP_EOL;
$total_cache_count++;
$total_cache_size += $file_size;
}
}
echo PHP_EOL;
}
echo PHP_EOL . $total_cache_count . ' Files Cached' . PHP_EOL . $test_count . ' Test Profiles' . PHP_EOL . $suite_count . ' Test Suites' . PHP_EOL . $total_cache_size . 'KB Total Cache Size' . PHP_EOL . PHP_EOL;
}
示例4: test_install_progress_start
public function test_install_progress_start($process)
{
$this->progress_line_prefix = $process;
$this->progress_last_float = -1;
$this->progress_tab_count = 1;
$this->progress_string_length = pts_client::terminal_width() > 1 ? pts_client::terminal_width() - 4 : 20;
return;
}
示例5: run
public static function run($r)
{
$result_file = new pts_result_file($r[0]);
$result_output = pts_result_file_output::result_file_to_text($result_file, pts_client::terminal_width());
echo $result_output;
}