本文整理汇总了PHP中pts_client::create_temporary_file方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_client::create_temporary_file方法的具体用法?PHP pts_client::create_temporary_file怎么用?PHP pts_client::create_temporary_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_client
的用法示例。
在下文中一共展示了pts_client::create_temporary_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload_test_result
public static function upload_test_result(&$object, $return_json_data = false)
{
if ($object instanceof pts_test_run_manager) {
$result_file = new pts_result_file($object->get_file_name());
$local_file_name = $object->get_file_name();
$results_identifier = $object->get_results_identifier();
} else {
if ($object instanceof pts_result_file) {
$result_file =& $object;
$local_file_name = $result_file->get_identifier();
$results_identifier = null;
}
}
// Ensure the results can be shared
if (self::result_upload_supported($result_file) == false) {
return false;
}
if (pts_network::internet_support_available() == false) {
echo PHP_EOL . 'No network support available.' . PHP_EOL;
return false;
}
$composite_xml = $result_file->getRawXml();
$system_log_dir = PTS_SAVE_RESULTS_PATH . $result_file->get_identifier() . '/system-logs/';
$upload_system_logs = false;
if (is_dir($system_log_dir)) {
if (pts_config::read_bool_config('PhoronixTestSuite/Options/OpenBenchmarking/AlwaysUploadSystemLogs', 'FALSE')) {
$upload_system_logs = true;
} else {
if (isset(self::$client_settings['UploadSystemLogsByDefault'])) {
$upload_system_logs = self::$client_settings['UploadSystemLogsByDefault'];
} else {
if (is_dir($system_log_dir)) {
$upload_system_logs = pts_user_io::prompt_bool_input('Would you like to attach the system logs (lspci, dmesg, lsusb, etc) to the test result', true, 'UPLOAD_SYSTEM_LOGS');
}
}
}
}
$system_logs = null;
$system_logs_hash = null;
if ($upload_system_logs) {
$is_valid_log = true;
$finfo = function_exists('finfo_open') ? finfo_open(FILEINFO_MIME_TYPE) : false;
foreach (pts_file_io::glob($system_log_dir . '*') as $log_dir) {
if ($is_valid_log == false || !is_dir($log_dir)) {
$is_valid_log = false;
break;
}
foreach (pts_file_io::glob($log_dir . '/*') as $log_file) {
if (!is_file($log_file)) {
$is_valid_log = false;
break;
}
if ($finfo && substr(finfo_file($finfo, $log_file), 0, 5) != 'text/') {
$is_valid_log = false;
break;
}
}
}
if ($is_valid_log) {
$system_logs_zip = pts_client::create_temporary_file('.zip');
pts_compression::zip_archive_create($system_logs_zip, $system_log_dir);
if (filesize($system_logs_zip) < 2097152) {
// If it's over 2MB, probably too big
$system_logs = base64_encode(file_get_contents($system_logs_zip));
$system_logs_hash = sha1($system_logs);
} else {
trigger_error('The systems log attachment is too large to upload to OpenBenchmarking.org.', E_USER_WARNING);
}
unlink($system_logs_zip);
}
}
$composite_xml_hash = sha1($composite_xml);
$composite_xml_type = 'composite_xml';
// Compress the result file XML if it's big
if (isset($composite_xml[50000]) && function_exists('gzdeflate')) {
$composite_xml_gz = gzdeflate($composite_xml);
if ($composite_xml_gz != false) {
$composite_xml = $composite_xml_gz;
$composite_xml_type = 'composite_xml_gz';
}
}
$to_post = array($composite_xml_type => base64_encode($composite_xml), 'composite_xml_hash' => $composite_xml_hash, 'local_file_name' => $local_file_name, 'this_results_identifier' => $results_identifier, 'system_logs_zip' => $system_logs, 'system_logs_hash' => $system_logs_hash);
if (isset(self::$client_settings['ResultUploadsDefaultDisplayStatus']) && is_numeric(self::$client_settings['ResultUploadsDefaultDisplayStatus'])) {
$to_post['display_status'] = self::$client_settings['ResultUploadsDefaultDisplayStatus'];
}
$json_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_result', $to_post);
$json_response = json_decode($json_response, true);
if (!is_array($json_response)) {
trigger_error('Unhandled Exception', E_USER_ERROR);
return false;
}
if (isset($json_response['openbenchmarking']['upload']['error'])) {
trigger_error($json_response['openbenchmarking']['upload']['error'], E_USER_ERROR);
}
if (isset($json_response['openbenchmarking']['upload']['url'])) {
echo PHP_EOL . 'Results Uploaded To: ' . $json_response['openbenchmarking']['upload']['url'] . PHP_EOL;
pts_module_manager::module_process('__event_openbenchmarking_upload', $json_response);
}
//$json['openbenchmarking']['upload']['id']
if (isset(self::$client_settings['RemoveLocalResultsOnUpload']) && self::$client_settings['RemoveLocalResultsOnUpload'] && $local_file_name != null) {
//.........这里部分代码省略.........
示例2: set_user_context
private static function set_user_context($context_script, $trigger, $schedule_id, $process)
{
if (!empty($context_script)) {
$context_file = pts_client::create_temporary_file();
file_put_contents($context_file, $context_script);
chmod($context_file, 0755);
pts_file_io::mkdir(pts_module::save_dir());
$storage_path = pts_module::save_dir() . 'memory.pt2so';
$storage_object = pts_storage_object::recover_from_file($storage_path);
$notes_log_file = pts_module::save_dir() . sha1($trigger . $schedule_id . $process);
// We check to see if the context was already set but the system rebooted or something in that script
if ($storage_object == false) {
$storage_object = new pts_storage_object(true, true);
} else {
if ($storage_object->read_object('last_set_context_trigger') == $trigger && $storage_object->read_object('last_set_context_schedule') == $schedule_id && $storage_object->read_object('last_set_context_process') == $process) {
// If the script already ran once for this trigger, don't run it again
self::check_user_context_log($trigger, $schedule_id, $process, $notes_log_file, null);
return false;
}
}
$storage_object->add_object('last_set_context_trigger', $trigger);
$storage_object->add_object('last_set_context_schedule', $schedule_id);
$storage_object->add_object('last_set_context_process', $process);
$storage_object->save_to_file($storage_path);
phoromatic::update_system_status('Setting context for: ' . $schedule_id . ' - ' . $trigger . ' - ' . $process);
// Run the set context script
$env_vars['PHOROMATIC_TRIGGER'] = $trigger;
$env_vars['PHOROMATIC_SCHEDULE_ID'] = $schedule_id;
$env_vars['PHOROMATIC_SCHEDULE_PROCESS'] = $process;
$env_vars['PHOROMATIC_LOG_FILE'] = $notes_log_file;
$log_output = pts_client::shell_exec('./' . $context_script . ' ' . $trigger . ' 2>&1', $env_vars);
self::check_user_context_log($trigger, $schedule_id, $process, $notes_log_file, $log_output);
// Just simply return true for now, perhaps check exit code status and do something
return true;
}
return false;
}
示例3: clone_openbenchmarking_result_system_logs
public static function clone_openbenchmarking_result_system_logs(&$id, $extract_to, $sha1_compare = null)
{
if (!pts_network::internet_support_available()) {
return false;
}
$system_log_response = pts_openbenchmarking::make_openbenchmarking_request('clone_openbenchmarking_system_logs', array('i' => $id));
$extracted = false;
if ($system_log_response != null) {
$zip_temp = pts_client::create_temporary_file();
file_put_contents($zip_temp, $system_log_response);
if ($sha1_compare == null || sha1_file($zip_temp) == $sha1_compare) {
// hash check of file passed or was null
$extracted = pts_compression::zip_archive_extract($zip_temp, $extract_to);
}
unlink($zip_temp);
}
return $extracted;
}
示例4: capture_test_logs
private static function capture_test_logs($save_identifier)
{
$data = array('system-logs' => null, 'test-logs' => null);
if (is_dir(PTS_SAVE_RESULTS_PATH . $save_identifier . '/system-logs/')) {
$system_logs_zip = pts_client::create_temporary_file();
pts_compression::zip_archive_create($system_logs_zip, PTS_SAVE_RESULTS_PATH . $save_identifier . '/system-logs/');
$data['system-logs'] = base64_encode(file_get_contents($system_logs_zip));
unlink($system_logs_zip);
}
if (is_dir(PTS_SAVE_RESULTS_PATH . $save_identifier . '/test-logs/')) {
$test_logs_zip = pts_client::create_temporary_file();
pts_compression::zip_archive_create($test_logs_zip, PTS_SAVE_RESULTS_PATH . $save_identifier . '/test-logs/');
$data['test-logs'] = base64_encode(file_get_contents($test_logs_zip));
unlink($test_logs_zip);
}
return $data;
}