Blame SOURCES/0068-ureport-attach-contact-email-if-configured.patch

a60cd7
From 715a047ada1ca9f9420e194306c5b0fe01b5c9f1 Mon Sep 17 00:00:00 2001
a60cd7
From: Jakub Filak <jfilak@redhat.com>
a60cd7
Date: Thu, 9 Oct 2014 10:24:42 +0200
a60cd7
Subject: [ABRT PATCH 68/68] ureport: attach contact email if configured
a60cd7
a60cd7
Resolves #1150389
a60cd7
a60cd7
Signed-off-by: Jakub Filak <jfilak@redhat.com>
a60cd7
---
a60cd7
 src/plugins/abrt-action-ureport | 37 ++++++++++++++++++++++++++++++++++---
a60cd7
 1 file changed, 34 insertions(+), 3 deletions(-)
a60cd7
a60cd7
diff --git a/src/plugins/abrt-action-ureport b/src/plugins/abrt-action-ureport
a60cd7
index e38a92c..48bebef 100755
a60cd7
--- a/src/plugins/abrt-action-ureport
a60cd7
+++ b/src/plugins/abrt-action-ureport
a60cd7
@@ -8,6 +8,7 @@
a60cd7
 import sys
a60cd7
 import os
a60cd7
 import getopt
a60cd7
+import augeas
a60cd7
 
a60cd7
 from report import dd_opendir, DD_FAIL_QUIETLY_ENOENT
a60cd7
 from reportclient import set_verbosity, error_msg_and_die, error_msg, log1, log
a60cd7
@@ -32,12 +33,31 @@ def init_gettext():
a60cd7
     gettext.bindtextdomain(GETTEXT_PROGNAME, '/usr/share/locale')
a60cd7
     gettext.textdomain(GETTEXT_PROGNAME)
a60cd7
 
a60cd7
-def spawn_and_wait(prog):
a60cd7
+
a60cd7
+def get_augeas(module, file_path):
a60cd7
+    """
a60cd7
+    A function for efficient configuration of Augeas.
a60cd7
+    Augeas modules are placed in /usr/share/augeas/lenses/dist
a60cd7
+    """
a60cd7
+
a60cd7
+    aug_obj = augeas.Augeas(flags=augeas.Augeas.NO_MODL_AUTOLOAD)
a60cd7
+    aug_obj.set("/augeas/load/{0}/lens".format(module), "{0}.lns".format(module))
a60cd7
+    aug_obj.set("/augeas/load/{0}/incl".format(module), file_path)
a60cd7
+    aug_obj.load()
a60cd7
+    return aug_obj
a60cd7
+
a60cd7
+
a60cd7
+def spawn_and_wait(prog, args=None):
a60cd7
+    if args is None:
a60cd7
+        args = [prog]
a60cd7
+    else:
a60cd7
+        args.insert(0, prog)
a60cd7
+
a60cd7
     try:
a60cd7
-        return os.spawnlp(os.P_WAIT, prog, prog)
a60cd7
+         return os.spawnvpe(os.P_WAIT, prog, args, os.environ)
a60cd7
     except OSError as err:
a60cd7
         error_msg(_("Unable to start '%s', error message was: '%s'"),
a60cd7
-                    prog, err)
a60cd7
+                    " ".join(args), err)
a60cd7
         return -1
a60cd7
 
a60cd7
 def try_parse_number(dd, filename):
a60cd7
@@ -78,6 +98,7 @@ if __name__ == "__main__":
a60cd7
             verbose += 1
a60cd7
 
a60cd7
     set_verbosity(verbose)
a60cd7
+    os.environ["ABRT_VERBOSE"] = str(verbose)
a60cd7
 
a60cd7
     # getcwd might fail if cwd was deleted
a60cd7
     try:
a60cd7
@@ -140,6 +161,16 @@ if __name__ == "__main__":
a60cd7
             sys.exit(1)
a60cd7
         dd.save_text("ureports_counter", str(ureports_counter + 1))
a60cd7
         dd.close()
a60cd7
+
a60cd7
+        email = os.getenv("uReport_ContactEmail")
a60cd7
+        if not email:
a60cd7
+            augeas = get_augeas("libreport", "/etc/libreport/plugins/ureport.conf")
a60cd7
+            email = augeas.get("/files/etc/libreport/plugins/ureport.conf/ContactEmail")
a60cd7
+
a60cd7
+        if email:
a60cd7
+            log1("Attaching ContactEmail: " + email)
a60cd7
+            spawn_and_wait("reporter-ureport", ["-A", "-E"])
a60cd7
+
a60cd7
         sys.exit(exitcode)
a60cd7
     else:
a60cd7
         error_msg_and_die(_("reporter-ureport failed with exit code %d" % exitcode))
a60cd7
-- 
a60cd7
1.8.3.1
a60cd7