本文整理汇总了PHP中pts_strings::is_url方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::is_url方法的具体用法?PHP pts_strings::is_url怎么用?PHP pts_strings::is_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_strings
的用法示例。
在下文中一共展示了pts_strings::is_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install_test_process
protected static function install_test_process(&$test_install_request, $no_prompts)
{
// Install a test
$identifier = $test_install_request->test_profile->get_identifier();
$test_install_directory = $test_install_request->test_profile->get_install_dir();
pts_file_io::mkdir(dirname($test_install_directory));
pts_file_io::mkdir($test_install_directory);
$installed = false;
if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_download_size() + 128) {
self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for the test files.');
} else {
if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_environment_size(false) + 128) {
self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for this test.');
} else {
pts_test_installer::setup_test_install_directory($test_install_request, true);
// Download test files
$download_test_files = pts_test_installer::download_test_files($test_install_request, false, $no_prompts);
if ($download_test_files == false) {
self::test_install_error(null, $test_install_request, 'Downloading of needed test files failed.');
return false;
}
if ($test_install_request->test_profile->get_file_installer() != false) {
self::create_compiler_mask($test_install_request);
pts_module_manager::module_process('__pre_test_install', $identifier);
pts_client::$display->test_install_begin($test_install_request);
$pre_install_message = $test_install_request->test_profile->get_pre_install_message();
$post_install_message = $test_install_request->test_profile->get_post_install_message();
$install_agreement = $test_install_request->test_profile->get_installation_agreement_message();
if (!empty($install_agreement)) {
if (pts_strings::is_url($install_agreement)) {
$install_agreement = pts_network::http_get_contents($install_agreement);
if (empty($install_agreement)) {
self::test_install_error(null, $test_install_request, 'The user agreement could not be found. Test installation aborted.');
return false;
}
}
echo $install_agreement . PHP_EOL;
if (!$no_prompts) {
$user_agrees = pts_user_io::prompt_bool_input('Do you agree to these terms', false, 'INSTALL_AGREEMENT');
if (!$user_agrees) {
self::test_install_error(null, $test_install_request, 'User agreement failed; this test will not be installed.');
return false;
}
}
}
pts_client::$display->display_interrupt_message($pre_install_message);
$install_time_length_start = microtime(true);
$install_log = pts_tests::call_test_script($test_install_request->test_profile, 'install', null, $test_install_directory, $test_install_request->special_environment_vars, false);
$test_install_request->install_time_duration = ceil(microtime(true) - $install_time_length_start);
pts_client::$display->display_interrupt_message($post_install_message);
if (!empty($install_log)) {
file_put_contents($test_install_directory . 'install.log', $install_log);
pts_file_io::unlink($test_install_directory . 'install-failed.log');
pts_client::$display->test_install_output($install_log);
}
if (is_file($test_install_directory . 'install-exit-status')) {
// If the installer writes its exit status to ~/install-exit-status, if it's non-zero the install failed
$install_exit_status = pts_file_io::file_get_contents($test_install_directory . 'install-exit-status');
unlink($test_install_directory . 'install-exit-status');
if ($install_exit_status != 0 && phodevi::is_windows() == false) {
$install_error = null;
// TODO: perhaps better way to handle this than to remove pts-install.xml
pts_file_io::unlink($test_install_directory . 'pts-install.xml');
if (is_file($test_install_directory . 'install.log')) {
$install_log = pts_file_io::file_get_contents($test_install_directory . 'install.log');
$install_error = pts_tests::scan_for_error($install_log, $test_install_directory);
copy($test_install_directory . 'install.log', $test_install_directory . 'install-failed.log');
}
//pts_test_installer::setup_test_install_directory($test_install_request, true); // Remove installed files from the bunked installation
self::test_install_error(null, $test_install_request, 'The installer exited with a non-zero exit status.');
if ($install_error != null) {
$test_install_request->install_error = pts_tests::pretty_error_string($install_error);
if ($test_install_request->install_error != null) {
self::test_install_error(null, $test_install_request, 'ERROR: ' . $test_install_request->install_error);
}
}
pts_client::$display->test_install_error('LOG: ' . str_replace(pts_core::user_home_directory(), '~/', $test_install_directory) . 'install-failed.log' . PHP_EOL);
if (pts_client::do_anonymous_usage_reporting()) {
// If anonymous usage reporting enabled, report test install failure to OpenBenchmarking.org
pts_openbenchmarking_client::upload_usage_data('test_install_failure', array($test_install_request, $install_error));
}
return false;
}
}
pts_module_manager::module_process('__post_test_install', $identifier);
$installed = true;
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/RemoveDownloadFiles', 'FALSE')) {
// Remove original downloaded files
foreach ($test_install_request->get_download_objects() as $download_object) {
pts_file_io::unlink($test_install_directory . $download_object->get_filename());
}
}
} else {
pts_client::$display->test_install_error('No installation script found.');
$installed = true;
}
// Additional validation checks?
$custom_validated_output = pts_tests::call_test_script($test_install_request->test_profile, 'validate-install', PHP_EOL . 'Validating Installation...' . PHP_EOL, $test_install_directory, null, false);
if (!empty($custom_validated_output) && !pts_strings::string_bool($custom_validated_output)) {
$installed = false;
//.........这里部分代码省略.........
示例2: download_cache_locations
public static function download_cache_locations()
{
static $cache_directories = null;
if ($cache_directories == null) {
$cache_directories = array();
// Phoronix Test Suite System Cache Directories
$additional_dir_checks = array('/var/cache/phoronix-test-suite/download-cache/', '/var/cache/phoronix-test-suite/');
foreach ($additional_dir_checks as $dir_check) {
if (is_dir($dir_check)) {
$cache_directories[] = $dir_check;
break;
}
}
// User Defined Directory Checking
$dir_string = ($dir = pts_client::read_env('PTS_DOWNLOAD_CACHE')) != false ? $dir : null;
foreach (array_merge(self::$extra_caches, pts_strings::colon_explode($dir_string)) as $dir_check) {
if ($dir_check == null) {
continue;
}
$dir_check = pts_strings::parse_for_home_directory($dir_check);
if (pts_strings::is_url($dir_check) == false && !is_dir($dir_check)) {
continue;
}
$cache_directories[] = pts_strings::add_trailing_slash($dir_check);
}
if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/SearchMediaForCache', 'TRUE')) {
$download_cache_dirs = array_merge(pts_file_io::glob('/media/*/download-cache/'), pts_file_io::glob('/media/*/*/download-cache/'), pts_file_io::glob('/run/media/*/*/download-cache/'), pts_file_io::glob('/Volumes/*/download-cache/'));
foreach ($download_cache_dirs as $dir) {
$cache_directories[] = $dir;
}
}
}
return $cache_directories;
}