本文整理汇总了PHP中pts_file_io::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_file_io::delete方法的具体用法?PHP pts_file_io::delete怎么用?PHP pts_file_io::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_file_io
的用法示例。
在下文中一共展示了pts_file_io::delete方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
$result_file = new pts_result_file($r[0]);
$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));
$result_file->remove_run($remove_identifiers);
$result_dir = dirname($result_file->get_file_location()) . '/';
foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
foreach ($remove_identifiers as $remove_identifier) {
if (is_dir($result_dir . $dir_name . '/' . $remove_identifier)) {
pts_file_io::delete($result_dir . $dir_name . '/' . $remove_identifier, null, true);
}
}
}
pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
pts_client::display_web_page($result_dir . '/index.html');
}
示例3: setup_test_install_directory
protected static function setup_test_install_directory(&$test_install_request, $remove_old_files = false)
{
$identifier = $test_install_request->test_profile->get_identifier();
pts_file_io::mkdir($test_install_request->test_profile->get_install_dir());
if ($remove_old_files) {
// Remove any (old) files that were installed
$ignore_files = array('pts-install.xml', 'install-failed.log');
foreach ($test_install_request->get_download_objects() as $download_object) {
$ignore_files[] = $download_object->get_filename();
}
pts_file_io::delete($test_install_request->test_profile->get_install_dir(), $ignore_files);
}
pts_file_io::symlink(pts_core::user_home_directory() . '.Xauthority', $test_install_request->test_profile->get_install_dir() . '.Xauthority');
pts_file_io::symlink(pts_core::user_home_directory() . '.drirc', $test_install_request->test_profile->get_install_dir() . '.drirc');
}
示例4: remove_saved_result_file
public static function remove_saved_result_file($identifier)
{
pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $identifier, null, true);
}
示例5: run
public static function run($r)
{
$_REQUEST['force_format'] = 'PNG';
// Force to PNG renderer
$_REQUEST['svg_dom_gd_no_interlacing'] = true;
// Otherwise FPDF will fail
$tdir = pts_client::create_temporary_directory();
pts_client::generate_result_file_graphs($r[0], $tdir);
$result_file = new pts_result_file($r[0]);
$pdf = new pts_pdf_template($result_file->get_title(), null);
$pdf->AddPage();
$pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38);
$pdf->Ln(120);
$pdf->WriteStatementCenter('www.phoronix-test-suite.com');
$pdf->Ln(15);
$pdf->WriteBigHeaderCenter($result_file->get_title());
$pdf->WriteText($result_file->get_description());
$pdf->AddPage();
$pdf->Ln(15);
$pdf->SetSubject($result_file->get_title() . ' Benchmarks');
//$pdf->SetKeywords(implode(', ', $identifiers));
$pdf->WriteHeader('Test Systems:');
foreach ($result_file->get_systems() as $s) {
$pdf->WriteMiniHeader($s->get_identifier());
$pdf->WriteText($s->get_hardware());
$pdf->WriteText($s->get_software());
//$pdf->WriteText($notes_r[$i]);
}
/*
if(count($identifiers) > 1 && is_file($tdir . 'result-graphs/overview.jpg'))
{
$pdf->AddPage();
$pdf->Ln(100);
$pdf->Image($tdir . 'result-graphs/overview.jpg', 15, 40, 180);
}
*/
$pdf->AddPage();
$placement = 1;
$results = $result_file->get_result_objects();
for ($i = 1; $i <= count($results); $i++) {
if (is_file($tdir . 'result-graphs/' . $i . '.png')) {
$pdf->Ln(100);
$pdf->Image($tdir . 'result-graphs/' . $i . '.png', 50, 40 + ($placement - 1) * 120, 120);
}
if ($placement == 2) {
$placement = 0;
if ($i != count($results)) {
$pdf->AddPage();
}
}
$placement++;
}
// To save:
/*
$pdf_file = 'SAVE_TO';
if(substr($pdf_file, -4) != '.pdf')
{
$pdf_file .= '.pdf';
}
*/
$pdf_file = pts_client::user_home_directory() . $r[0] . '.pdf';
$pdf->Output($pdf_file);
pts_file_io::delete($tdir, null, true);
echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL;
}
示例6: custom_test_support_check
public function custom_test_support_check()
{
/*
As of Phoronix Test Suite 4.4, the software will check for the presence of a 'support-check' file.
Any test profile can optionally include a support-check.sh file to check for arbitrary commands not covered by
the rest of the PTS testing architecture, e.g. to check for the presence of systemd on the target system. If
the script finds that the system is incompatible with the test, it can write a custom error message to the file
specified by the $TEST_CUSTOM_ERROR environment variable. If the $TEST_CUSTOM_ERROR target is written to, the PTS
client will abort the test installation with the specified error message.
*/
$support_check_file = $this->get_resource_dir() . 'support-check.sh';
if (PTS_IS_CLIENT && is_file($support_check_file)) {
$environment['TEST_CUSTOM_ERROR'] = pts_client::temporary_directory() . '/PTS-' . $this->get_identifier_base_name() . '-' . rand(1000, 9999);
$support_check = pts_tests::call_test_script($this, 'support-check', null, null, $environment, false);
if (is_file($environment['TEST_CUSTOM_ERROR'])) {
$support_result = pts_file_io::file_get_contents($environment['TEST_CUSTOM_ERROR']);
pts_file_io::delete($environment['TEST_CUSTOM_ERROR']);
return $support_result;
}
}
return true;
}
示例7: run_test
public static function run_test(&$test_run_manager, &$test_run_request)
{
$test_identifier = $test_run_request->test_profile->get_identifier();
$extra_arguments = $test_run_request->get_arguments();
$arguments_description = $test_run_request->get_arguments_description();
$full_output = pts_config::read_bool_config('PhoronixTestSuite/Options/General/FullOutput', 'FALSE');
// Do the actual test running process
$test_directory = $test_run_request->test_profile->get_install_dir();
if (!is_dir($test_directory)) {
return false;
}
$lock_file = $test_directory . 'run_lock';
if (pts_client::create_lock($lock_file) == false && $test_run_manager->is_multi_test_stress_run() == false) {
self::test_run_error($test_run_manager, $test_run_request, 'The ' . $test_identifier . ' test is already running.');
return false;
}
$active_result_buffer = new pts_test_result_buffer_active();
$test_run_request->active =& $active_result_buffer;
$execute_binary = $test_run_request->test_profile->get_test_executable();
$times_to_run = $test_run_request->test_profile->get_times_to_run();
$ignore_runs = $test_run_request->test_profile->get_runs_to_ignore();
$test_type = $test_run_request->test_profile->get_test_hardware_type();
$allow_cache_share = $test_run_request->test_profile->allow_cache_share();
$min_length = $test_run_request->test_profile->get_min_length();
$max_length = $test_run_request->test_profile->get_max_length();
if ($test_run_request->test_profile->get_environment_testing_size() > 1 && ceil(disk_free_space($test_directory) / 1048576) < $test_run_request->test_profile->get_environment_testing_size()) {
// Ensure enough space is available on disk during testing process
self::test_run_error($test_run_manager, $test_run_request, 'There is not enough space (at ' . $test_directory . ') for this test to run.');
pts_client::release_lock($lock_file);
return false;
}
$to_execute = $test_run_request->test_profile->get_test_executable_dir();
$pts_test_arguments = trim($test_run_request->test_profile->get_default_arguments() . ' ' . str_replace($test_run_request->test_profile->get_default_arguments(), '', $extra_arguments) . ' ' . $test_run_request->test_profile->get_default_post_arguments());
$extra_runtime_variables = pts_tests::extra_environmental_variables($test_run_request->test_profile);
// Start
$cache_share_pt2so = $test_directory . 'cache-share-' . PTS_INIT_TIME . '.pt2so';
$cache_share_present = $allow_cache_share && is_file($cache_share_pt2so);
$test_run_request->set_used_arguments_description($arguments_description);
pts_module_manager::module_process('__pre_test_run', $test_run_request);
$time_test_start = time();
pts_client::$display->test_run_start($test_run_manager, $test_run_request);
if (!$cache_share_present) {
$pre_output = pts_tests::call_test_script($test_run_request->test_profile, 'pre', 'Running Pre-Test Script', $pts_test_arguments, $extra_runtime_variables, true);
if ($pre_output != null && (pts_client::is_debug_mode() || $full_output)) {
pts_client::$display->test_run_instance_output($pre_output);
}
if (is_file($test_directory . 'pre-test-exit-status')) {
// If the pre script writes its exit status to ~/pre-test-exit-status, if it's non-zero the test run failed
$exit_status = pts_file_io::file_get_contents($test_directory . 'pre-test-exit-status');
unlink($test_directory . 'pre-test-exit-status');
if ($exit_status != 0) {
self::test_run_instance_error($test_run_manager, $test_run_request, 'The pre run script exited with a non-zero exit status.' . PHP_EOL);
self::test_run_error($test_run_manager, $test_run_request, 'This test execution has been abandoned.');
return false;
}
}
}
pts_client::$display->display_interrupt_message($test_run_request->test_profile->get_pre_run_message());
$runtime_identifier = time();
$execute_binary_prepend = '';
if ($test_run_request->exec_binary_prepend != null) {
$execute_binary_prepend = $test_run_request->exec_binary_prepend;
}
if (!$cache_share_present && $test_run_request->test_profile->is_root_required()) {
if (phodevi::is_root() == false) {
pts_client::$display->test_run_error('This test must be run as the root / administrator account.');
}
$execute_binary_prepend .= ' ' . PTS_CORE_STATIC_PATH . 'root-access.sh ';
}
if ($allow_cache_share && !is_file($cache_share_pt2so)) {
$cache_share = new pts_storage_object(false, false);
}
if ($test_run_manager->get_results_identifier() != null && $test_run_manager->get_file_name() != null && pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/SaveTestLogs', 'FALSE')) {
$backup_test_log_dir = PTS_SAVE_RESULTS_PATH . $test_run_manager->get_file_name() . '/test-logs/active/' . $test_run_manager->get_results_identifier() . '/';
pts_file_io::delete($backup_test_log_dir);
pts_file_io::mkdir($backup_test_log_dir, 0777, true);
} else {
$backup_test_log_dir = false;
}
for ($i = 0, $abort_testing = false, $time_test_start_actual = time(), $defined_times_to_run = $times_to_run; $i < $times_to_run && $i < 256 && !$abort_testing; $i++) {
pts_client::$display->test_run_instance_header($test_run_request);
$test_log_file = $test_directory . basename($test_identifier) . '-' . $runtime_identifier . '-' . ($i + 1) . '.log';
$is_expected_last_run = $i == $times_to_run - 1;
$test_extra_runtime_variables = array_merge($extra_runtime_variables, array('LOG_FILE' => $test_log_file, 'DISPLAY' => getenv('DISPLAY'), 'PATH' => getenv('PATH')));
$restored_from_cache = false;
if ($cache_share_present) {
$cache_share = pts_storage_object::recover_from_file($cache_share_pt2so);
if ($cache_share) {
$test_result = $cache_share->read_object('test_results_output_' . $i);
$test_extra_runtime_variables['LOG_FILE'] = $cache_share->read_object('log_file_location_' . $i);
if ($test_extra_runtime_variables['LOG_FILE'] != null) {
file_put_contents($test_extra_runtime_variables['LOG_FILE'], $cache_share->read_object('log_file_' . $i));
$test_run_time = 0;
// This wouldn't be used for a cache share since it would always be the same, but declare the value so the variable is at least initialized
$restored_from_cache = true;
}
}
unset($cache_share);
}
if ($restored_from_cache == false) {
//.........这里部分代码省略.........
示例8: post_execution_process
public function post_execution_process()
{
if ($this->do_save_results()) {
if ($this->result_file->get_test_count() == 0 && $this->is_new_result_file) {
pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name());
return false;
}
pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/test-logs/active/', null, true);
if ($this->is_new_result_file || $this->result_already_contains_identifier() == false) {
// nothing to do here now
}
echo PHP_EOL;
pts_module_manager::module_process('__event_results_process', $this);
pts_client::save_test_result($this->get_file_name() . '/composite.xml', $this->result_file->get_xml(), true, $this->results_identifier);
pts_module_manager::module_process('__event_results_saved', $this);
//echo PHP_EOL . 'Results Saved To: ; . PTS_SAVE_RESULTS_PATH . $this->get_file_name() . ;/composite.xml' . PHP_EOL;
if (!$this->auto_mode) {
if ($this->batch_mode) {
if ($this->batch_mode['OpenBrowser']) {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, true);
}
} else {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, false);
}
}
if ($this->allow_sharing_of_results && pts_network::internet_support_available()) {
if ($this->auto_upload_to_openbenchmarking || pts_openbenchmarking_client::auto_upload_results() || pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', 'FALSE')) {
$upload_results = true;
} else {
if ($this->batch_mode) {
$upload_results = $this->batch_mode['UploadResults'];
} else {
if (!$this->auto_mode) {
$upload_results = pts_user_io::prompt_bool_input('Would you like to upload the results to OpenBenchmarking.org', true);
} else {
$upload_results = false;
}
}
}
if ($upload_results) {
$this->openbenchmarking_results_data = pts_openbenchmarking::upload_test_result($this, true);
if ($this->get_results_url()) {
if (!$this->auto_mode && !$this->batch_mode && pts_openbenchmarking_client::auto_upload_results() == false) {
pts_client::display_web_page($this->get_results_url(), 'Do you want to launch OpenBenchmarking.org', true);
}
} else {
echo PHP_EOL . 'Results Failed To Upload.' . PHP_EOL;
}
}
}
}
}
示例9: cleanup
public function cleanup()
{
pts_file_io::delete($this->sensor_storage_dir, null, true);
}
示例10: select_drive_mount
private static function select_drive_mount()
{
$drives = pts_file_io::glob('/dev/sd*');
if (count($drives) == 0) {
echo PHP_EOL . 'No Disk Drives Found' . PHP_EOL . PHP_EOL;
} else {
array_push($drives, 'No HDD');
$to_mount = pts_user_io::prompt_text_menu('Select Drive / Partition To Mount', $drives);
if ($to_mount != 'No HDD') {
echo PHP_EOL . 'Attempting to mount: ' . $to_mount . PHP_EOL;
exec('umount /media/pts-auto-mount 2>&1');
pts_file_io::delete('/media/pts-auto-mount', null, true);
pts_file_io::mkdir('/media/pts-auto-mount');
echo exec('mount ' . $to_mount . ' /media/pts-auto-mount');
putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/');
} else {
if (is_dir('/media/pts-auto-mount')) {
exec('umount /media/pts-auto-mount');
@rmdir('/media/pts-auto-mount');
}
putenv('PTS_TEST_INSTALL_ROOT_PATH=');
}
}
}
示例11: execute_script
public function execute_script($pass_arguments = null)
{
if ($this->script_file == null) {
return false;
}
$script_contents = file_get_contents($this->script_file);
$prev_exit_status = 0;
$script_pointer = -1;
do {
$exit_status = 0;
if ($prev_exit_status != 0) {
$exit_status = $prev_exit_status;
$prev_exit_status = 0;
}
$script_contents = substr($script_contents, $script_pointer + 1);
$line = $script_contents;
$prev_script_pointer = $script_pointer;
if (($script_pointer = strpos($line, "\n")) !== false) {
$line = substr($line, 0, $script_pointer);
}
$line_r = $line != null ? pts_strings::trim_explode(' ', $line) : null;
switch (isset($line_r[0]) ? $line_r[0] : null) {
case '':
break;
case 'mv':
// TODO: implement folder support better
$line_r[1] = $this->get_real_path($line_r[1], $pass_arguments);
$line_r[2] = $this->get_real_path($line_r[2], $pass_arguments);
//pts_file_io::delete($line_r[2], null, true);
//copy($line_r[1], $line_r[2] . (is_dir($line_r[2]) ? basename($line_r[1]) : null));
//pts_file_io::delete($line_r[1], null, true);
rename($line_r[1], $line_r[2] . (is_dir($line_r[2]) ? basename($line_r[1]) : null));
break;
case 'cp':
// TODO: implement folder support better
$line_r[1] = $this->get_real_path($line_r[1], $pass_arguments);
$line_r[2] = $this->get_real_path($line_r[2], $pass_arguments);
copy($line_r[1], $line_r[2] . (is_dir($line_r[2]) ? basename($line_r[1]) : null));
break;
case 'cat':
// TODO: implement folder support better
$line_r[1] = $this->get_real_path($line_r[1], $pass_arguments);
$line_r[3] = $this->get_real_path($line_r[3], $pass_arguments);
copy($line_r[1], $line_r[3]);
break;
case 'cd':
if ($line_r[1] == '..') {
if (substr($this->var_current_directory, -1) == '/') {
$this->var_current_directory = substr($this->var_current_directory, 0, -1);
}
$this->var_current_directory = substr($this->var_current_directory, 0, strrpos($this->var_current_directory, '/') + 1);
} else {
if ($line_r[1] == '~') {
$this->var_current_directory = $this->environmental_variables["HOME"];
} else {
if (substr($line_r[1], 0, 1) == '"') {
// On Windows some directories are encased in quotes for spaces in the directory names
array_shift($line_r);
$this->var_current_directory = implode(' ', $line_r);
} else {
if (is_readable($line_r[1])) {
$this->var_current_directory = $line_r[1];
} else {
if (is_readable($this->get_real_path($line_r[1], $pass_arguments))) {
$this->var_current_directory = $this->get_real_path($line_r[1], $pass_arguments);
}
}
}
}
}
break;
case 'touch':
if (!is_file($this->var_current_directory . $line_r[1]) && is_writable($this->var_current_directory)) {
touch($this->var_current_directory . $line_r[1]);
}
break;
case 'mkdir':
pts_file_io::mkdir($this->var_current_directory . $line_r[1]);
break;
case 'rm':
for ($i = 1; $i < count($line_r); $i++) {
if (is_file($this->var_current_directory . $line_r[$i])) {
unlink($this->var_current_directory . $line_r[$i]);
} else {
if (is_dir($this->var_current_directory . $line_r[$i])) {
pts_file_io::delete($this->var_current_directory . $line_r[$i], null, true);
}
}
}
break;
case 'chmod':
$chmod_file = self::find_file_in_array($line_r);
if ($chmod_file) {
chmod($chmod_file, 0755);
}
break;
case 'unzip':
$zip_file = self::find_file_in_array($line_r);
pts_compression::zip_archive_extract($zip_file, $this->var_current_directory);
break;
//.........这里部分代码省略.........
示例12: post_execution_process
public function post_execution_process()
{
if ($this->do_save_results()) {
if ($this->result_file_writer->get_result_count() == 0 && !pts_result_file::is_test_result_file($this->get_file_name()) && pts_c::$test_flags ^ pts_c::is_recovering && pts_c::$test_flags ^ pts_c::remote_mode) {
pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name());
return false;
}
pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/test-logs/active/', null, true);
if (pts_c::$test_flags ^ pts_c::is_recovering && (!pts_result_file::is_test_result_file($this->get_file_name()) || $this->result_already_contains_identifier() == false)) {
$this->result_file_writer->add_test_notes(pts_test_notes_manager::generate_test_notes($this->tests_to_run), $this->generate_json_system_attributes());
}
echo PHP_EOL;
pts_module_manager::module_process('__event_results_process', $this);
pts_client::save_result_file($this->result_file_writer, $this->get_file_name());
pts_module_manager::module_process('__event_results_saved', $this);
//echo PHP_EOL . 'Results Saved To: ; . PTS_SAVE_RESULTS_PATH . $this->get_file_name() . ;/composite.xml' . PHP_EOL;
if (!(pts_c::$test_flags & pts_c::auto_mode)) {
if (pts_c::$test_flags & pts_c::batch_mode) {
if (self::$batch_mode_options['OpenBrowser']) {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, true);
}
} else {
pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, false);
}
}
if ($this->allow_sharing_of_results && pts_network::internet_support_available()) {
if ($this->auto_upload_to_openbenchmarking || pts_openbenchmarking_client::auto_upload_results() || pts_flags::upload_to_openbenchmarking()) {
$upload_results = true;
} else {
if (pts_c::$test_flags & pts_c::batch_mode) {
$upload_results = self::$batch_mode_options['UploadResults'];
} else {
if (!(pts_c::$test_flags & pts_c::auto_mode)) {
$upload_results = pts_user_io::prompt_bool_input('Would you like to upload the results to OpenBenchmarking.org', true);
} else {
$upload_results = false;
}
}
}
if ($upload_results) {
$this->openbenchmarking_results_data = pts_openbenchmarking::upload_test_result($this, true);
if ($this->get_results_url()) {
if (!(pts_c::$test_flags & pts_c::auto_mode) && pts_openbenchmarking_client::auto_upload_results() == false) {
pts_client::display_web_page($this->get_results_url(), 'Do you want to launch OpenBenchmarking.org', true);
}
} else {
echo PHP_EOL . 'Results Failed To Upload.' . PHP_EOL;
}
}
}
}
}