[glom/glom-1-14] Improve stderr message.



commit 0c87ee5a2757c1ec2861517b4ae1aec7f1f53e5d
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Jun 29 09:18:02 2010 +0200

    Improve stderr message.
    
    * glom/libglom/spawn_with_feedback.cc:
        execute_command_line_and_wait_until_second_command_returns_success():
        Correct the error message when a command (such as postgres) fails. As
        noticed in bug #617504.

 ChangeLog                           |   69 ++++++++++++++++++++---------------
 glom/libglom/spawn_with_feedback.cc |   52 +++++++++++++-------------
 2 files changed, 65 insertions(+), 56 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5b6f9bd..cd1f714 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-06-29  Murray Cumming  <murrayc murrayc com>
+
+	Improve stderr message.
+
+	* glom/libglom/spawn_with_feedback.cc:
+    execute_command_line_and_wait_until_second_command_returns_success():
+    Correct the error message when a command (such as postgres) fails. As
+    noticed in bug #617504.
+
 2010-06-21  David King  <amigadave amigadave com>
 
 	Explicitly link with libdl for Python module loading test
@@ -11,10 +20,10 @@
 
 	Revert previous "Fix a crash when using find mode" commit.
 
-	* glom/application.cc: 
-	* glom/application.h: This was apparently only a problem due to a previous 
+	* glom/application.cc:
+	* glom/application.h: This was apparently only a problem due to a previous
 	UI-changing commit in the glom-1-16 branch.
-	
+
 2010-05-03  Daniel Borgmann  <danielb openismus com>
 
 	Set default icon instead of individual window icons.
@@ -81,7 +90,7 @@
 	* glom/utility_widgets/db_adddel/db_adddel.cc:
 	* glom/utility_widgets/flowtable.cc:
 	* glom/utility_widgets/layouttoolbar.cc:
-	* glom/xsl_utils.cc: Remove now-unnecessary gtk+/gtk* includes, 
+	* glom/xsl_utils.cc: Remove now-unnecessary gtk+/gtk* includes,
 	replacing some with use of C++ API. These caused warnings due to GSEAL.
 
 2010-06-19  Murray Cumming  <murrayc murrayc com>
@@ -102,59 +111,59 @@
 2010-05-02  Murray Cumming  <murrayc murrayc-x61>
 
 	Python calculations: Really convert to expected types.
-	
-	* glom/libglom/data_structure/glomconversions.cc: 
-	get_double_for_gda_value_numeric(): Handle all numeric GTypes - not just 
+
+	* glom/libglom/data_structure/glomconversions.cc:
+	get_double_for_gda_value_numeric(): Handle all numeric GTypes - not just
 	G_TYPE_INT..
-	convert_value(): Remove the special case for G_TYPE_INT (now handled in 
-	get_double_for_gda_value_numeric instead). Make sure that all numeric GTypes 
+	convert_value(): Remove the special case for G_TYPE_INT (now handled in
+	get_double_for_gda_value_numeric instead). Make sure that all numeric GTypes
 	are converted to GDA_TYPE_NUMERIC, making it easier for callers to check.
 
 2010-05-01  Murray Cumming  <murrayc murrayc com>
 
 	Add test of type conversion after python calculations.
-	
+
 	* Makefile_tests.am:
-	* tests/test_python_execute_func_change_result_type.cc: Add a test that 
-	calls a python function that returns a number, for a text field, to 
+	* tests/test_python_execute_func_change_result_type.cc: Add a test that
+	calls a python function that returns a number, for a text field, to
 	check that the conversion is done.
 
 2010-05-01  Murray Cumming  <murrayc murrayc com>
 
 	Python scripts and calculations: Test buttons now show python errors.
-	
-	* glom/python_embed/glom_python.[h|cc]: 
-	glom_execute_python_function_implementation(), 
-	glom_evaluate_python_function_implementation(): Add an error_message output 
+
+	* glom/python_embed/glom_python.[h|cc]:
+	glom_execute_python_function_implementation(),
+	glom_evaluate_python_function_implementation(): Add an error_message output
 	parameter, to report syntax errors, for instance.
 	* glom/mode_design/fields/dialog_fieldcalculation.cc:
   * glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc:
   Show the python error, if any, when pressing the Test button.
   * Other files: Adapt, ignoring the error message for now.
   * Makefile_tests.am:
-	* tests/test_python_execute_func_bad_syntax.cc: Added a test of the new 
-	error_message parameter. 
+	* tests/test_python_execute_func_bad_syntax.cc: Added a test of the new
+	error_message parameter.
 
 2010-05-01  Murray Cumming  <murrayc murrayc com>
 
 	Fix a possible crash when showing choices.
 
-	* glom/mode_data/datawidget/combo.cc: set_text(): Don't show a warning if 
+	* glom/mode_data/datawidget/combo.cc: set_text(): Don't show a warning if
 	"" is not found because it's OK to use that to clear the combo.
-	* glom/mode_data/datawidget/combochoiceswithtreemodel.cc: 
-	set_choices_with_second(): Don't dereference a null smartpointer, avoiding 
+	* glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
+	set_choices_with_second(): Don't dereference a null smartpointer, avoiding
 	a crash with one .glom file that I tried.
 
 2010-05-01  Murray Cumming  <murrayc murrayc com>
 
 	Python Glom API documentation improvement.
-	
-	* glom/python_embed/python_module/py_glom_module.cc: Turn off auto-writing 
-	of the Python signatures in the docstrings, because that is a) crappy and 
-	b) confuses the sphinx autodoc module, which adds an invisible ..function 
+
+	* glom/python_embed/python_module/py_glom_module.cc: Turn off auto-writing
+	of the Python signatures in the docstrings, because that is a) crappy and
+	b) confuses the sphinx autodoc module, which adds an invisible ..function
 	reStrucuredText line.
-	Add :param:, :type, and :returns: lines with the necessary indenting and 
-	empty lines needed by that invisible ..function line. 
+	Add :param:, :type, and :returns: lines with the necessary indenting and
+	empty lines needed by that invisible ..function line.
 
 2010-05-01  Murray Cumming  <murrayc murrayc com>
 
@@ -163,7 +172,7 @@
 	* glom/libglom/document/bakery/document.cc: write_to_disk():
 	Do not fail if the parent directory already exists.
 	* Makefile_tests.am:
-	* tests/test_document_autosave.cc: Added a test of document saving and 
+	* tests/test_document_autosave.cc: Added a test of document saving and
 	autosaving.
 
 2010-05-01  Murray Cumming  <murrayc murrayc com>
@@ -178,8 +187,8 @@
 2010-04-27  Murray Cumming  <murrayc murrayc-x61>
 
 	PyGlom: Don't use deprecated boost::python::args.
-	
-	* glom/python_embed/python_module/py_glom_module.cc: Use boost::python::arg() 
+
+	* glom/python_embed/python_module/py_glom_module.cc: Use boost::python::arg()
 	instead of boost::python::args(), because I noticed that args is deprecated.
 
 1.14.1:
diff --git a/glom/libglom/spawn_with_feedback.cc b/glom/libglom/spawn_with_feedback.cc
index 6186ba2..601c71f 100644
--- a/glom/libglom/spawn_with_feedback.cc
+++ b/glom/libglom/spawn_with_feedback.cc
@@ -345,7 +345,7 @@ static std::auto_ptr<const SpawnInfo> spawn_async(const Glib::ustring& command_l
 
 /**
  * @param return_status: The return value of the command.
- * @result Whether we successfully ended the async spawn. 
+ * @result Whether we successfully ended the async spawn.
  */
 static bool spawn_async_end(std::auto_ptr<const SpawnInfo> info, std::string* stdout_text = 0, std::string* stderr_text = 0, int* return_status = 0)
 {
@@ -371,11 +371,11 @@ static int spawn_sync(const Glib::ustring& command_line, std::string* stdout_tex
     redirect_flags |= REDIRECT_STDERR;
 
   Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(false);
-     
+
   std::auto_ptr<const SpawnInfo> info = spawn_async(command_line, redirect_flags);
   info->signal_finished().connect(
     sigc::bind(sigc::ptr_fun(&on_spawn_info_finished), sigc::ref(mainloop) ) );
- 
+
   // Block until signal_finished is emitted:
   mainloop->run();
 
@@ -390,9 +390,9 @@ static int spawn_sync(const Glib::ustring& command_line, std::string* stdout_tex
 bool execute_command_line_and_wait(const std::string& command, const SlotProgress& slot_progress)
 {
   //Show UI progress feedback while we wait for the command to finish:
-  
+
   std::auto_ptr<const Impl::SpawnInfo> info = Impl::spawn_async(command, 0);
-  
+
   Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(false);
   info->signal_finished().connect(
     sigc::bind(sigc::ptr_fun(&on_spawn_info_finished), sigc::ref(mainloop) ) );
@@ -408,7 +408,7 @@ bool execute_command_line_and_wait(const std::string& command, const SlotProgres
 
   //Stop the timeout callback:
   timeout_connection.disconnect();
-  
+
   int return_status = false;
   const bool returned = Impl::spawn_async_end(info, 0, 0, &return_status);
   if(!returned)
@@ -423,9 +423,9 @@ bool execute_command_line_and_wait(const std::string& command, const SlotProgres
   output = std::string();
 
   //Show UI progress feedback while we wait for the command to finish:
-  
+
   std::auto_ptr<const Impl::SpawnInfo> info = Impl::spawn_async(command, Impl::REDIRECT_STDOUT | Impl::REDIRECT_STDERR);
-  
+
   Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(false);
   info->signal_finished().connect(
     sigc::bind(sigc::ptr_fun(&on_spawn_info_finished), sigc::ref(mainloop) ) );
@@ -441,7 +441,7 @@ bool execute_command_line_and_wait(const std::string& command, const SlotProgres
 
   //Stop the timeout callback:
   timeout_connection.disconnect();
-  
+
   int return_status = false;
   std::string stdout_text, stderr_text;
   const bool returned = Impl::spawn_async_end(info, &stdout_text, &stderr_text, &return_status);
@@ -457,7 +457,7 @@ bool execute_command_line_and_wait(const std::string& command, const SlotProgres
   if(!stderr_text.empty())
   {
     std::cerr << "Glom: execute_command_line_and_wait(): command produced stderr text: " << std::endl <<
-      "  command: " << command << std::endl << 
+      "  command: " << command << std::endl <<
       "  error text: " << stderr_text << std::endl;
   }
 
@@ -474,17 +474,17 @@ namespace
     Glib::ustring stored_env_language;
     if(!success_text.empty())
     {
-      // If we are going to check the text output of the second command, 
+      // If we are going to check the text output of the second command,
       // then we should make sure that we get a fairly canonical version of that text,
       // so we set the LANG for this command.
-      // We have to set LANGUAGE (a GNU extension) as well as LANG, because it 
-      // is probably defined on the system already and that definition would override our LANG:  
+      // We have to set LANGUAGE (a GNU extension) as well as LANG, because it
+      // is probably defined on the system already and that definition would override our LANG:
       // (Note that we can not just do "LANG=C;the_command", as on the command line, because g_spawn() does not support that.)
 
       #ifdef GLOM_SPAWN_DEBUG
       std::cout << std::endl << "debug: temporarily setting LANG and LANGUAGE environment variables to \"C\"" << std::endl;
       #endif //GLOM_SPAWN_DEBUG
-      
+
       stored_env_lang = Glib::getenv("LANG");
       stored_env_language = Glib::getenv("LANGUAGE");
       Glib::setenv("LANG", "C", true /* overwrite */);
@@ -505,7 +505,7 @@ namespace
     catch(const Impl::SpawnError& ex)
     {
       std::cerr << "Glom::execute_command_line_and_wait_until_second_command_returns_success(): Exception while calling Glib::spawn_command_line_sync(): " << ex.what() << std::endl;
-      // TODO: We should cancel the whole call if this fails three times in 
+      // TODO: We should cancel the whole call if this fails three times in
       // a row or so.
     }
 #else
@@ -518,7 +518,7 @@ namespace
       #ifdef GLOM_SPAWN_DEBUG
       std::cout << std::endl << "debug: restoring the LANG and LANGUAGE environment variables." << std::endl;
       #endif //GLOM_SPAWN_DEBUG
-      
+
       Glib::setenv("LANG", stored_env_lang, true /* overwrite */);
       Glib::setenv("LANGUAGE", stored_env_language, true /* overwrite */);
     }
@@ -531,7 +531,7 @@ namespace
         #ifdef GLOM_SPAWN_DEBUG
         std::cout << " debug: output=" << stdout_output << ", waiting for=" << success_text << std::endl;
         #endif //GLOM_SPAWN_DEBUG
-        
+
         if(stdout_output.find(success_text) == std::string::npos)
           success = false;
       }
@@ -541,7 +541,7 @@ namespace
         #ifdef GLOM_SPAWN_DEBUG
         std::cout << "debug: Success, do response" << std::endl;
         #endif //GLOM_SPAWN_DEBUG
-        
+
         // Exit from run() in execute_command_line_and_wait_until_second_command_returns_success().
         mainloop->quit();
         // Cancel timeout. Actually, we also could return true here since
@@ -568,7 +568,7 @@ static bool on_timeout_delay(const Glib::RefPtr<Glib::MainLoop>& mainloop)
   //Allow our mainloop.run() to return:
   if(mainloop)
     mainloop->quit();
-    
+
   return false;
 }
 */
@@ -578,7 +578,7 @@ bool execute_command_line_and_wait_until_second_command_returns_success(const st
   #ifdef GLOM_SPAWN_DEBUG
   std::cout << "debug: Command: " << command << std::endl;
   #endif //GLOM_SPAWN_DEBUG
-  
+
   std::auto_ptr<const Impl::SpawnInfo> info = Impl::spawn_async(command, Impl::REDIRECT_STDERR);
 
   // While we wait for the second command to finish we
@@ -604,17 +604,17 @@ bool execute_command_line_and_wait_until_second_command_returns_success(const st
   std::string stderr_text;
   int return_status = 0;
   const bool success = Impl::spawn_async_end(info, 0, &stderr_text, &return_status);
-  
+
   if(success && (return_status == EXIT_SUCCESS))
   {
-    /* Don't sleep here. Instead we just keep trying to connect until it succeeds, 
+    /* Don't sleep here. Instead we just keep trying to connect until it succeeds,
      * timing out during that if necessary.
      *
      *
     //Sleep for a bit more, because I think that pg_ctl sometimes reports success too early.
     Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(false);
     sigc::connection connection_timeout = Glib::signal_timeout().connect(
-     sigc::bind(sigc::ptr_fun(&on_timeout_delay), sigc::ref(mainloop)), 
+     sigc::bind(sigc::ptr_fun(&on_timeout_delay), sigc::ref(mainloop)),
      8000);
     mainloop->run();
 
@@ -640,8 +640,9 @@ bool execute_command_line_and_wait_until_second_command_returns_success(const st
       error_dialog->set_secondary_text("The command was:\n\n" + Glib::Markup::escape_text(command) + (stderr_text.empty() ? Glib::ustring("") : ("\n\n<small>" + Glib::Markup::escape_text(stderr_text) + "</small>")), true);
       error_dialog->run();
       */
-      
-      std::cerr << "Glom:  execute_command_line_and_wait_until_second_command_returns_success(): Child command failed. The command was: " << std::endl << stderr_text << std::endl;
+
+      std::cerr << "Glom:  execute_command_line_and_wait_until_second_command_returns_success(): Command failed. The command was: " << command << std::endl <<
+        "and the error was: " << stderr_text << std::endl;
     }
     else
     {
@@ -657,4 +658,3 @@ bool execute_command_line_and_wait_until_second_command_returns_success(const st
 } //Spawn
 
 } //Glom
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]