- the event takes care about asking user for permission to do something which needs user's permission (upload coredump, run local analysis) - the event starts the local analysis if the remote analysis fails or if the remote analysis was rejected by user
Signed-off-by: Jakub Filak jfilak@redhat.com --- abrt.spec.in | 2 + po/POTFILES.in | 2 + src/plugins/Makefile.am | 9 +++ src/plugins/abrt-action-analyze-smart.in | 117 +++++++++++++++++++++++++++++++ src/plugins/analyze_Smart.xml.in | 41 +++++++++++ src/plugins/ccpp_event.conf | 5 +- 6 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 src/plugins/abrt-action-analyze-smart.in create mode 100644 src/plugins/analyze_Smart.xml.in
diff --git a/abrt.spec.in b/abrt.spec.in index a1c00ba..ebb81a0 100644 --- a/abrt.spec.in +++ b/abrt.spec.in @@ -467,12 +467,14 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_bindir}/abrt-handle-upload %{_bindir}/abrt-action-save-package-data %{_bindir}/abrt-watch-log +%{_bindir}/abrt-action-analyze-smart %config(noreplace) %{_sysconfdir}/%{name}/abrt.conf %config(noreplace) %{_sysconfdir}/%{name}/abrt-action-save-package-data.conf %config(noreplace) %{_sysconfdir}/%{name}/gpg_keys %config(noreplace) %{_sysconfdir}/libreport/events.d/abrt_event.conf %config(noreplace) %{_sysconfdir}/libreport/events.d/smart_event.conf %config(noreplace) %{_sysconfdir}/libreport/events.d/smolt_event.conf +%config(noreplace) %{_sysconfdir}/libreport/events/analyze_Smart.xml %dir %attr(0755, abrt, abrt) %{_localstatedir}/spool/%{name} %dir %attr(0700, abrt, abrt) %{_localstatedir}/spool/%{name}-upload # abrtd runs as root diff --git a/po/POTFILES.in b/po/POTFILES.in index 3bd7a1b..095aef2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -17,6 +17,7 @@ src/plugins/abrt-action-analyze-backtrace.c src/plugins/abrt-action-analyze-c.c src/plugins/abrt-action-analyze-oops.c src/plugins/abrt-action-analyze-python.c +src/plugins/abrt-action-analyze-smart.in src/plugins/abrt-action-analyze-vmcore.in src/plugins/abrt-action-generate-backtrace.c src/plugins/abrt-action-generate-core-backtrace.c @@ -35,6 +36,7 @@ src/plugins/bodhi.c
src/cli/abrt-cli.c src/cli/list.c +src/plugins/analyze_Smart.xml.in src/plugins/analyze_VMcore.xml.in src/plugins/collect_GConf.xml.in src/plugins/collect_Smolt.xml.in diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 675b1a7..7d1f523 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -3,6 +3,7 @@ bin_SCRIPTS = \ abrt-action-install-debuginfo \ abrt-action-analyze-core \ + abrt-action-analyze-smart \ abrt-action-analyze-vmcore \ abrt-action-list-dsos
@@ -30,6 +31,7 @@ eventsdir = $(EVENTS_DIR) dist_events_DATA = \ analyze_LocalGDB.xml \ analyze_RetraceServer.xml \ + analyze_Smart.xml \ analyze_VMcore.xml \ collect_xsession_errors.xml \ collect_Smolt.xml \ @@ -59,6 +61,7 @@ PYTHON_FILES = \ abrt-action-install-debuginfo.in \ abrt-action-list-dsos \ abrt-action-analyze-core \ + abrt-action-analyze-smart.in \ abrt-action-analyze-vmcore.in
EXTRA_DIST = \ @@ -70,6 +73,7 @@ EXTRA_DIST = \ collect_vimrc_system.xml.in \ analyze_LocalGDB.xml.in \ analyze_RetraceServer.xml.in \ + analyze_Smart.xml.in \ analyze_VMcore.xml.in \ abrt-action-analyze-vmcore \ https-utils.h \ @@ -266,3 +270,8 @@ abrt_bodhi_SOURCES = \
DEFS = -DLOCALEDIR="$(localedir)" @DEFS@ + + +abrt-action-analyze-smart: abrt-action-analyze-smart.in + sed -e s,@libexecdir@,$(libexecdir),g \ + $< >$@ diff --git a/src/plugins/abrt-action-analyze-smart.in b/src/plugins/abrt-action-analyze-smart.in new file mode 100644 index 0000000..399b349 --- /dev/null +++ b/src/plugins/abrt-action-analyze-smart.in @@ -0,0 +1,117 @@ +#!/usr/bin/env python +"""This module provides a function for executing of disjunction of analyze +events. +""" + +import sys +import os +from argparse import ArgumentParser +import locale +import gettext +from subprocess import Popen + + +GETTEXT_PROGNAME = "abrt-action-analyze-smart" + +_ = gettext.lgettext + +def ask_yes_no_save_result(option_name, question): + """Asks user for answer to yes/no/yesforever question. + + Keyword arguments: + option_name -- a key for configuration to store the yesforever answer + question -- a displayed question + + Returns True if user's answer is yes or yes forever; otherwise returns + False. + + """ + + sys.stdout.write("ASK_YES_NO_YESFOREVER {0} {1}\n" + .format(option_name, question)) + sys.stdout.flush() + return sys.stdin.readline() == "yes\n" + +def handle_event(event_name, problem_dir): + """Helper function handling a single event + + Keyword arguments: + envet_name -- a name of handled event + problem_dir -- a path to problem directory + + Returns True if the handled event was successfully executed; otherwise + returns False. + + """ + + executable = "@libexecdir@/abrt-handle-event" + try: + proc = Popen([executable, "-e", event_name, "--", problem_dir]) + return proc.wait() == 0 + except OSError as e: + sys.stderr.write("Can't run '{0}': {1}\n".format(executable, e)) + sys.exit(1) + + +def run_analyze_smart(problem_dir): + """Runs analyze_RetraceServer event or analyze_LocalGB event. + + At first runs analyze_RetraceServer. If user dismisses + analyze_RetraceServer event or if the run fails the analyze_LocalGDB event + will be run. + + Keyword arguments: + problem_dir -- a path to problem directory + + Returns True if any of the events was successfuly performed; otherwise + returns False. + + """ + + analyzed = False + allowed = ask_yes_no_save_result("abrt_analyze_smart_ask_upload_coredump", + _("Ok to upload core dump? (It may contain sensitive data). "\ + "If your answer is 'No', a stack trace will be generated localy. "\ + "(It may download a huge amount of data).")) + + if allowed: + analyzed = handle_event("analyze_RetraceServer", problem_dir) + + # temporary helper variables for better readability + option = "abrt_analyze_smart_ask_perform_local_analysis" + question = _("Do you want to generate a stack trace localy? "\ + "(It may download a huge amount of data but reporting "\ + "can't continue without stack trace).") + + # run local GDB if the retrace event was dismissed + # or if the retrace event failed and user gave us permission to run local GDB + if not allowed or (not analyzed and ask_yes_no_save_result(option, question)): + analyzed = handle_event("analyze_LocalGDB", problem_dir) + + return analyzed + + +if __name__ == "__main__": + try: + locale.setlocale(locale.LC_ALL, "") + except locale.Error: + os.environ['LC_ALL'] = 'C' + locale.setlocale(locale.LC_ALL, "") + + # Defeat "AttributeError: 'module' object has no attribute 'nl_langinfo'" + try: + gettext.bind_textdomain_codeset(GETTEXT_PROGNAME, + locale.nl_langinfo(locale.CODESET)) + except AttributeError: + pass + + gettext.bindtextdomain(GETTEXT_PROGNAME, '/usr/share/locale') + gettext.textdomain(GETTEXT_PROGNAME) + + CMDARGS = ArgumentParser(description = _('Smartly runs analyze events')) + CMDARGS.add_argument('-d', '--problem-dir', type=str, + default='.', help=_('Problem directory')) + + OPTIONS = CMDARGS.parse_args() + + sys.exit(0 if run_analyze_smart(vars(OPTIONS)['problem_dir']) else 1) diff --git a/src/plugins/analyze_Smart.xml.in b/src/plugins/analyze_Smart.xml.in new file mode 100644 index 0000000..2d4aa3b --- /dev/null +++ b/src/plugins/analyze_Smart.xml.in @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<event> + <name>Smart Analyze Event</name> + <_description>Send core dump to remote retrace server for analysis or perform local analysis if the remote analysis fails</_description> + <_long-description>Uploads coredump to a server, which generates backtrace and returns it. If user doens't want to upload his coredump to anywhere the event performs local analysis. Local analysis is run event if remote analysis fails. + Pros: no need for debuginfo downloads. Retrace server's database of debuginfos is more complete. Retrace server may generate better backtraces. + Cons: coredump you upload contains all the data from the crashed program, including your private data, if any. + </_long-description> + <creates-items>backtrace</creates-items> + <gui-review-elements>no</gui-review-elements> + + <!-- The event shows a message about sensitive data on its own. + It has to ask user on its own because other tools interrupts + processing at all if user rejects sending of sensitive data. + The second result for showing the question on its own is that the + event implementation automatically runs the analyze_LocalGDB event if + user dismisses the analyze_RetraceServer event. --> + <sending-sensitive-data>no</sending-sensitive-data> + + <!-- The following options are taken from analyze_RetraceServer + event configuration because the analyze smart event internally runs + the analyze_RetraceServer. The current implementation of the event + and libreport's run event framework can't load configuration of an + internally executed event. This causes that user can be forced to + configure remote analysis on two different places. --> + <options> + <option type="text" name="RETRACE_SERVER_URL"> + <_label>Retrace server URL</_label> + <default-value>retrace.fedoraproject.org</default-value> + <allow-empty>no</allow-empty> + <_description>Address of the retrace server</_description> + </option> + <option type="text" name="RETRACE_SERVER_INSECURE"> + <_label>Insecure</_label> + <allow-empty>yes</allow-empty> + <_description>Whether or not to use insecure connection</_description> + <_note-html>Write "insecure" to allow insecure connection <a href="https://fedorahosted.org/abrt/wiki/AbrtRetraceServerInsecureConnection" >(warning)</a></_note-html> + </option> + + </options> +</event> diff --git a/src/plugins/ccpp_event.conf b/src/plugins/ccpp_event.conf index 81b14d2..0d6300e 100644 --- a/src/plugins/ccpp_event.conf +++ b/src/plugins/ccpp_event.conf @@ -56,6 +56,9 @@ EVENT=report_uReport analyzer=CCpp EVENT=post_report analyzer=CCpp reporter-ureport -r
+EVENT=analyze_Smart analyzer=CCpp + abrt-action-analyze-smart + # Reporting of C/Cpp problems EVENT=report-gui analyzer=CCpp - report-gtk -e report_uReport -e analyze_RetraceServer -e report_Bugzilla -e post_report -- "$DUMP_DIR" + report-gtk -e report_uReport -e analyze_Smart -e report_Bugzilla -e post_report -- "$DUMP_DIR"
On 09/13/2012 12:02 PM, Jakub Filak wrote:
- the event takes care about asking user for permission to do something which needs user's permission (upload coredump, run local analysis)
- the event starts the local analysis if the remote analysis fails or if the remote analysis was rejected by user
Signed-off-by: Jakub Filak jfilak@redhat.com
abrt.spec.in | 2 + po/POTFILES.in | 2 + src/plugins/Makefile.am | 9 +++ src/plugins/abrt-action-analyze-smart.in | 117 +++++++++++++++++++++++++++++++ src/plugins/analyze_Smart.xml.in | 41 +++++++++++ src/plugins/ccpp_event.conf | 5 +- 6 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 src/plugins/abrt-action-analyze-smart.in create mode 100644 src/plugins/analyze_Smart.xml.in
diff --git a/abrt.spec.in b/abrt.spec.in index a1c00ba..ebb81a0 100644 --- a/abrt.spec.in +++ b/abrt.spec.in @@ -467,12 +467,14 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %{_bindir}/abrt-handle-upload %{_bindir}/abrt-action-save-package-data %{_bindir}/abrt-watch-log +%{_bindir}/abrt-action-analyze-smart %config(noreplace) %{_sysconfdir}/%{name}/abrt.conf %config(noreplace) %{_sysconfdir}/%{name}/abrt-action-save-package-data.conf %config(noreplace) %{_sysconfdir}/%{name}/gpg_keys %config(noreplace) %{_sysconfdir}/libreport/events.d/abrt_event.conf %config(noreplace) %{_sysconfdir}/libreport/events.d/smart_event.conf %config(noreplace) %{_sysconfdir}/libreport/events.d/smolt_event.conf +%config(noreplace) %{_sysconfdir}/libreport/events/analyze_Smart.xml %dir %attr(0755, abrt, abrt) %{_localstatedir}/spool/%{name} %dir %attr(0700, abrt, abrt) %{_localstatedir}/spool/%{name}-upload # abrtd runs as root diff --git a/po/POTFILES.in b/po/POTFILES.in index 3bd7a1b..095aef2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -17,6 +17,7 @@ src/plugins/abrt-action-analyze-backtrace.c src/plugins/abrt-action-analyze-c.c src/plugins/abrt-action-analyze-oops.c src/plugins/abrt-action-analyze-python.c +src/plugins/abrt-action-analyze-smart.in src/plugins/abrt-action-analyze-vmcore.in src/plugins/abrt-action-generate-backtrace.c src/plugins/abrt-action-generate-core-backtrace.c @@ -35,6 +36,7 @@ src/plugins/bodhi.c
src/cli/abrt-cli.c src/cli/list.c +src/plugins/analyze_Smart.xml.in src/plugins/analyze_VMcore.xml.in src/plugins/collect_GConf.xml.in src/plugins/collect_Smolt.xml.in diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 675b1a7..7d1f523 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -3,6 +3,7 @@ bin_SCRIPTS = \ abrt-action-install-debuginfo \ abrt-action-analyze-core \
- abrt-action-analyze-smart \ abrt-action-analyze-vmcore \ abrt-action-list-dsos
@@ -30,6 +31,7 @@ eventsdir = $(EVENTS_DIR) dist_events_DATA = \ analyze_LocalGDB.xml \ analyze_RetraceServer.xml \
- analyze_Smart.xml \ analyze_VMcore.xml \ collect_xsession_errors.xml \ collect_Smolt.xml \
@@ -59,6 +61,7 @@ PYTHON_FILES = \ abrt-action-install-debuginfo.in \ abrt-action-list-dsos \ abrt-action-analyze-core \
- abrt-action-analyze-smart.in \ abrt-action-analyze-vmcore.in
EXTRA_DIST = \ @@ -70,6 +73,7 @@ EXTRA_DIST = \ collect_vimrc_system.xml.in \ analyze_LocalGDB.xml.in \ analyze_RetraceServer.xml.in \
- analyze_Smart.xml.in \ analyze_VMcore.xml.in \ abrt-action-analyze-vmcore \ https-utils.h \
@@ -266,3 +270,8 @@ abrt_bodhi_SOURCES = \
DEFS = -DLOCALEDIR="$(localedir)" @DEFS@
+abrt-action-analyze-smart: abrt-action-analyze-smart.in
- sed -e s,@libexecdir@,$(libexecdir),g \
$< >$@
diff --git a/src/plugins/abrt-action-analyze-smart.in b/src/plugins/abrt-action-analyze-smart.in new file mode 100644 index 0000000..399b349 --- /dev/null +++ b/src/plugins/abrt-action-analyze-smart.in @@ -0,0 +1,117 @@ +#!/usr/bin/env python +"""This module provides a function for executing of disjunction of analyze +events. +"""
+import sys +import os +from argparse import ArgumentParser +import locale +import gettext +from subprocess import Popen
+GETTEXT_PROGNAME = "abrt-action-analyze-smart"
+_ = gettext.lgettext
+def ask_yes_no_save_result(option_name, question):
- """Asks user for answer to yes/no/yesforever question.
- Keyword arguments:
- option_name -- a key for configuration to store the yesforever answer
- question -- a displayed question
- Returns True if user's answer is yes or yes forever; otherwise returns
- False.
- """
- sys.stdout.write("ASK_YES_NO_YESFOREVER {0} {1}\n"
.format(option_name, question))
- sys.stdout.flush()
- return sys.stdin.readline() == "yes\n"
+def handle_event(event_name, problem_dir):
- """Helper function handling a single event
- Keyword arguments:
- envet_name -- a name of handled event
- problem_dir -- a path to problem directory
- Returns True if the handled event was successfully executed; otherwise
- returns False.
- """
- executable = "@libexecdir@/abrt-handle-event"
- try:
proc = Popen([executable, "-e", event_name, "--", problem_dir])
return proc.wait() == 0
- except OSError as e:
sys.stderr.write("Can't run '{0}': {1}\n".format(executable, e))
sys.exit(1)
+def run_analyze_smart(problem_dir):
- """Runs analyze_RetraceServer event or analyze_LocalGB event.
- At first runs analyze_RetraceServer. If user dismisses
- analyze_RetraceServer event or if the run fails the analyze_LocalGDB event
- will be run.
- Keyword arguments:
- problem_dir -- a path to problem directory
- Returns True if any of the events was successfuly performed; otherwise
typo: successfuly
- returns False.
- """
- analyzed = False
- allowed = ask_yes_no_save_result("abrt_analyze_smart_ask_upload_coredump",
_("Ok to upload core dump? (It may contain sensitive data). "\
"If your answer is 'No', a stack trace will be generated localy. "\
"(It may download a huge amount of data)."))
typo: locally
- if allowed:
analyzed = handle_event("analyze_RetraceServer", problem_dir)
- # temporary helper variables for better readability
- option = "abrt_analyze_smart_ask_perform_local_analysis"
- question = _("Do you want to generate a stack trace localy? "\
"(It may download a huge amount of data but reporting "\
"can't continue without stack trace).")
- # run local GDB if the retrace event was dismissed
- # or if the retrace event failed and user gave us permission to run local GDB
- if not allowed or (not analyzed and ask_yes_no_save_result(option, question)):
analyzed = handle_event("analyze_LocalGDB", problem_dir)
- return analyzed
+if __name__ == "__main__":
- try:
locale.setlocale(locale.LC_ALL, "")
- except locale.Error:
os.environ['LC_ALL'] = 'C'
locale.setlocale(locale.LC_ALL, "")
- # Defeat "AttributeError: 'module' object has no attribute 'nl_langinfo'"
- try:
gettext.bind_textdomain_codeset(GETTEXT_PROGNAME,
locale.nl_langinfo(locale.CODESET))
- except AttributeError:
pass
- gettext.bindtextdomain(GETTEXT_PROGNAME, '/usr/share/locale')
- gettext.textdomain(GETTEXT_PROGNAME)
- CMDARGS = ArgumentParser(description = _('Smartly runs analyze events'))
- CMDARGS.add_argument('-d', '--problem-dir', type=str,
default='.', help=_('Problem directory'))
- OPTIONS = CMDARGS.parse_args()
- sys.exit(0 if run_analyze_smart(vars(OPTIONS)['problem_dir']) else 1)
diff --git a/src/plugins/analyze_Smart.xml.in b/src/plugins/analyze_Smart.xml.in new file mode 100644 index 0000000..2d4aa3b --- /dev/null +++ b/src/plugins/analyze_Smart.xml.in @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<event>
- <name>Smart Analyze Event</name>
- <_description>Send core dump to remote retrace server for analysis or perform local analysis if the remote analysis fails</_description>
- <_long-description>Uploads coredump to a server, which generates backtrace and returns it. If user doens't want to upload his coredump to anywhere the event performs local analysis. Local analysis is run event if remote
typo: doens't
analysis fails.
- Pros: no need for debuginfo downloads. Retrace server's database of debuginfos is more complete. Retrace server may generate better backtraces.
- Cons: coredump you upload contains all the data from the crashed program, including your private data, if any.
- </_long-description>
- <creates-items>backtrace</creates-items>
- <gui-review-elements>no</gui-review-elements>
- <!-- The event shows a message about sensitive data on its own.
It has to ask user on its own because other tools interrupts
processing at all if user rejects sending of sensitive data.
The second result for showing the question on its own is that the
event implementation automatically runs the analyze_LocalGDB event if
user dismisses the analyze_RetraceServer event. -->
- <sending-sensitive-data>no</sending-sensitive-data>
- <!-- The following options are taken from analyze_RetraceServer
event configuration because the analyze smart event internally runs
the analyze_RetraceServer. The current implementation of the event
and libreport's run event framework can't load configuration of an
internally executed event. This causes that user can be forced to
configure remote analysis on two different places. -->
<options>
<option type="text" name="RETRACE_SERVER_URL">
<_label>Retrace server URL</_label>
<default-value>retrace.fedoraproject.org</default-value>
<allow-empty>no</allow-empty>
<_description>Address of the retrace server</_description>
</option>
<option type="text" name="RETRACE_SERVER_INSECURE">
<_label>Insecure</_label>
<allow-empty>yes</allow-empty>
<_description>Whether or not to use insecure connection</_description>
<_note-html>Write "insecure" to allow insecure connection <a href="https://fedorahosted.org/abrt/wiki/AbrtRetraceServerInsecureConnection" >(warning)</a></_note-html>
</option>
</options>
+</event> diff --git a/src/plugins/ccpp_event.conf b/src/plugins/ccpp_event.conf index 81b14d2..0d6300e 100644 --- a/src/plugins/ccpp_event.conf +++ b/src/plugins/ccpp_event.conf @@ -56,6 +56,9 @@ EVENT=report_uReport analyzer=CCpp EVENT=post_report analyzer=CCpp reporter-ureport -r
+EVENT=analyze_Smart analyzer=CCpp
abrt-action-analyze-smart
# Reporting of C/Cpp problems EVENT=report-gui analyzer=CCpp
report-gtk -e report_uReport -e analyze_RetraceServer -e report_Bugzilla -e post_report -- "$DUMP_DIR"
report-gtk -e report_uReport -e analyze_Smart -e report_Bugzilla -e post_report -- "$DUMP_DIR"
Works fine, fix the typos and push it please.
crash-catcher@lists.fedorahosted.org