本文整理汇总了PHP中pts_client::executable_in_path方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::executable_in_path方法的具体用法?PHP pts_client::executable_in_path怎么用?PHP pts_client::executable_in_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::executable_in_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read_osx_system_profiler
public static function read_osx_system_profiler($data_type, $object, $multiple_objects = false, $ignore_values = array())
{
$value = $multiple_objects ? array() : false;
if (pts_client::executable_in_path('system_profiler')) {
$info = trim(shell_exec('system_profiler ' . $data_type . ' 2>&1'));
$lines = explode("\n", $info);
for ($i = 0; $i < count($lines) && ($value == false || $multiple_objects); $i++) {
$line = pts_strings::colon_explode($lines[$i]);
if (isset($line[0]) == false) {
continue;
}
$line_object = str_replace(' ', null, $line[0]);
if (($cut_point = strpos($line_object, '(')) > 0) {
$line_object = substr($line_object, 0, $cut_point);
}
if (strtolower($line_object) == strtolower($object) && isset($line[1])) {
$this_value = trim($line[1]);
if (!empty($this_value) && !in_array($this_value, $ignore_values)) {
if ($multiple_objects) {
array_push($value, $this_value);
} else {
$value = $this_value;
}
}
}
}
}
return $value;
}
示例2: what_provides
public static function what_provides($files_needed)
{
$packages_needed = array();
foreach (pts_arrays::to_array($files_needed) as $file) {
if (pts_client::executable_in_path('apt-file')) {
if (!defined('APT_FILE_UPDATED')) {
shell_exec('apt-file update 2>&1');
define('APT_FILE_UPDATED', 1);
}
// Try appending common paths
if (strpos($file, '.h') !== false) {
$apt_provides = self::run_apt_file_provides('/usr/include/' . $file);
if ($apt_provides != null) {
$packages_needed[$file] = $apt_provides;
}
} else {
if (strpos($file, '.so') !== false) {
$apt_provides = self::run_apt_file_provides('/usr/lib/' . $file);
if ($apt_provides != null) {
$packages_needed[$file] = $apt_provides;
}
} else {
foreach (array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path) {
$apt_provides = self::run_apt_file_provides($possible_path . $file);
if ($apt_provides != null) {
$packages_needed[$file] = $apt_provides;
break;
}
}
}
}
}
}
return $packages_needed;
}
示例3: generate_download_object_list
public function generate_download_object_list($do_file_checks = true)
{
$download_xml_file = $this->test_profile->get_file_download_spec();
if ($download_xml_file != null) {
$xml_parser = new pts_test_downloads_nye_XmlReader($download_xml_file);
$package_url = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/URL');
$package_md5 = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/MD5');
$package_sha256 = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/SHA256');
$package_filename = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/FileName');
$package_filesize = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/FileSize');
$package_platform = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/PlatformSpecific');
$package_architecture = $xml_parser->getXMLArrayValues('PhoronixTestSuite/Downloads/Package/ArchitectureSpecific');
foreach (array_keys($package_url) as $i) {
if (!empty($package_platform[$i]) && $do_file_checks) {
$platforms = pts_strings::comma_explode($package_platform[$i]);
if (!in_array(phodevi::operating_system(), $platforms) && !(phodevi::is_bsd() && in_array('Linux', $platforms) && (pts_client::executable_in_path('kldstat') && strpos(shell_exec('kldstat -n linux 2>&1'), 'linux.ko') != false))) {
// This download does not match the operating system
continue;
}
}
if (!empty($package_architecture[$i]) && $do_file_checks) {
$architectures = pts_strings::comma_explode($package_architecture[$i]);
if (phodevi::cpu_arch_compatible($architectures) == false) {
// This download does not match the CPU architecture
continue;
}
}
$this->test_files[] = new pts_test_file_download($package_url[$i], $package_filename[$i], $package_filesize[$i], $package_md5[$i], $package_sha256[$i], $package_platform[$i], $package_architecture[$i]);
}
}
}
示例4: net_counter
private static function net_counter($IFACE = 'en0')
{
$net_counter = -1;
if (pts_client::executable_in_path('netstat') != false) {
$netstat_lines = explode("\n", shell_exec('netstat -ib 2>&1'));
$ibytes_index = -1;
$obytes_index = -1;
$ibytes = -1;
$obytes = -1;
foreach ($netstat_lines as $line) {
if (strtok($line, ' ') == 'Name') {
$ibytes_index = strpos($line, 'Ierrs') + 6;
$obytes_index = strpos($line, 'Oerrs') + 6;
continue;
}
//$netstat_data = pts_strings::trim_explode(' ', $line);
/*
* Sample output:
* Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll
* en0 1500 <Link#4> 00:25:4b:c5:95:66 23350 0 19111634 13494 0 1632167 0
*/
if (strtok($line, ' ') == $IFACE) {
$ibytes = strtok(substr($line, $ibytes_index), ' ');
$obytes = strtok(substr($line, $obytes_index), ' ');
$net_counter = $ibytes + $obytes;
}
if ($ibytes != -1 && $obytes != -1) {
break;
}
}
}
return $net_counter;
}
示例5: __run_manager_setup
public static function __run_manager_setup(&$test_run_manager)
{
// Verify LINUX_PERF is set, `perf` can be found, and is Linux
if (getenv('LINUX_PERF') == 0 || !pts_client::executable_in_path('perf') || !phodevi::is_linux()) {
return pts_module::MODULE_UNLOAD;
// This module doesn't have anything else to do
}
echo PHP_EOL . 'Linux PERF Monitoring Enabled.' . PHP_EOL . PHP_EOL;
// This module won't be too useful if you're not saving the results to see the graphs
$test_run_manager->force_results_save();
}
示例6: read_acpiconf
public static function read_acpiconf($desc)
{
$info = false;
if (pts_client::executable_in_path('acpiconf 2> /dev/null')) {
$output = shell_exec('acpiconf -i0');
if (($point = strpos($output, $desc . ':')) !== false) {
$info = substr($output, $point + strlen($desc) + 1);
$info = substr($info, 0, strpos($info, "\n"));
$info = trim($info);
}
}
return $info;
}
示例7: read_hal_property
public static function read_hal_property($udi, $key)
{
$value = false;
if (pts_client::executable_in_path('hal-get-property')) {
foreach (pts_arrays::to_array($udi) as $udi_check) {
$value = trim(shell_exec('hal-get-property --udi ' . $udi_check . ' --key ' . $key . ' 2> /dev/null'));
if ($value != false) {
break;
}
}
}
return $value;
}
示例8: __startup
public static function __startup()
{
// Make sure the file is removed to avoid potential problems if it was leftover from earlier run
pts_module::remove_file('is_running');
if (pts_client::executable_in_path('import') == false) {
echo PHP_EOL . 'ImageMagick must first be installed onto this system!' . PHP_EOL;
return pts_module::MODULE_UNLOAD;
}
if (($interval = pts_module::read_variable('SCREENSHOT_INTERVAL')) > 1 && is_numeric($interval)) {
self::$screenshot_interval = $interval;
return true;
}
return pts_module::MODULE_UNLOAD;
self::$existing_screenshots = pts_file_io::glob(pts_module::save_dir() . 'screenshot-*.png');
}
示例9: send_wol_wakeup
protected function send_wol_wakeup($mac, $ip)
{
$sent_wol_request = false;
if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
foreach (array('etherwake', 'ether-wake') as $etherwake) {
if (pts_client::executable_in_path($etherwake)) {
shell_exec($etherwake . ' ' . $mac . ' 2>&1');
$sent_wol_request = true;
sleep(5);
break;
}
}
}
if (true || $sent_wol_request == false) {
pts_network::send_wol_packet($ip, $mac);
$sent_wol_request = true;
}
return $sent_wol_request;
}
示例10: set_probe_mode
private function set_probe_mode()
{
if (phodevi::is_ati_graphics() && phodevi::is_linux()) {
$this->probe_ati_overdrive = true;
} else {
if (phodevi::is_mesa_graphics() && pts_client::executable_in_path('radeontop')) {
$this->probe_radeontop = true;
} else {
if (phodevi::is_nvidia_graphics()) {
$util = $this->read_nvidia_settings_gpu_utilization();
if ($util !== false) {
$this->probe_nvidia_settings = true;
} else {
if (pts_client::executable_in_path('nvidia-smi')) {
$this->probe_nvidia_smi = true;
}
}
}
}
}
}
示例11: process_user_config_external_hook_process
protected static function process_user_config_external_hook_process($process, $cmd_value, $description_string = null, &$passed_obj = null)
{
if (!empty($cmd_value) && (is_executable($cmd_value) || ($cmd_value = pts_client::executable_in_path($cmd_value)))) {
$descriptor_spec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$env_vars = array('PTS_EXTERNAL_TEST_HOOK' => $process);
if ($passed_obj instanceof pts_test_result) {
$env_vars['PTS_EXTERNAL_TEST_IDENTIFIER'] = $passed_obj->test_profile->get_identifier();
$env_vars['PTS_EXTERNAL_TEST_RUN_POSITION'] = $passed_obj->test_result_buffer->get_count() + 1;
$env_vars['PTS_EXTERNAL_TEST_RUN_COUNT'] = $passed_obj->test_profile->get_times_to_run();
$env_vars['PTS_EXTERNAL_TEST_ARGS'] = $passed_obj->get_arguments();
$env_vars['PTS_EXTERNAL_TEST_DESCRIPTION'] = $passed_obj->get_arguments_description();
$env_vars['PTS_EXTERNAL_TEST_RESULT_SET'] = $passed_obj->test_result_buffer->get_values_as_string();
$env_vars['PTS_EXTERNAL_TEST_RESULT'] = $passed_obj->get_result() != 0 ? $passed_obj->get_result() : pts_arrays::last_element($passed_obj->test_result_buffer->get_values());
$env_vars['PTS_EXTERNAL_TEST_HASH'] = bin2hex($passed_obj->get_comparison_hash());
$env_vars['PTS_EXTERNAL_TEST_STD_DEV_PERCENT'] = pts_math::percent_standard_deviation($passed_obj->test_result_buffer->get_values());
if (is_file($passed_obj->test_profile->get_install_dir() . 'cache-share-' . PTS_INIT_TIME . '.pt2so')) {
// There's a cache share present
$env_vars['PTS_EXTERNAL_TEST_CACHE_SHARE'] = 1;
}
} else {
if ($passed_obj instanceof pts_test_run_manager) {
$env_vars['PTS_EXTERNAL_TESTS_IN_QUEUE'] = implode(':', $passed_obj->get_tests_to_run_identifiers());
$env_vars['PTS_EXTERNAL_TEST_FILE_NAME'] = $passed_obj->get_file_name();
$env_vars['PTS_EXTERNAL_TEST_IDENTIFIER'] = $passed_obj->get_results_identifier();
}
}
$description_string != null && pts_client::$display->test_run_instance_error($description_string);
$proc = proc_open($cmd_value, $descriptor_spec, $pipes, null, $env_vars);
$std_output = stream_get_contents($pipes[1]);
$return_value = proc_close($proc);
// If you want PTS to exit or something when your script returns !0, you could add an 'exit;' or whatever you want below
// The contents of $std_output is anything that may have been written by your script, if you want it to be interpreted by anything in this module
if ($return_value != 0) {
return false;
}
}
return true;
}
示例12: what_provides
public static function what_provides($files_needed)
{
$packages_needed = array();
foreach (pts_arrays::to_array($files_needed) as $file) {
if (pts_client::executable_in_path('dnf')) {
$dnf_provides = self::run_dnf_provides($file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
} else {
// Try appending common paths
if (strpos($file, '.h') !== false) {
$dnf_provides = self::run_dnf_provides('/usr/include/' . $file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
}
} else {
if (strpos($file, '.so') !== false) {
$dnf_provides = self::run_dnf_provides('/usr/lib/' . $file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
}
} else {
foreach (array('/usr/bin/', '/bin/', '/usr/sbin') as $possible_path) {
$dnf_provides = self::run_dnf_provides($possible_path . $file);
if ($dnf_provides != null) {
$packages_needed[$file] = $dnf_provides;
break;
}
}
}
}
}
}
}
return $packages_needed;
}
示例13: create_compiler_mask
public static function create_compiler_mask(&$test_install_request)
{
if (phodevi::is_bsd()) {
// XXX: Using the compiler-mask causes a number of tests to fail to properly install due to compiler issues with at least PC-BSD 10.0
return false;
}
// or pass false to $test_install_request to bypass the test checks
$compilers = array();
$external_dependencies = $test_install_request != false ? $test_install_request->test_profile->get_external_dependencies() : false;
if ($test_install_request === false || in_array('build-utilities', $external_dependencies)) {
// Handle C/C++ compilers for this external dependency
$compilers['CC'] = array(pts_strings::first_in_string(pts_client::read_env('CC'), ' '), 'gcc', 'clang', 'icc', 'pcc');
$compilers['CXX'] = array(pts_strings::first_in_string(pts_client::read_env('CXX'), ' '), 'g++', 'clang++', 'cpp');
}
if ($test_install_request === false || in_array('fortran-compiler', $external_dependencies)) {
// Handle Fortran for this external dependency
$compilers['F9X'] = array(pts_strings::first_in_string(pts_client::read_env('F9X'), ' '), pts_strings::first_in_string(pts_client::read_env('F95'), ' '), 'gfortran', 'f90', 'f95', 'fortran');
}
if (empty($compilers)) {
// If the test profile doesn't request a compiler external dependency, probably not compiling anything
return false;
}
foreach ($compilers as $compiler_type => $possible_compilers) {
// Compilers to check for, listed in order of priority
$compiler_found = false;
foreach ($possible_compilers as $i => $possible_compiler) {
// first check to ensure not null sent to executable_in_path from env variable
if ($possible_compiler && (($compiler_path = is_executable($possible_compiler)) || ($compiler_path = pts_client::executable_in_path($possible_compiler, 'ccache')))) {
// Replace the array of possible compilers with a string to the detected compiler executable
$compilers[$compiler_type] = $compiler_path;
$compiler_found = true;
break;
}
}
if ($compiler_found == false) {
unset($compilers[$compiler_type]);
}
}
if (!empty($compilers)) {
// Create a temporary directory that will be at front of PATH and serve for masking the actual compiler
if ($test_install_request instanceof pts_test_install_request) {
$mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . $test_install_request->test_profile->get_identifier_base_name() . $test_install_request->test_profile->get_test_profile_version() . '/';
} else {
$mask_dir = pts_client::temporary_directory() . '/pts-compiler-mask-' . rand(100, 999) . '/';
}
pts_file_io::mkdir($mask_dir);
$compiler_extras = array('CC' => array('safeguard-names' => array('gcc', 'cc'), 'environment-variables' => 'CFLAGS'), 'CXX' => array('safeguard-names' => array('g++', 'c++'), 'environment-variables' => 'CXXFLAGS'), 'F9X' => array('safeguard-names' => array('gfortran', 'f95'), 'environment-variables' => 'F9XFLAGS'));
foreach ($compilers as $compiler_type => $compiler_path) {
$compiler_name = basename($compiler_path);
$main_compiler = $mask_dir . $compiler_name;
// take advantage of environment-variables to be sure they're found in the string
$env_var_check = PHP_EOL;
/*
foreach(pts_arrays::to_array($compiler_extras[$compiler_type]['environment-variables']) as $env_var)
{
// since it's a dynamic check in script could probably get rid of this check...
if(true || getenv($env_var))
{
$env_var_check .= 'if [[ $COMPILER_OPTIONS != "*$' . $env_var . '*" ]]' . PHP_EOL . 'then ' . PHP_EOL . 'COMPILER_OPTIONS="$COMPILER_OPTIONS $' . $env_var . '"' . PHP_EOL . 'fi' . PHP_EOL;
}
}
*/
// Write the main mask for the compiler
file_put_contents($main_compiler, '#!/bin/bash' . PHP_EOL . 'COMPILER_OPTIONS="$@"' . PHP_EOL . $env_var_check . PHP_EOL . 'echo $COMPILER_OPTIONS >> ' . $mask_dir . $compiler_type . '-options-' . $compiler_name . PHP_EOL . $compiler_path . ' "$@"' . PHP_EOL);
// Make executable
chmod($main_compiler, 0755);
// The two below code chunks ensure the proper compiler is always hit
if ($test_install_request instanceof pts_test_install_request && !in_array($compiler_name, pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names'])) && getenv($compiler_type) == false) {
// So if e.g. clang becomes the default compiler, since it's not GCC, it will ensure CC is also set to clang beyond the masking below
$test_install_request->special_environment_vars[$compiler_type] = $compiler_name;
}
// Just in case any test profile script is statically always calling 'gcc' or anything not CC, try to make sure it hits one of the safeguard-names so it redirects to the intended compiler under test
foreach (pts_arrays::to_array($compiler_extras[$compiler_type]['safeguard-names']) as $safe_name) {
if (!is_file($mask_dir . $safe_name)) {
symlink($main_compiler, $mask_dir . $safe_name);
}
}
}
if ($test_install_request instanceof pts_test_install_request) {
$test_install_request->compiler_mask_dir = $mask_dir;
// Appending the rest of the path will be done automatically within call_test_script
$test_install_request->special_environment_vars['PATH'] = $mask_dir;
}
return $mask_dir;
}
return false;
}
示例14: vendor_identifier
private static function vendor_identifier($type)
{
$os_vendor = phodevi::read_property('system', 'vendor-identifier');
switch ($type) {
case 'package-list':
$file_check_success = is_file(PTS_EXDEP_PATH . 'xml/' . $os_vendor . '-packages.xml');
break;
case 'installer':
$file_check_success = is_file(PTS_EXDEP_PATH . 'scripts/install-' . $os_vendor . '-packages.sh');
break;
}
if ($file_check_success == false) {
// Check the aliases to figure out the upstream distribution
$os_vendor = false;
$exdep_generic_parser = new pts_exdep_generic_parser();
foreach ($exdep_generic_parser->get_vendors_list() as $this_vendor) {
$exdep_platform_parser = new pts_exdep_platform_parser($this_vendor);
$aliases = $exdep_platform_parser->get_aliases();
if (in_array($os_vendor, $aliases)) {
$os_vendor = $this_vendor;
break;
}
}
if ($os_vendor == false) {
// Attempt to match the current operating system by seeing what package manager matches
foreach ($exdep_generic_parser->get_vendors_list() as $this_vendor) {
$exdep_platform_parser = new pts_exdep_platform_parser($this_vendor);
$package_manager = $exdep_platform_parser->get_package_manager();
if ($package_manager != null && pts_client::executable_in_path($package_manager)) {
$os_vendor = $this_vendor;
break;
}
}
}
}
return $os_vendor;
}
示例15: run_connection
public static function run_connection($args)
{
if (pts_client::create_lock(PTS_USER_PATH . 'phoromatic_lock') == false) {
trigger_error('Phoromatic is already running.', E_USER_ERROR);
return false;
}
define('PHOROMATIC_PROCESS', true);
if (pts_client::$pts_logger == false) {
pts_client::$pts_logger = new pts_logger();
}
pts_client::$pts_logger->log(pts_title(true) . ' [' . PTS_CORE_VERSION . '] starting Phoromatic client');
if (phodevi::system_uptime() < 60) {
echo 'PHOROMATIC: Sleeping for 60 seconds as system freshly started.' . PHP_EOL;
pts_client::$pts_logger->log('Sleeping for 60 seconds as system freshly started');
sleep(60);
}
$server_setup = self::setup_server_addressing($args);
//$http_comm = new phoromatic_client_comm_http();
if (!$server_setup) {
if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
if (pts_client::executable_in_path('reboot')) {
shell_exec('reboot');
sleep(5);
}
}
return false;
}
$times_failed = 0;
$has_success = false;
$do_exit = false;
$just_started = true;
self::setup_system_environment();
pts_client::$pts_logger->log('SYSTEM HARDWARE: ' . phodevi::system_hardware(true));
pts_client::$pts_logger->log('SYSTEM SOFTWARE: ' . phodevi::system_software(true));
while ($do_exit == false) {
$server_response = phoromatic::upload_to_remote_server(array('r' => 'start'));
if ($server_response == false) {
$times_failed++;
pts_client::$pts_logger->log('Server response failed');
if ($times_failed >= 2) {
trigger_error('Communication with server failed.', E_USER_ERROR);
if (PTS_IS_DAEMONIZED_SERVER_PROCESS == false && $times_failed > 5) {
return false;
} else {
if (PTS_IS_DAEMONIZED_SERVER_PROCESS && $times_failed > 10) {
if (pts_client::executable_in_path('reboot')) {
shell_exec('reboot');
sleep(5);
}
}
}
}
} else {
if (substr($server_response, 0, 1) == '[') {
// Likely a notice/warning from server
echo PHP_EOL . substr($server_response, 0, strpos($server_response, PHP_EOL)) . PHP_EOL;
} else {
if (substr($server_response, 0, 1) == '{') {
$times_failed = 0;
$json = json_decode($server_response, true);
if ($has_success == false) {
$has_success = true;
pts_module::save_file('last-phoromatic-server', self::$server_address . ':' . self::$server_http_port . '/' . self::$account_id);
}
if ($json != null) {
if (isset($json['phoromatic']['error']) && !empty($json['phoromatic']['error'])) {
trigger_error($json['phoromatic']['error'], E_USER_ERROR);
}
if (isset($json['phoromatic']['response']) && !empty($json['phoromatic']['response'])) {
echo PHP_EOL . $json['phoromatic']['response'] . PHP_EOL;
}
}
if ($just_started) {
if (PTS_IS_DAEMONIZED_SERVER_PROCESS) {
$pid = pcntl_fork();
if ($pid == 0) {
// Start the tick thread
self::tick_thread();
}
}
$just_started = false;
}
if (isset($json['phoromatic']['pre_set_sys_env_vars']) && !empty($json['phoromatic']['pre_set_sys_env_vars'])) {
// pre_set_sys_env_vars was added during PTS 5.8 development
// Sets environment variables on client as specified via the Phoromatic Server's systems page
foreach (explode(';', $json['phoromatic']['pre_set_sys_env_vars']) as $i => $v_string) {
$var = explode('=', $v_string);
if (count($var) == 2) {
putenv($var[0] . '=' . $var[1]);
}
}
}
switch (isset($json['phoromatic']['task']) ? $json['phoromatic']['task'] : null) {
case 'install':
phoromatic::update_system_status('Installing Tests');
pts_suite_nye_XmlReader::set_temporary_suite('pre-seed', $json['phoromatic']['test_suite']);
pts_test_installer::standard_install('pre-seed');
break;
case 'benchmark':
// Make sure all latest tests are available
//.........这里部分代码省略.........