How to use read_name method of phodevi class

Best Phoronix-test-suite code snippet using phodevi.read_name

phodevi.php

Source:phodevi.php Github

copy

Full Screen

...42 public static $allow_phodevi_caching = true;43 const no_caching = 1;44 const std_caching = 2;45 const smart_caching = 3;46 public static function read_name($device)47 {48 return phodevi::read_property($device, 'identifier');49 }50 public static function load_sensors()51 {52 if(!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300)53 {54 // Phodevi sensors don't work prior to PHP 5.355 self::$sensors = array();56 return false;57 }58 foreach(glob(dirname(__FILE__) . '/sensors/*') as $sensor_obj_file)59 {60 $sensor_obj_name = basename($sensor_obj_file, '.php');61 if(!class_exists($sensor_obj_name, false))62 {63 include($sensor_obj_file);64 }65 $type = call_user_func(array($sensor_obj_name, 'get_type'));66 $sensor = call_user_func(array($sensor_obj_name, 'get_sensor'));67 if($type != null && $sensor != null)68 {69 self::$sensors[$type][$sensor] = $sensor_obj_name;70 }71 }72 }73 public static function available_sensors($limit_sensors = false)74 {75 static $available_sensors = null;76 if($limit_sensors != false)77 {78 return self::select_sensors($limit_sensors);79 }80 else if($available_sensors == null)81 {82 $available_sensors = array();83 foreach(self::$sensors as $sensor_type => &$sensor)84 {85 foreach(array_keys($sensor) as $sensor_senses)86 {87 array_push($available_sensors, array($sensor_type, $sensor_senses, self::$sensors[$sensor_type][$sensor_senses]));88 }89 }90 }91 return $available_sensors;92 }93 public static function select_sensors($limit_sensors = false)94 {95 if(!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300)96 {97 // Phodevi sensors don't work prior to PHP 5.398 return array();99 }100 $selected = array();101 foreach(self::available_sensors() as $sensor)102 {103 if($limit_sensors == false || (is_array($limit_sensors) && in_array($sensor[2], $limit_sensors)))104 {105 array_push($selected, $sensor);106 }107 }108 return $selected;109 }110 public static function supported_sensors($limit_sensors = false)111 {112 static $supported_sensors = null;113 if($limit_sensors != false)114 {115 return self::select_sensors($limit_sensors);116 }117 else if($supported_sensors == null)118 {119 $supported_sensors = array();120 foreach(self::available_sensors($limit_sensors) as $sensor)121 {122 if(self::sensor_supported($sensor))123 {124 array_push($supported_sensors, $sensor);125 }126 }127 }128 return $supported_sensors;129 }130 public static function unsupported_sensors()131 {132 static $unsupported_sensors = null;133 if($unsupported_sensors == null)134 {135 $unsupported_sensors = array();136 $supported_sensors = self::supported_sensors();137 foreach(self::available_sensors() as $sensor)138 {139 if(!in_array($sensor, $supported_sensors))140 {141 array_push($unsupported_sensors, $sensor);142 }143 }144 }145 return $unsupported_sensors;146 }147 public static function read_sensor($sensor)148 {149 if($sensor instanceof phodevi_sensor)150 {151 $sensor_object = $sensor;152 }153 else154 {155 $sensor_object = new self::$sensors[$sensor[0]][$sensor[1]](null, null);156 }157 return $sensor_object->read_sensor();158 }159 public static function read_sensor_object_unit(&$sensor_object)160 {161 $sensor = array($sensor_object->get_type(), $sensor_object->get_sensor(), get_class($sensor_object));162 return self::read_sensor_unit($sensor);163 }164 public static function read_sensor_unit($sensor)165 {166 return call_user_func(array(self::$sensors[$sensor[0]][$sensor[1]], 'get_unit'));167 }168 public static function sensor_supported($sensor)169 {170 $sensor_object = new self::$sensors[$sensor[0]][$sensor[1]](null, null);171 return isset(self::$sensors[$sensor[0]][$sensor[1]]) && $sensor_object->support_check();172 }173 public static function sensor_object_identifier(&$sensor_object)174 {175 $sensor = array($sensor_object->get_type(), $sensor_object->get_sensor(), get_class($sensor_object));176 return self::sensor_identifier($sensor) . '.' . $sensor_object->get_instance();177 }178 public static function sensor_identifier($sensor)179 {180 return $sensor[0] . '.' . $sensor[1];181 }182 public static function sensor_object_name(&$sensor_object)183 {184 $sensor = array($sensor_object->get_type(), $sensor_object->get_sensor(), get_class($sensor_object));185 $name = self::sensor_name($sensor);186 $params = $sensor_object->get_readable_device_name();187 if($params !== NULL)188 {189 $name .= ' (' . $params . ')';190 }191 return $name;192 }193 public static function sensor_name($sensor)194 {195 $type = call_user_func(array(self::$sensors[$sensor[0]][$sensor[1]], 'get_type'));196 $sensor = call_user_func(array(self::$sensors[$sensor[0]][$sensor[1]], 'get_sensor'));197 if(strlen($type) < 4)198 {199 $formatted = strtoupper($type);200 }201 else202 {203 $formatted = ucwords($type);204 }205 switch($formatted)206 {207 case 'SYS':208 $formatted = 'System';209 break;210 case 'HDD':211 $formatted = 'Drive';212 break;213 }214 $formatted .= ' ';215 switch($sensor)216 {217 case 'temp':218 $formatted .= 'Temperature';219 break;220 case 'freq':221 $formatted .= 'Frequency';222 break;223 case 'memory':224 $formatted .= 'Memory Usage';225 break;226 case 'power':227 $formatted .= 'Power Consumption';228 break;229 default:230 $formatted .= ucwords(str_replace('-', ' ', $sensor));231 break;232 }233 return $formatted;234 }235 public static function system_hardware($return_as_string = true)236 {237 return self::system_information_parse(self::available_hardware_devices(), $return_as_string);238 }239 public static function system_software($return_as_string = true)240 {241 return self::system_information_parse(self::available_software_components(), $return_as_string);242 }243 public static function system_centralized_view($return_as_string = true)244 {245 $core_count = phodevi::is_linux() ? phodevi_cpu::cpuinfo_core_count() : phodevi::read_property('cpu', 'core-count');246 $thread_count = phodevi_cpu::cpuinfo_thread_count();247 $sys = array(248 'Processor' => phodevi::read_name('cpu'),249 array(250 'Core Count' => $core_count,251 'Thread Count' => $core_count == $thread_count ? '' : $thread_count, // don't show thread count if it's same as core count252 'Extensions' => phodevi_cpu::instruction_set_extensions(),253 // 'Virtualization' => (phodevi_cpu::virtualization_technology() ? phodevi_cpu::virtualization_technology() : ''),254 'Cache Size' => phodevi::read_property('cpu', 'cache-size-string'),255 'Microcode'=> phodevi::read_property('cpu', 'microcode-version'),256 'Scaling Driver'=> phodevi::read_property('cpu', 'scaling-governor'),257 ),258 'Graphics' => phodevi::read_name('gpu'),259 array(260 'OpenGL' => phodevi::read_property('system', 'opengl-driver'),261 'Vulkan' => phodevi::read_property('system', 'vulkan-driver'),262 'OpenCL' => phodevi::read_property('system', 'opencl-driver'),263 'Display Driver' => phodevi::read_property('system', 'display-driver-string'),264 'Monitor' => phodevi::read_name('monitor'),265 'Screen' => phodevi::read_property('gpu', 'screen-resolution-string'),266 ),267 'Motherboard' => phodevi::read_name('motherboard'),268 array(269 'Memory' => phodevi::read_name('memory'),270 'Chipset' => phodevi::read_name('chipset'),271 'Audio' => phodevi::read_name('audoo'),272 'Network' => phodevi::read_name('network'),273 ),274 'Disk' => phodevi::read_name('disk'),275 array(276 'File-System' => phodevi::read_property('system', 'filesystem'),277 'Mount Options' => phodevi::read_property('disk', 'mount-options-string'),278 'Disk Scheduler' => phodevi::read_property('disk', 'scheduler'),279 'Disk Details' => phodevi::read_property('disk', 'extra-disk-details'),280 ),281 'Operating System' => phodevi::read_property('system', 'operating-system'),282 array(283 'Kernel' => phodevi::read_property('system', 'kernel-string'),284 'Desktop' => phodevi::read_property('system', 'desktop-environment'),285 'Display Server' => phodevi::read_property('system', 'display-server'),286 'Compiler' => phodevi::read_property('system', 'compiler'),287 'System Layer' => phodevi::read_property('system', 'system-layer'),288 )289 );290 if($return_as_string)291 {292 $sys_string = null;293 $tabled = array();294 foreach($sys as $key => $in)295 {296 $space_in = 2;297 if(is_array($in))298 {299 $tabled = array();300 foreach($in as $key => $value)301 {302 if(!empty($value))303 {304 $tabled[] = array(pts_client::cli_just_bold($key) . ':' . str_repeat(' ', (16 - strlen($key))), $value);305 //$sys_string .= ' ' . strtoupper($key) . ':' . $value . PHP_EOL;306 }307 }308 }309 else if(!empty($in))310 {311 if(!empty($tabled))312 {313 $sys_string .= pts_user_io::display_text_table($tabled, ' ', 0, 17) . PHP_EOL;314 }315 $sys_string .= PHP_EOL . ' ' . pts_client::cli_colored_text(strtoupper($key), 'gray', true) . ': ' . str_repeat(' ', (18 - strlen($key))) . pts_client::cli_colored_text($in, 'green', true) . PHP_EOL;316 }317 }318 if(!empty($tabled))319 {320 $sys_string .= pts_user_io::display_text_table($tabled, ' ', 0, 17) . PHP_EOL;321 }322 return $sys_string;323 }324 return $sys;325 }326 public static function system_id_string()327 {328 $extra = null;329 foreach(array('CC', 'CXX', 'CFLAGS', 'CPPFLAGS', 'CXXFLAGS') as $env)330 {331 $val = getenv($env);332 if(!empty($val))333 {334 $extra .= $env . '=' . $val . ';';335 }336 }337 $components = array(phodevi::read_property('cpu', 'model'), phodevi::read_property('system', 'operating-system'), phodevi::read_property('system', 'compiler'), $extra);338 return base64_encode(implode('__', $components));339 }340 public static function read_device_notes($device)341 {342 $devices = phodevi::available_hardware_devices();343 if($device != null && isset($devices[$device]))344 {345 $notes_r = call_user_func(array('phodevi_' . $devices[$device], 'device_notes'));346 }347 else348 {349 $notes_r = array();350 }351 return is_array($notes_r) ? $notes_r : array();352 }353 public static function read_property($device, $read_property)354 {355 $value = false;356 if(method_exists('phodevi_' . $device, 'read_property'))357 {358 $property = call_user_func(array('phodevi_' . $device, 'read_property'), $read_property);359 if(!($property instanceof phodevi_device_property))360 {361 return false;362 }363 $cache_code = $property->cache_code();364 if($cache_code != phodevi::no_caching && phodevi::$allow_phodevi_caching && isset(self::$device_cache[$device][$read_property]))365 {366 $value = self::$device_cache[$device][$read_property];367 }368 else369 {370 $dev_function_r = pts_arrays::to_array($property->get_device_function());371 $dev_function = $dev_function_r[0];372 $function_pass = array();373 for($i = 1; $i < count($dev_function_r); $i++)374 {375 array_push($function_pass, $dev_function_r[$i]);376 }377 if(method_exists('phodevi_' . $device, $dev_function))378 {379 $value = call_user_func_array(array('phodevi_' . $device, $dev_function), $function_pass);380 if(!is_array($value) && $value != null)381 {382 $value = pts_strings::strip_string($value);383 if(function_exists('preg_replace'))384 {385 $value = preg_replace('/[^(\x20-\x7F)]*/','', $value);386 }387 }388 if($cache_code != phodevi::no_caching)389 {390 self::$device_cache[$device][$read_property] = $value;391 if($cache_code == phodevi::smart_caching)392 {393 // TODO: For now just copy the smart cache to other var, but come up with better yet efficient way394 self::$smart_cache[$device][$read_property] = $value;395 }396 }397 }398 }399 }400 return $value;401 }402 public static function set_property($device, $set_property, $pass_args = array())403 {404 $return_value = false;405 if(method_exists('phodevi_' . $device, 'set_property'))406 {407 $return_value = call_user_func(array('phodevi_' . $device, 'set_property'), $set_property, $pass_args);408 }409 return $return_value;410 }411 public static function create_vfs()412 {413 self::$vfs = new phodevi_vfs();414 }415 public static function initial_setup()416 {417 // Operating System Detection418 $supported_operating_systems = pts_types::operating_systems();419 $uname_s = strtolower(php_uname('s'));420 foreach($supported_operating_systems as $os_check)421 {422 for($i = 0; $i < count($os_check); $i++)423 {424 if(strpos($uname_s, strtolower($os_check[$i])) !== false) // Check for OS425 {426 self::$operating_system = $os_check[0];427 self::$operating_systems[strtolower($os_check[0])] = true;428 break;429 }430 }431 if(self::$operating_system != null)432 {433 break;434 }435 }436 if(self::operating_system() == false)437 {438 self::$operating_system = 'Unknown';439 }440 self::load_sensors();441 }442 private static function detect_graphics()443 {444 if(self::$graphics_detected == true)445 {446 return;447 }448 // OpenGL / graphics detection449 $graphics_detection = array('NVIDIA', array('ATI', 'AMD', 'fglrx'), array('Mesa', 'SGI'));450 $opengl_driver = phodevi::read_property('system', 'opengl-vendor') . ' ' . phodevi::read_property('system', 'opengl-driver') . ' ' . phodevi::read_property('system', 'dri-display-driver');451 $opengl_driver = trim(str_replace('Corporation', null, $opengl_driver)); // Prevents a possible false positive for ATI being in CorporATIon452 foreach($graphics_detection as $gpu_check)453 {454 if(!is_array($gpu_check))455 {456 $gpu_check = array($gpu_check);457 }458 for($i = 0; $i < count($gpu_check); $i++)459 {460 if(stripos($opengl_driver, $gpu_check[$i]) !== false) // Check for GPU461 {462 self::$graphics[(strtolower($gpu_check[0]))] = true;463 break;464 }465 }466 }467 self::$graphics_detected = true;468 }469 public static function set_device_cache($cache_array)470 {471 if(is_array($cache_array) && !empty($cache_array))472 {473 self::$smart_cache = array_merge(self::$smart_cache, $cache_array);474 self::$device_cache = array_merge(self::$device_cache, $cache_array);475 }476 }477 public static function clear_cache()478 {479 self::$smart_cache = array();480 self::$device_cache = array();481 }482 public static function get_phodevi_cache_object($store_dir, $client_version = 0)483 {484 return new phodevi_cache(self::$smart_cache, $store_dir, $client_version);485 }486 protected static function system_information_parse($component_array, $return_as_string = true)487 {488 // Returns string of hardware information489 $info = array();490 foreach($component_array as $string => $id)491 {492 if(is_array($id) && count($id) == 2)493 {494 $value = self::read_property($id[0], $id[1]);495 }496 else497 {498 $value = self::read_name($id);499 }500 if($value != -1 && !empty($value))501 {502 $info[$string] = $value;503 }504 }505 if($return_as_string)506 {507 $info_array = $info;508 $info = null;509 foreach($info_array as $type => $value)510 {511 if($info != null)512 {...

Full Screen

Full Screen

read_name

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2$phodevi = new phodevi();3echo $phodevi->read_name();4require_once('phodevi.php');5$phodevi = new phodevi();6echo $phodevi->read_name();7require_once('phodevi.php');8$phodevi = new phodevi();9echo $phodevi->read_name();10require_once('phodevi.php');11$phodevi = new phodevi();12echo $phodevi->read_name();13require_once('phodevi.php');14$phodevi = new phodevi();15echo $phodevi->read_name();16require_once('phodevi.php');17$phodevi = new phodevi();18echo $phodevi->read_name();19require_once('phodevi.php');20$phodevi = new phodevi();21echo $phodevi->read_name();22require_once('phodevi.php');23$phodevi = new phodevi();24echo $phodevi->read_name();25require_once('phodevi.php');26$phodevi = new phodevi();27echo $phodevi->read_name();28require_once('phodevi.php');29$phodevi = new phodevi();30echo $phodevi->read_name();31require_once('phodevi.php');32$phodevi = new phodevi();33echo $phodevi->read_name();

Full Screen

Full Screen

read_name

Using AI Code Generation

copy

Full Screen

1require_once('phodevi.php');2$phodevi = new phodevi();3echo $phodevi->read_name();4require_once('phodevi.php');5$phodevi = new phodevi();6echo $phodevi->read_name();

Full Screen

Full Screen

read_name

Using AI Code Generation

copy

Full Screen

1$phodevi = new phodevi();2$name = $phodevi->read_name();3echo $name;4$phodevi = new phodevi();5$name = $phodevi->read_name();6echo $name;7$phodevi = new phodevi();8$name = $phodevi->read_name();9echo $name;10$phodevi = new phodevi();11$name = $phodevi->read_name();12echo $name;13$phodevi = new phodevi();14$name = $phodevi->read_name();15echo $name;16$phodevi = new phodevi();17$name = $phodevi->read_name();18echo $name;19$phodevi = new phodevi();20$name = $phodevi->read_name();21echo $name;22$phodevi = new phodevi();23$name = $phodevi->read_name();24echo $name;25$phodevi = new phodevi();26$name = $phodevi->read_name();27echo $name;28$phodevi = new phodevi();29$name = $phodevi->read_name();30echo $name;31$phodevi = new phodevi();32$name = $phodevi->read_name();33echo $name;34$phodevi = new phodevi();

Full Screen

Full Screen

read_name

Using AI Code Generation

copy

Full Screen

1require_once 'phodevi.php';2$phodevi = new phodevi();3echo $phodevi->read_name();4require_once 'phodevi.php';5$phodevi = new phodevi();6echo $phodevi->read_name();7require_once 'phodevi.php';8$phodevi = new phodevi();9echo $phodevi->read_name();10require_once 'phodevi.php';11$phodevi = new phodevi();12echo $phodevi->read_name();13require_once 'phodevi.php';14$phodevi = new phodevi();15echo $phodevi->read_name();16require_once 'phodevi.php';17$phodevi = new phodevi();18echo $phodevi->read_name();19require_once 'phodevi.php';20$phodevi = new phodevi();21echo $phodevi->read_name();22require_once 'phodevi.php';23$phodevi = new phodevi();24echo $phodevi->read_name();25require_once 'phodevi.php';26$phodevi = new phodevi();27echo $phodevi->read_name();28require_once 'phodevi.php';29$phodevi = new phodevi();30echo $phodevi->read_name();31require_once 'phodevi.php';32$phodevi = new phodevi();33echo $phodevi->read_name();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful