Blame SOURCES/0021-abrt-action-check-oops-for-hw-error-i18n-add-error-c.patch

baab13
From 56c3d6950f300e98460fe196e0fe138f89ead83d Mon Sep 17 00:00:00 2001
baab13
From: Denys Vlasenko <dvlasenk@redhat.com>
baab13
Date: Mon, 6 Jan 2014 16:47:52 +0100
baab13
Subject: [ABRT PATCH 21/27] abrt-action-check-oops-for-hw-error: i18n, add
baab13
 error check on open()
baab13
baab13
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
baab13
baab13
Related to rhbz#1032077
baab13
baab13
Signed-off-by: Jakub Filak <jfilak@redhat.com>
baab13
---
baab13
 src/plugins/abrt-action-check-oops-for-hw-error.in | 23 ++++++++++++++++------
baab13
 1 file changed, 17 insertions(+), 6 deletions(-)
baab13
baab13
diff --git a/src/plugins/abrt-action-check-oops-for-hw-error.in b/src/plugins/abrt-action-check-oops-for-hw-error.in
baab13
index 83c0f22..ce13caf 100644
baab13
--- a/src/plugins/abrt-action-check-oops-for-hw-error.in
baab13
+++ b/src/plugins/abrt-action-check-oops-for-hw-error.in
baab13
@@ -39,6 +39,15 @@ def tail_with_search(filename, string, maxlen):
baab13
     return l
baab13
 
baab13
 
baab13
+def open_or_die(filename, mode):
baab13
+    try:
baab13
+        f = open(filename, mode)
baab13
+    except IOError as e:
baab13
+        sys.stderr.write(str(e) + "\n")
baab13
+        sys.exit(1)
baab13
+    return f
baab13
+
baab13
+
baab13
 if __name__ == "__main__":
baab13
     try:
baab13
         locale.setlocale(locale.LC_ALL, "")
baab13
@@ -65,16 +74,18 @@ if __name__ == "__main__":
baab13
         sys.exit(0)
baab13
     #
baab13
     # There was an MCE. IOW: it's not a bug, it's a HW error.
baab13
-    f = open("not-reportable", "w")
baab13
-    f.write("The kernel log indicates that hardware errors were detected.\n");
baab13
-    f.write("This is most likely not a software problem.\n");
baab13
+    f = open_or_die("not-reportable", "w")
baab13
+    f.write(_(
baab13
+                "The kernel log indicates that hardware errors were detected.\n"
baab13
+                "This is most likely not a software problem.\n"
baab13
+    ))
baab13
     f.close()
baab13
 
baab13
     #
baab13
     # Did mcelog logged it to /var/log/mcelog
baab13
     # (RHEL6 by default does this)?
baab13
     if os.path.exists("/var/log/mcelog"):
baab13
-        f = open("comment", "w")
baab13
+        f = open_or_die("comment", "w")
baab13
         f.write("The kernel log indicates that hardware errors were detected.\n")
baab13
         f.write("/var/log/mcelog file may have more information.\n")
baab13
         f.write("The last 20 lines of /var/log/mcelog are:\n")
baab13
@@ -89,7 +100,7 @@ if __name__ == "__main__":
baab13
     # On RHEL7, mcelog is run so that its output ends up in syslog.
baab13
     # Do we see that?
baab13
     if file_has_string("/var/log/messages", "mcelog: Hardware event"):
baab13
-        f = open("comment", "w")
baab13
+        f = open_or_die("comment", "w")
baab13
         f.write("The kernel log indicates that hardware errors were detected.\n")
baab13
         f.write("System log may have more information.\n")
baab13
         f.write("The last 20 mcelog lines of system log are:\n")
baab13
@@ -103,7 +114,7 @@ if __name__ == "__main__":
baab13
     #
baab13
     # Apparently, there is no running mcelog daemon!
baab13
     # Let user know that he needs one.
baab13
-    f = open("comment", "w")
baab13
+    f = open_or_die("comment", "w")
baab13
     f.write("The kernel log indicates that hardware errors were detected.\n")
baab13
     f.write("The data was saved by kernel for processing by the mcelog tool.\n")
baab13
     f.write("However, neither /var/log/mcelog nor system log contain mcelog messages.\n")
baab13
-- 
baab13
1.8.3.1
baab13