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

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