Blame SOURCES/0018-don-t-break-the-event-run-by-failures-of-abrt-action.patch

06486d
From e6b19714485e72be99a9fcce62cd3a8a0e95808f Mon Sep 17 00:00:00 2001
06486d
From: Jakub Filak <jfilak@redhat.com>
06486d
Date: Fri, 24 Jan 2014 14:26:02 +0100
06486d
Subject: [ABRT PATCH 18/27] don't break the event run by failures of
06486d
 abrt-action-notify
06486d
06486d
Closes #789
06486d
Closes rhbz#1057710
06486d
06486d
rmarko: add newlines to sys.stderr.write calls
06486d
06486d
Signed-off-by: Jakub Filak <jfilak@redhat.com>
06486d
---
06486d
 src/daemon/abrt_event.conf     |  2 ++
06486d
 src/plugins/abrt-action-notify | 48 ++++++++++++++++++++++++------------------
06486d
 2 files changed, 30 insertions(+), 20 deletions(-)
06486d
06486d
diff --git a/src/daemon/abrt_event.conf b/src/daemon/abrt_event.conf
06486d
index 8a8e862..fe9c3d5 100644
06486d
--- a/src/daemon/abrt_event.conf
06486d
+++ b/src/daemon/abrt_event.conf
06486d
@@ -104,7 +104,9 @@ EVENT=open-gui
06486d
 # Notify a new crash
06486d
 EVENT=notify package!=
06486d
         abrt-action-notify -d $DUMP_DIR
06486d
+        true # ignore failures because we want to run all 'notify' events
06486d
 
06486d
 # Notify a new occurrence of a single crash
06486d
 EVENT=notify-dup package!=
06486d
         abrt-action-notify -d $DUMP_DIR
06486d
+        true # ignore failures because we want to run all 'notify' events
06486d
diff --git a/src/plugins/abrt-action-notify b/src/plugins/abrt-action-notify
06486d
index 72bfbf8..cbabf74 100644
06486d
--- a/src/plugins/abrt-action-notify
06486d
+++ b/src/plugins/abrt-action-notify
06486d
@@ -216,17 +216,22 @@ if __name__ == "__main__":
06486d
                 format(DIR_PATH, ex.message))
06486d
         sys.exit(RETURN_FAILURE)
06486d
 
06486d
+    # The execution must continue because we should try to notify via all
06486d
+    # configured channels. One of them might work properly.
06486d
+    return_status = RETURN_OK
06486d
     try:
06486d
         emit_crash_dbus_signal(PD)
06486d
     except RuntimeError as ex:
06486d
-        sys.stderr.write("Cannot notify '{0}': {1}\n".
06486d
+        sys.stderr.write("Cannot notify '{0}' via D-Bus: {1}\n".
06486d
                 format(DIR_PATH, ex.message))
06486d
-        sys.exit(RETURN_FAILURE)
06486d
+        return_status = RETURN_FAILURE
06486d
     except KeyError as ex:
06486d
         # this is a bug in build_notification_problem_data()
06486d
         sys.stderr.write("BUG: problem data misses required element '{0}'"
06486d
-                .format(ex.message))
06486d
-        sys.exit(RETURN_FAILURE)
06486d
+                         " required for D-Bus notification\n"
06486d
+                         .format(ex.message))
06486d
+
06486d
+        return_status = RETURN_FAILURE
06486d
 
06486d
     if OPTIONS.autoreporting or conf.get("AutoreportingEnabled", "no") == "yes":
06486d
         event_name = OPTIONS.autoreporting_event
06486d
@@ -234,20 +239,23 @@ if __name__ == "__main__":
06486d
             if "AutoreportingEvent" in conf:
06486d
                 event_name = conf["AutoreportingEvent"]
06486d
             else:
06486d
-                sys.stderr.write("Autoreporting event is not configured")
06486d
-                sys.exit(RETURN_FAILURE)
06486d
-
06486d
-        try:
06486d
-            run_autoreport(PD, event_name)
06486d
-        except RuntimeError as ex:
06486d
-            sys.stderr.write("Cannot notify '{0}': {1}\n".
06486d
-                    format(DIR_PATH, ex.message))
06486d
-            sys.exit(RETURN_FAILURE)
06486d
-        except KeyError as ex:
06486d
-            # this is a bug in build_notification_problem_data()
06486d
-            sys.stderr.write("BUG: problem data misses required element '{0}'"
06486d
-                    .format(ex.message))
06486d
-            sys.exit(RETURN_FAILURE)
06486d
-
06486d
-    sys.exit(RETURN_OK)
06486d
+                sys.stderr.write("Autoreporting event is not configured\n")
06486d
+                return_status = RETURN_FAILURE
06486d
+
06486d
+        if event_name:
06486d
+            try:
06486d
+                run_autoreport(PD, event_name)
06486d
+            except RuntimeError as ex:
06486d
+                sys.stderr.write("Cannot notify '{0}' via uReport: {1}\n".
06486d
+                        format(DIR_PATH, ex.message))
06486d
+                return_status = RETURN_FAILURE
06486d
+            except KeyError as ex:
06486d
+                # this is a bug in build_notification_problem_data()
06486d
+                sys.stderr.write(
06486d
+                    "BUG: problem data misses required element '{0}'"
06486d
+                    " required for uReport notification\n".format(ex.message))
06486d
+
06486d
+                return_status = RETURN_FAILURE
06486d
+
06486d
+    sys.exit(return_status)
06486d
 
06486d
-- 
06486d
1.8.3.1
06486d