本文整理汇总了PHP中pts_file_io类的典型用法代码示例。如果您正苦于以下问题:PHP pts_file_io类的具体用法?PHP pts_file_io怎么用?PHP pts_file_io使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pts_file_io类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($r)
{
$result = $r[0];
$result_file = new pts_result_file($result);
$result_file_identifiers = $result_file->get_system_identifiers();
if (count($result_file_identifiers) < 2) {
echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
return false;
}
$remove_identifiers = explode(',', pts_user_io::prompt_text_menu('Select the test run(s) to remove', $result_file_identifiers, true));
$keep_identifiers = array();
foreach ($result_file_identifiers as $identifier) {
if (!in_array($identifier, $remove_identifiers)) {
array_push($keep_identifiers, $identifier);
}
}
foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
foreach ($remove_identifiers as $remove_identifier) {
if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier)) {
pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier, null, true);
}
}
}
$extract_select = new pts_result_merge_select($result, $keep_identifiers);
$extract_result = pts_merge::merge_test_results($extract_select);
pts_client::save_test_result($r[0] . '/composite.xml', $extract_result);
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
}
示例2: run
public static function run($r)
{
pts_client::$display->generic_heading('Available Tests');
$test_count = 0;
foreach (pts_openbenchmarking::available_tests(false) as $identifier) {
$repo = substr($identifier, 0, strpos($identifier, '/'));
$id = substr($identifier, strlen($repo) + 1);
$repo_index = pts_openbenchmarking::read_repository_index($repo);
if (!in_array(phodevi::operating_system(), $repo_index['tests'][$id]['supported_platforms']) || empty($repo_index['tests'][$id]['title'])) {
// Don't show unsupported tests
continue;
}
echo sprintf('%-30ls - %-35ls %-9ls', $identifier, $repo_index['tests'][$id]['title'], $repo_index['tests'][$id]['test_type']) . PHP_EOL;
$test_count++;
}
foreach (pts_file_io::glob(PTS_TEST_PROFILE_PATH . 'local/*/test-definition.xml') as $path) {
$test_profile = new pts_test_profile('local/' . basename(dirname($path)));
if ($test_profile->get_title() != null && $test_profile->is_supported(false)) {
echo sprintf('%-30ls - %-35ls %-9ls', $test_profile->get_identifier(), $test_profile->get_title(), $test_profile->get_test_hardware_type()) . PHP_EOL;
$test_count++;
}
}
if ($test_count == 0) {
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;
}
}
示例3: render_page_process
public static function render_page_process($PATH)
{
$suite_dir = phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID']);
$main = '<h1>Local Suites</h1><p>These are test suites created by you or another account within your group. Suites are an easy collection of test profiles. New suits can be trivially made via the <a href="/?build_suite">build suite</a> page.</p>';
$suite_count = 0;
foreach (pts_file_io::glob($suite_dir . '*/suite-definition.xml') as $xml_path) {
$suite_count++;
$id = basename(dirname($xml_path));
$test_suite = new pts_test_suite($xml_path);
$main .= '<a name="' . $id . '"></a><h1>' . $test_suite->get_title() . ' [' . $id . ']</h1>';
$main .= '<p><strong>' . $test_suite->get_maintainer() . '</strong></p>';
$main .= '<p><em>' . $test_suite->get_description() . '</em></p>';
$main .= '<div style="max-height: 200px; overflow-y: scroll;">';
foreach ($test_suite->get_contained_test_result_objects() as $tro) {
$main .= '<h3>' . $tro->test_profile->get_title() . ' [' . $tro->test_profile->get_identifier() . ']</h3>';
$main .= '<p>' . $tro->get_arguments_description() . '</p>';
}
$main .= '</div>';
$main .= '<hr />';
}
if ($suite_count == 0) {
$main .= '<h1>No Test Suites Found</h1>';
}
echo phoromatic_webui_header_logged_in();
echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
echo phoromatic_webui_footer();
}
示例4: client_commands_array
public static function client_commands_array()
{
$options = array('Test Installation' => array(), 'Testing' => array(), 'Batch Testing' => array(), 'OpenBenchmarking.org' => array(), 'System' => array(), 'Information' => array(), 'Asset Creation' => array(), 'Result Management' => array(), 'Result Analytics' => array(), 'Other' => array());
foreach (pts_file_io::glob(PTS_COMMAND_PATH . '*.php') as $option_php_file) {
$option_php = basename($option_php_file, '.php');
$name = str_replace('_', '-', $option_php);
if (!in_array(pts_strings::first_in_string($name, '-'), array('dump', 'task'))) {
include_once $option_php_file;
$reflect = new ReflectionClass($option_php);
$constants = $reflect->getConstants();
$doc_description = isset($constants['doc_description']) ? constant($option_php . '::doc_description') : 'No summary is available.';
$doc_section = isset($constants['doc_section']) ? constant($option_php . '::doc_section') : 'Other';
$name = isset($constants['doc_use_alias']) ? constant($option_php . '::doc_use_alias') : $name;
$skip = isset($constants['doc_skip']) ? constant($option_php . '::doc_skip') : false;
$doc_args = array();
if ($skip) {
continue;
}
if (method_exists($option_php, 'argument_checks')) {
$doc_args = call_user_func(array($option_php, 'argument_checks'));
}
if (!empty($doc_section) && !isset($options[$doc_section])) {
$options[$doc_section] = array();
}
array_push($options[$doc_section], array($name, $doc_args, $doc_description));
}
}
return $options;
}
示例5: delete
public static function delete($object, $ignore_files = null, $remove_root_directory = false)
{
// Delete files and/or directories
if ($object == false) {
return false;
}
if (is_dir($object)) {
$object = pts_strings::add_trailing_slash($object);
}
foreach (pts_file_io::glob($object . '*') as $to_remove) {
if (is_file($to_remove) || is_link($to_remove)) {
if (is_array($ignore_files) && in_array(basename($to_remove), $ignore_files)) {
continue;
// Don't remove the file
} else {
unlink($to_remove);
}
} else {
if (is_dir($to_remove)) {
self::delete($to_remove, $ignore_files, true);
}
}
}
if ($remove_root_directory && is_dir($object) && count(pts_file_io::glob($object . '/*')) == 0) {
rmdir($object);
}
}
示例6: get_vendors_list
public function get_vendors_list()
{
$package_files = pts_file_io::glob(PTS_EXDEP_PATH . 'xml/*-packages.xml');
foreach ($package_files as &$file) {
$file = basename(substr($file, 0, strpos($file, '-packages.xml')));
}
return $package_files;
}
示例7: run
public static function run($r)
{
pts_file_io::unlink(getenv('PTS_EXT_LAUNCH_SCRIPT_DIR') . '/web-server-launcher');
if (PHP_VERSION_ID < 50400) {
echo 'Running an unsupported PHP version. PHP 5.4+ is required to use this feature.' . PHP_EOL . PHP_EOL;
return false;
}
$server_launcher = '#!/bin/sh' . PHP_EOL;
$web_port = 0;
$remote_access = pts_config::read_user_config('PhoronixTestSuite/Options/Server/RemoteAccessPort', 'FALSE');
$remote_access = is_numeric($remote_access) && $remote_access > 1 ? $remote_access : false;
$blocked_ports = array(2049, 3659, 4045, 6000);
if ($remote_access) {
// ALLOWING SERVER TO BE REMOTELY ACCESSIBLE
$server_ip = '0.0.0.0';
$fp = false;
$errno = null;
$errstr = null;
if (($fp = fsockopen('127.0.0.1', $remote_access, $errno, $errstr, 5)) != false) {
trigger_error('Port ' . $remote_access . ' is already in use by another server process. Close that process or change the Phoronix Test Suite server port via ' . pts_config::get_config_file_location() . ' to proceed.', E_USER_ERROR);
fclose($fp);
return false;
} else {
$web_port = $remote_access;
$web_socket_port = pts_config::read_user_config('PhoronixTestSuite/Options/Server/WebSocketPort', '');
if ($web_socket_port == null || !is_numeric($web_socket_port)) {
$web_socket_port = $web_port - 1;
}
}
} else {
echo PHP_EOL . PHP_EOL . 'You must first configure the remote GUI/WEBUI settings via:' . pts_config::get_config_file_location() . PHP_EOL . PHP_EOL;
return false;
}
// WebSocket Server Setup
$server_launcher .= 'export PTS_WEBSOCKET_PORT=' . $web_socket_port . PHP_EOL;
$server_launcher .= 'export PTS_WEBSOCKET_SERVER=GUI' . PHP_EOL;
$server_launcher .= 'cd ' . getenv('PTS_DIR') . ' && PTS_MODE="CLIENT" ' . getenv('PHP_BIN') . ' pts-core/phoronix-test-suite.php start-ws-server &' . PHP_EOL;
$server_launcher .= 'websocket_server_pid=$!' . PHP_EOL;
// HTTP Server Setup
if (strpos(getenv('PHP_BIN'), 'hhvm')) {
echo PHP_EOL . 'Unfortunately, the HHVM built-in web server has abandoned upstream. Users will need to use the PHP binary or other alternatives.' . PHP_EOL . PHP_EOL;
return false;
} else {
$server_launcher .= getenv('PHP_BIN') . ' -S ' . $server_ip . ':' . $web_port . ' -t ' . PTS_CORE_PATH . 'web-interface/ 2> /dev/null &' . PHP_EOL;
//2> /dev/null
}
$server_launcher .= 'http_server_pid=$!' . PHP_EOL;
$server_launcher .= 'sleep 1' . PHP_EOL;
$server_launcher .= 'echo "The Web Interface Is Accessible At: http://localhost:' . $web_port . '"' . PHP_EOL;
$server_launcher .= PHP_EOL . 'echo -n "Press [ENTER] to kill server..."' . PHP_EOL . 'read var_name';
// Shutdown / Kill Servers
$server_launcher .= PHP_EOL . 'kill $http_server_pid';
$server_launcher .= PHP_EOL . 'kill $websocket_server_pid';
$server_launcher .= PHP_EOL . 'rm -f ~/.phoronix-test-suite/run-lock*';
file_put_contents(getenv('PTS_EXT_LAUNCH_SCRIPT_DIR') . '/web-server-launcher', $server_launcher);
}
示例8: run
public static function run($r)
{
$identifier = $r[0];
$test_xml_files = pts_file_io::glob(PTS_SAVE_RESULTS_PATH . $identifier . '/test-*.xml');
if (count($test_xml_files) == 0) {
echo PHP_EOL . 'No test XML data was found.' . PHP_EOL;
return false;
}
pts_client::save_test_result($identifier . '/composite.xml', pts_merge::merge_test_results_array($test_xml_files));
pts_client::regenerate_graphs($identifier, 'The ' . $identifier . ' result file XML has been rebuilt.');
}
示例9: run
public static function run($r)
{
$options = array();
foreach (pts_file_io::glob(PTS_COMMAND_PATH . '*.php') as $option_php) {
$name = str_replace('_', '-', basename($option_php, '.php'));
if (!in_array(pts_strings::first_in_string($name, '-'), array('dump', 'debug', 'task'))) {
array_push($options, $name);
}
}
$is_true = isset($r[0]) && $r[0] == 'TRUE';
echo implode($is_true ? ' ' : PHP_EOL, $options) . ($is_true ? null : PHP_EOL);
}
示例10: read_sensor
public static function read_sensor()
{
// Reads the system's temperature
$temp_c = -1;
if (phodevi::is_linux()) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp3_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp2_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
}
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/device/temp1_input', 'POSITIVE_NUMERIC', array('name' => '!coretemp,!radeon,!nouveau'));
}
if ($raw_temp == -1) {
$raw_temp = phodevi_linux_parser::read_sysfs_node('/sys/class/hwmon/hwmon*/temp1_input', 'POSITIVE_NUMERIC');
}
if ($raw_temp != -1) {
if ($raw_temp > 1000) {
$raw_temp = $raw_temp / 1000;
}
$temp_c = pts_math::set_precision($raw_temp, 2);
}
if ($temp_c == -1) {
$acpi = phodevi_linux_parser::read_acpi(array('/thermal_zone/THM1/temperature', '/thermal_zone/TZ00/temperature', '/thermal_zone/TZ01/temperature'), 'temperature');
if (($end = strpos($acpi, ' ')) > 0) {
$temp_c = substr($acpi, 0, $end);
}
}
if ($temp_c == -1) {
$sensors = phodevi_linux_parser::read_sensors(array('Sys Temp', 'Board Temp'));
if ($sensors != false && is_numeric($sensors)) {
$temp_c = $sensors;
}
}
if ($temp_c == -1 && is_file('/sys/class/thermal/thermal_zone0/temp')) {
$temp_c = pts_file_io::file_get_contents('/sys/class/thermal/thermal_zone0/temp');
if ($temp_c > 1000) {
$temp_c = pts_math::set_precision($temp_c / 1000, 1);
}
}
} else {
if (phodevi::is_bsd()) {
$acpi = phodevi_bsd_parser::read_sysctl(array('hw.sensors.acpi_tz1.temp0', 'hw.acpi.thermal.tz1.temperature'));
if (($end = strpos($acpi, ' degC')) > 0 || ($end = strpos($acpi, 'C')) > 0) {
$acpi = substr($acpi, 0, $end);
if (is_numeric($acpi)) {
$temp_c = $acpi;
}
}
}
}
return $temp_c;
}
示例11: get_supported_devices
public static function get_supported_devices()
{
if (phodevi::is_linux()) {
$blockdev_dir = '/sys/block/';
$glob_regex = '{[shvm]d*,nvme*,mmcblk*}';
$disk_array = pts_file_io::glob($blockdev_dir . $glob_regex, GLOB_BRACE);
$supported = array();
foreach ($disk_array as $check_disk) {
$stat_path = $check_disk . '/stat';
if (is_file($stat_path) && pts_file_io::file_get_contents($stat_path) != null) {
array_push($supported, basename($check_disk));
}
}
return $supported;
}
return NULL;
}
示例12: read_sensor
public static function read_sensor()
{
$iowait = -1;
if (phodevi::is_linux() && is_file('/proc/stat')) {
$start_stat = pts_file_io::file_get_contents('/proc/stat');
sleep(1);
$end_stat = pts_file_io::file_get_contents('/proc/stat');
$start_stat = explode(' ', substr($start_stat, 0, strpos($start_stat, "\n")));
$end_stat = explode(' ', substr($end_stat, 0, strpos($end_stat, "\n")));
for ($i = 2, $diff_cpu_total = 0; $i < 9; $i++) {
$diff_cpu_total += $end_stat[$i] - $start_stat[$i];
}
$diff_iowait = $end_stat[6] - $start_stat[6];
$iowait = pts_math::set_precision(1000 * $diff_iowait / $diff_cpu_total / 10, 2);
}
return $iowait;
}
示例13: get_supported_devices
public static function get_supported_devices()
{
if (phodevi::is_linux()) {
$disk_list = shell_exec("ls -1 /sys/class/block | grep '^[shv]d[a-z]\$'");
// TODO make this native PHP
$disk_array = explode("\n", $disk_list);
$supported = array();
foreach ($disk_array as $check_disk) {
$stat_path = '/sys/class/block/' . $check_disk . '/stat';
if (is_file($stat_path) && pts_file_io::file_get_contents($stat_path) != null) {
array_push($supported, $check_disk);
}
}
return $supported;
}
return NULL;
}
示例14: audio_processor_string
public static function audio_processor_string()
{
$audio = null;
if (phodevi::is_macosx()) {
// TODO: implement
} else {
if (phodevi::is_bsd()) {
foreach (array('dev.hdac.0.%desc') as $dev) {
$dev = phodevi_bsd_parser::read_sysctl($dev);
if (!empty($dev)) {
$audio = $dev;
}
}
} else {
if (phodevi::is_windows()) {
// TODO: implement
} else {
if (phodevi::is_linux()) {
foreach (pts_file_io::glob('/sys/class/sound/card*/hwC0D*/vendor_name') as $vendor_name) {
$card_dir = dirname($vendor_name) . '/';
if (!is_readable($card_dir . 'chip_name')) {
continue;
}
$vendor_name = pts_file_io::file_get_contents($vendor_name);
$chip_name = pts_file_io::file_get_contents($card_dir . 'chip_name');
$audio = $vendor_name . ' ' . $chip_name;
if (strpos($chip_name, 'HDMI') !== false || strpos($chip_name, 'DP') !== false) {
// If HDMI is in the audio string, likely the GPU-provided audio, so try to find the mainboard otherwise
$audio = null;
} else {
break;
}
}
if ($audio == null) {
$audio = phodevi_linux_parser::read_pci('Multimedia audio controller');
}
if ($audio == null) {
$audio = phodevi_linux_parser::read_pci('Audio device');
}
}
}
}
}
return $audio;
}
示例15: read_sensor
public static function read_sensor()
{
// speed in MB/s
$speed = -1;
if (phodevi::is_linux()) {
static $sys_disk = null;
if ($sys_disk == null) {
foreach (pts_file_io::glob('/sys/class/block/sd*/stat') as $check_disk) {
if (pts_file_io::file_get_contents($check_disk) != null) {
$sys_disk = $check_disk;
break;
}
}
}
$speed = phodevi_linux_parser::read_sys_disk_speed($sys_disk, 'READ');
}
return $speed;
}