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