当前位置: 首页>>代码示例>>PHP>>正文


PHP pts_strings::remove_line_timestamps方法代码示例

本文整理汇总了PHP中pts_strings::remove_line_timestamps方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::remove_line_timestamps方法的具体用法?PHP pts_strings::remove_line_timestamps怎么用?PHP pts_strings::remove_line_timestamps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pts_strings的用法示例。


在下文中一共展示了pts_strings::remove_line_timestamps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __get

 public function __get($name)
 {
     // This assumes that isset() has been called on $name prior to actually trying to get it...
     if (isset($this->cache[$name])) {
         return PHP_EOL . $this->cache[$name] . PHP_EOL;
     } else {
         if (PTS_IS_CLIENT && isset($this->options[$name])) {
             if (isset($this->options[$name]['type'])) {
                 $tries = array($this->options[$name]);
             } else {
                 $tries = $this->options[$name];
             }
             $contents = null;
             foreach ($tries as &$try) {
                 if ($try['type'] == 'F' && isset($try['F'][4]) && substr($try['F'], 0, 2) == '~/') {
                     // Set the home directory
                     $try['F'] = str_replace('~/', pts_core::user_home_directory(), $try['F']);
                 }
                 if ($try['type'] == 'F' && is_file($try['F'])) {
                     $contents = file_get_contents($try['F']);
                 } else {
                     if ($try['type'] == 'C') {
                         $command = pts_client::executable_in_path(pts_strings::first_in_string($try['C']));
                         if ($command != null) {
                             $descriptor_spec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
                             $proc = proc_open($try['C'], $descriptor_spec, $pipes, null, null);
                             $contents = stream_get_contents($pipes[1]);
                             fclose($pipes[1]);
                             $return_value = proc_close($proc);
                         }
                     }
                 }
                 if (isset($try['remove_timestamps']) && $try['remove_timestamps']) {
                     // remove leading timestamps such as from dmesg and Xorg.0.log
                     $contents = pts_strings::remove_line_timestamps($contents);
                 }
                 if ($contents != null) {
                     if ($try['cacheable']) {
                         $this->cache[$name] = $contents;
                     }
                     return PHP_EOL . $contents . PHP_EOL;
                 }
             }
         }
     }
     return false;
 }
开发者ID:ShaolongHu,项目名称:phoronix-test-suite,代码行数:47,代码来源:phodevi_vfs.php

示例2: save_test_result

 public static function save_test_result($save_to = null, $save_results = null, $render_graphs = true, $result_identifier = null)
 {
     // Saves PTS result file
     if (substr($save_to, -4) != '.xml') {
         $save_to .= '.xml';
     }
     $save_to = str_replace(PTS_SAVE_RESULTS_PATH, null, $save_to);
     $save_to_dir = pts_client::setup_test_result_directory($save_to);
     if ($save_to == null || $save_results == null) {
         $bool = false;
     } else {
         $save_name = basename($save_to, '.xml');
         if ($save_name == 'composite' && $render_graphs) {
             pts_client::generate_result_file_graphs($save_results, $save_to_dir);
         }
         $bool = file_put_contents(PTS_SAVE_RESULTS_PATH . $save_to, $save_results);
         if ($result_identifier != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveSystemLogs', 'TRUE')) {
             // Save verbose system information here
             $system_log_dir = $save_to_dir . '/system-logs/' . $result_identifier . '/';
             pts_file_io::mkdir($system_log_dir, 0777, true);
             // Backup system files
             // TODO: move out these files/commands to log out to respective Phodevi components so only what's relevant will be logged
             $system_log_files = array('/var/log/Xorg.0.log', '/proc/cpuinfo', '/proc/meminfo', '/proc/modules', '/proc/mounts', '/proc/cmdline', '/proc/version', '/proc/mdstat', '/etc/X11/xorg.conf', '/sys/kernel/debug/dri/0/radeon_pm_info', '/sys/kernel/debug/dri/0/i915_capabilities', '/sys/kernel/debug/dri/0/i915_cur_delayinfo', '/sys/kernel/debug/dri/0/i915_drpc_info', '/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies');
             /*
             if(phodevi::is_linux())
             {
             	// the kernel config file might just be too large to upload for now
             	array_push($system_log_files, '/boot/config-' . php_uname('r'));
             }
             */
             foreach ($system_log_files as $file) {
                 if (is_file($file) && is_readable($file)) {
                     // copy() can't be used in this case since it will result in a blank file for /proc/ file-system
                     $file_contents = file_get_contents($file);
                     $file_contents = pts_strings::remove_line_timestamps($file_contents);
                     file_put_contents($system_log_dir . basename($file), $file_contents);
                 }
             }
             // Generate logs from system commands to backup
             $system_log_commands = array('lspci -mmkvvvnn', 'lscpu', 'cc -v', 'lsusb', 'lsmod', 'sensors', 'dmesg', 'vdpauinfo', 'cpufreq-info', 'glxinfo', 'clinfo', 'uname -a', 'upower --dump');
             if (phodevi::is_bsd()) {
                 array_push($system_log_commands, 'sysctl -a');
                 array_push($system_log_commands, 'kenv');
             }
             if (is_readable('/dev/mem')) {
                 array_push($system_log_commands, 'dmidecode');
             }
             foreach ($system_log_commands as $command_string) {
                 $command = explode(' ', $command_string);
                 if ($command_bin = pts_client::executable_in_path($command[0])) {
                     $cmd_output = shell_exec('cd ' . dirname($command_bin) . ' && ./' . $command_string . ' 2>&1');
                     // Try to filter out any serial numbers, etc.
                     phodevi_vfs::cleanse_file($cmd_output, $command[0]);
                     $cmd_output = pts_strings::remove_line_timestamps($cmd_output);
                     file_put_contents($system_log_dir . $command[0], $cmd_output);
                 }
             }
             // Dump some common / important environmental variables
             $environment_variables = array('PATH' => null, 'CFLAGS' => null, 'CXXFLAGS' => null, 'LD_LIBRARY_PATH' => null, 'CC' => null, 'CXX' => null, 'LIBGL_DRIVERS_PATH' => null);
             foreach ($environment_variables as $variable => &$value) {
                 $v = getenv($variable);
                 if ($v != null) {
                     $value = $v;
                 } else {
                     unset($environment_variables[$variable]);
                 }
             }
             if (!empty($environment_variables)) {
                 $variable_dump = null;
                 foreach ($environment_variables as $variable => $value) {
                     $variable_dump .= $variable . '=' . $value . PHP_EOL;
                 }
                 file_put_contents($system_log_dir . 'environment-variables', $variable_dump);
             }
         }
     }
     return $bool;
 }
开发者ID:Grdflo,项目名称:phoronix-test-suite,代码行数:78,代码来源:pts_client.php


注:本文中的pts_strings::remove_line_timestamps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。