Summary
Description: Unnamed repository; edit this file to name it for gitweb.
Last Change: Wed 2/3/10 13:04
Recent Commits
>
--git a/pts-core/functions/pts-functions.php b/pts-core/functions/pts-functions.php
index 64bfe6f..6da66d2 100644
--- a/pts-core/functions/pts-functions.php
+++ b/pts-core/functions/pts-functions.php
@@ -185,10 +185,9 @@ function pts_process_active($process)
}
function display_web_browser($URL)
{
- echo "Do you want to view the results in your web browser (Y/n)? ";
- $VIEW_RESULTS = strtolower(trim(fgets(STDIN)));
+ $view_results = pts_bool_question("Do you want to view the results in your web browser (Y/n)?");
- if($VIEW_RESULTS == "y")
+ if($view_results)
shell_exec("firefox $URL &");
}
function pts_env_variables()
@@ -317,5 +316,23 @@ function pts_trim_double($double, $accuracy = 2)
return $return;
}
+function pts_bool_question($question, $default = true)
+{
+ do
+ {
+ echo $question . " ";
+ $input = trim(strtolower(fgets(STDIN)));
+ }
+ while($input != "y" && $input != "n" && $input != "");
+
+ if($input == "y")
+ $answer = true;
+ else if($intput == "n")
+ $answer = false;
+ else
+ $answer = $default;
+
+ return $answer;
+}
?>
diff --git a/pts-core/pts-run-benchmark.php b/pts-core/pts-run-benchmark.php
index ad463b2..35c891e 100644
--- a/pts-core/pts-run-benchmark.php
+++ b/pts-core/pts-run-benchmark.php
@@ -74,23 +74,12 @@ if(!$TO_RUN_TYPE)
}
else
{
- echo "Would you like to save these benchmark results (Y/n)? ";
- $SAVE_RESULTS = trim(fgets(STDIN));
+ $SAVE_RESULTS = pts_bool_question("Would you like to save these benchmark results (Y/n)?");
- if(strtolower($SAVE_RESULTS) == "y")
- {
- $SAVE_RESULTS = true;
- }
- else if(strtolower($SAVE_RESULTS) == "n")
- {
- echo "Benchmark results will NOT be saved!\n";
- $SAVE_RESULTS = false;
- }
+ if($SAVE_RESULTS)
+ echo "Benchmark results will be saved.\n";
else
- {
- echo "\nInput not understood. Results will not be saved.\n";
- $SAVE_RESULTS = false;
- }
+ echo "Benchmark results will NOT be saved!\n";
if($SAVE_RESULTS)
{
@@ -139,17 +128,18 @@ if($TO_RUN_TYPE == "BENCHMARK")
$option_names = $xml_parser->getXMLArrayValues("Entry/Name");
$option_values = $xml_parser->getXMLArrayValues("Entry/Value");
- echo "\n";
- for($i = 0; $i < count($option_names); $i++)
- {
- echo ($i + 1) . ": " . $option_names[$i] . "\n";
- }
-
do
{
+ echo "\n";
+ for($i = 0; $i < count($option_names); $i++)
+ {
+ echo ($i + 1) . ": " . $option_names[$i] . "\n";
+ }
echo "\nPlease Enter Your Choice: ";
$bench_choice = strtolower(trim(fgets(STDIN)));
- }while($bench_choice < 1 || $bench_choice > count($option_names));
+ }
+ while($bench_choice < 1 || $bench_choice > count($option_names));
+
$TEXT_ARGS .= "$settings_name[$option_count]: " . $option_names[($bench_choice - 1)];
$USER_ARGS .= $settings_argument[$option_count] . $option_values[($bench_choice - 1)] . " ";
@@ -252,10 +242,9 @@ if($SAVE_RESULTS)
echo "Results Saved To: " . SAVE_RESULTS_LOCATION . "$PROPOSED_FILE_NAME.xml\n";
display_web_browser(SAVE_RESULTS_LOCATION . "$PROPOSED_FILE_NAME.xml");
- echo "\nWould you like to upload these results to PTS Global (Y/n)? ";
- $upload_results = strtolower(trim(fgets(STDIN)));
+ $upload_results = pts_bool_question("Would you like to upload these results to PTS Global (y/N)?", false);
- if($upload_results == "y")
+ if($upload_results)
echo "Results Uploaded To: " . pts_global_upload_result(SAVE_RESULTS_LOCATION . "$PROPOSED_FILE_NAME.xml") . "\n";
 
Copyright © 2010 by Phoronix Media