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

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