[LIBREPORT PATCH 1/2] reporter-rhtsupport: make -t without CASE_NO ask for it
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/plugins/reporter-rhtsupport.c | 38 ++++++++++++++++++++++++++++++++------
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
index fe13423..c5e3c95 100644
--- a/src/plugins/reporter-rhtsupport.c
+++ b/src/plugins/reporter-rhtsupport.c
@@ -265,21 +265,47 @@ int main(int argc, char **argv)
{
if (!case_no)
{
- /* -t: extract URL where we previously reported it */
+ /* -t: ask for it */
report_result_t *reported_to = get_reported_to(dump_dir_name);
if (!reported_to || !reported_to->url)
- error_msg_and_die("Can't attach: problem data in '%s' "
- "was not reported to RHTSupport and therefore has no URL",
- dump_dir_name);
- //log("URL:'%s'", reported_to->url);
- //log("MSG:'%s'", reported_to->msg);
+ {
+ case_no = ask(_("Case number:"));
+ if (!case_no)
+ perror_msg_and_die("ask");
+ strtrim((char*)case_no);
+ if (case_no[0])
+ goto got_case_no;
+ /* User just pressed [enter] (or [cancel] in GIU). */
+ error_msg_and_die(_("Reporting cancelled"));
+ }
+ /* We have a preexisting URL */
+ log(_("Note: was already reported to '%s'"), reported_to->url);
+#if 1
+ case_no = ask(_("Case number:"));
+#else
+ case_no = ask(_("Case number (default:previously reported case):"));
+#endif
+ if (!case_no)
+ perror_msg_and_die("ask");
+ strtrim((char*)case_no);
+ if (case_no[0])
+ goto got_case_no;
+ /* User just pressed [enter]. Use previous URL */
+#if 1
+ error_msg_and_die(_("Reporting cancelled"));
+#else
+//GUI BUG: would like to use this, but in GUI, [cancel] in ask dialog
+//also results in ""!
+//Enabling this will make [cancel] in GUI to NOT cancel!
free(url);
url = reported_to->url;
reported_to->url = NULL;
free_report_result(reported_to);
+#endif
}
else
{
+ got_case_no:;
/* -tCASE */
char *url1 = concat_path_file(url, "cases");
free(url);
--
1.8.1.4
11 years, 1 month
[RHEL6 LIBREPORT PATCH 1/2] Change default conf to show three options: new case/existing case/tarball
by Denys Vlasenko
Per the discussion with GSS people, this change makes "abrt-cli report DIR"
to show this choice of reporters:
How would you like to report the problem?
1) New Red Hat Support case
2) Existing Red Hat Support case
3) Save to tar archive
Choice (2) is similar to (1) but in addition it prompts: "Case number:"
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
po/POTFILES.in | 2 +
src/gui-wizard-gtk/wizard.c | 8 +++---
src/plugins/Makefile.am | 5 ++++
src/plugins/bugzilla_event.conf | 3 +-
src/plugins/mailx_event.conf | 6 +++-
src/plugins/print_event.conf | 5 ++-
src/plugins/report_RHTSupport.xml.in | 4 +-
src/plugins/reporter-rhtsupport.c | 38 ++++++++++++++++++++++++++++-----
src/plugins/rhtsupport_event.conf | 9 +++++++-
src/plugins/uploader_event.conf | 3 +-
10 files changed, 64 insertions(+), 19 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 353b67c..b4e84fd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -24,6 +24,8 @@ src/plugins/report_Kerneloops.xml.in
src/plugins/report_Logger.xml.in
src/plugins/report_Mailx.xml.in
src/plugins/report_RHTSupport.xml.in
+src/plugins/report_RHTSupportAttach.xml.in
+src/plugins/report_Tarball.xml.in
src/plugins/report_Uploader.xml.in
src/plugins/reporter-bugzilla.c
src/plugins/reporter-kerneloops.c
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 425c1c7..c24ca8c 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -910,7 +910,7 @@ static event_gui_data_t *add_event_buttons(GtkBox *box,
if (get_problem_data_item_or_NULL(g_cd, cfg->ec_creates_items))
{
green_choice = true;
- event_description = tmp_description = xasprintf(_("(not needed, '%s' already exists)"), cfg->ec_creates_items);
+ tmp_description = xasprintf(_("(not needed, '%s' already exists)"), cfg->ec_creates_items);
}
}
}
@@ -919,9 +919,9 @@ static event_gui_data_t *add_event_buttons(GtkBox *box,
//VERB2 log("adding button '%s' to box %p", event_name, box);
char *event_label = xasprintf("%s%s%s",
- event_screen_name,
- (event_description ? " - " : ""),
- event_description ? event_description : ""
+ event_description ? event_description : event_screen_name,
+ tmp_description ? " - " : "",
+ tmp_description ? tmp_description : ""
);
free(tmp_description);
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 0284b3c..a92cb49 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -27,7 +27,9 @@ dist_events_DATA = \
report_Logger.xml \
report_Mailx.xml \
report_RHTSupport.xml \
+ report_RHTSupportAttach.xml \
report_Kerneloops.xml \
+ report_Tarball.xml \
report_Uploader.xml
@INTLTOOL_XML_RULE@
@@ -39,6 +41,7 @@ dist_eventsconf_DATA = \
print_event.conf \
bugzilla_event.conf \
rhtsupport_event.conf \
+ tarball_event.conf \
uploader_event.conf
EXTRA_DIST = \
@@ -48,7 +51,9 @@ EXTRA_DIST = \
report_Logger.xml.in \
report_Mailx.xml.in \
report_RHTSupport.xml.in \
+ report_RHTSupportAttach.xml.in \
report_Kerneloops.xml.in \
+ report_Tarball.xml.in \
report_Uploader.xml.in
$(DESTDIR)/$(DEBUG_INFO_DIR):
diff --git a/src/plugins/bugzilla_event.conf b/src/plugins/bugzilla_event.conf
index 109c581..828da94 100644
--- a/src/plugins/bugzilla_event.conf
+++ b/src/plugins/bugzilla_event.conf
@@ -1 +1,2 @@
-EVENT=report_Bugzilla analyzer=libreport reporter-bugzilla -b
+EVENT=report_Bugzilla analyzer=libreport
+ reporter-bugzilla -b
diff --git a/src/plugins/mailx_event.conf b/src/plugins/mailx_event.conf
index e03bb96..f3176bd 100644
--- a/src/plugins/mailx_event.conf
+++ b/src/plugins/mailx_event.conf
@@ -1,6 +1,8 @@
# This is already enabled in abrt_event.conf
-#EVENT=post-create reporter-mailx --notify-only -c /etc/libreport/plugins/mailx.conf
+#EVENT=post-create
+ reporter-mailx --notify-only -c /etc/libreport/plugins/mailx.conf
# Users should user rhtsupport plugin, so disabling others by default
# to not confuse users with too many options
-#EVENT=report_Mailx reporter-mailx
+#EVENT=report_Mailx
+ reporter-mailx
diff --git a/src/plugins/print_event.conf b/src/plugins/print_event.conf
index 6e6e38e..5514c55 100644
--- a/src/plugins/print_event.conf
+++ b/src/plugins/print_event.conf
@@ -1,2 +1,3 @@
-EVENT=report_Logger
- reporter-print -o "${Logger_Log_File:-/tmp/abrt.log}" -a "${Logger_Append:-no}" -r
+# Yet another example
+#EVENT=report_Logger
+ reporter-print -o "${Logger_Log_File:-/tmp/abrt.log}" -a "${Logger_Append:-no}" -r
diff --git a/src/plugins/report_RHTSupport.xml.in b/src/plugins/report_RHTSupport.xml.in
index d1993f0..db01d14 100644
--- a/src/plugins/report_RHTSupport.xml.in
+++ b/src/plugins/report_RHTSupport.xml.in
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<event>
- <_name>Red Hat Customer Support</_name>
- <_description>Report to Red Hat support</_description>
+ <_name>New Red Hat Support case</_name>
+ <_description>Create new Red Hat Support case</_description>
<requires-items>package</requires-items>
<exclude-items-by-default>count,event_log,reported_to,vmcore</exclude-items-by-default>
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
index 1c6b763..aab0a7f 100644
--- a/src/plugins/reporter-rhtsupport.c
+++ b/src/plugins/reporter-rhtsupport.c
@@ -274,21 +274,47 @@ int main(int argc, char **argv)
{
if (!case_no)
{
- /* -t: extract URL where we previously reported it */
+ /* -t: ask for it */
report_result_t *reported_to = get_reported_to(dump_dir_name);
if (!reported_to || !reported_to->url)
- error_msg_and_die("Can't attach: problem data in '%s' "
- "was not reported to RHTSupport and therefore has no URL",
- dump_dir_name);
- //log("URL:'%s'", reported_to->url);
- //log("MSG:'%s'", reported_to->msg);
+ {
+ case_no = ask(_("Case number:"));
+ if (!case_no)
+ perror_msg_and_die("ask");
+ strtrim((char*)case_no);
+ if (case_no[0])
+ goto got_case_no;
+ /* User just pressed [enter] (or [cancel] in GIU). */
+ error_msg_and_die(_("Reporting cancelled"));
+ }
+ /* We have a preexisting URL */
+ log(_("Note: was already reported to '%s'"), reported_to->url);
+#if 1
+ case_no = ask(_("Case number:"));
+#else
+ case_no = ask(_("Case number (default:previously reported case):"));
+#endif
+ if (!case_no)
+ perror_msg_and_die("ask");
+ strtrim((char*)case_no);
+ if (case_no[0])
+ goto got_case_no;
+ /* User just pressed [enter]. Use previous URL */
+#if 1
+ error_msg_and_die(_("Reporting cancelled"));
+#else
+//GUI BUG: would like to use this, but in GUI, [cancel] in ask dialog
+//also results in ""!
+//Enabling this will make [cancel] in GUI to NOT cancel!
free(url);
url = reported_to->url;
reported_to->url = NULL;
free_report_result(reported_to);
+#endif
}
else
{
+ got_case_no:;
/* -tCASE */
char *url1 = concat_path_file(url, "cases");
free(url);
diff --git a/src/plugins/rhtsupport_event.conf b/src/plugins/rhtsupport_event.conf
index 2e9b27e..c905d57 100644
--- a/src/plugins/rhtsupport_event.conf
+++ b/src/plugins/rhtsupport_event.conf
@@ -1 +1,8 @@
-EVENT=report_RHTSupport reporter-rhtsupport
+# On RHEL, we want "abrt-cli report DIR" to let users run
+# RHTS reporter (among other possible choices):
+EVENT=report_RHTSupport
+ reporter-rhtsupport
+
+EVENT=report_RHTSupportAttach
+ #TODO: make -t w/o CASE_NO ask for case no using ask()
+ reporter-rhtsupport -t
diff --git a/src/plugins/uploader_event.conf b/src/plugins/uploader_event.conf
index 2406008..1c624e7 100644
--- a/src/plugins/uploader_event.conf
+++ b/src/plugins/uploader_event.conf
@@ -1 +1,2 @@
-EVENT=report_Uploader analyzer=libreport reporter-upload
+EVENT=report_Uploader analyzer=libreport
+ reporter-upload
--
1.7.1
11 years, 1 month
[ABRT PATCH] post-create: record runlevel
by Jakub Filak
Closes #630
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/daemon/abrt_event.conf | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/daemon/abrt_event.conf b/src/daemon/abrt_event.conf
index a765ce6..55f0637 100644
--- a/src/daemon/abrt_event.conf
+++ b/src/daemon/abrt_event.conf
@@ -59,6 +59,10 @@ EVENT=post-create component= remote!=1
EVENT=post-create
if [ -f uid ]; then getent passwd "`cat uid`" | cut -d: -f1 >username; fi
+# Record runlevel (if not yet done) and don't return non-0 if it fails:
+EVENT=post-create runlevel=
+ (runlevel >runlevel 2>&1 || exit 0)
+
# Example: if you want to save sosreport immediately at the moment of a crash:
# (alternatively, you can add similar command to EVENT=analyze_foo's,
# if you would rather perform this collection later):
--
1.8.1.4
11 years, 1 month
[ABRT PATCH] dbus: Ensure we're linked to GObject
by Jakub Filak
- see https://bugzilla.gnome.org/show_bug.cgi?id=691077
- closes rhbz#927919
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/dbus/abrt-dbus.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/dbus/abrt-dbus.c b/src/dbus/abrt-dbus.c
index 9d7f1ff..5389753 100644
--- a/src/dbus/abrt-dbus.c
+++ b/src/dbus/abrt-dbus.c
@@ -894,7 +894,15 @@ int main(int argc, char *argv[])
error_msg_and_die(_("This program must be run as root."));
#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35)
+ /* Became deprecated in glib-2.35.1 (branch 2.36 commit df02fa1e4cc61a2c7f3aafdf1a6534a831f1c0d6) */
g_type_init();
+#else
+ /* Be defensive and ensure we're linked to GObject
+ * https://bugzilla.gnome.org/show_bug.cgi?id=691077
+ *
+ * See glib README -> Notes about GLib 2.36, 1st paragraph
+ */
+ g_type_ensure(G_TYPE_OBJECT);
#endif
/* We are lazy here - we don't want to manually provide
--
1.8.1.4
11 years, 1 month
[FAF PATCH] hub: implement daily statistics page(s)
by Richard Marko
Closes #155
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
configure.ac | 2 +
pyfaf/hub/Makefile.am | 2 +-
pyfaf/hub/media/style.css | 9 +++
pyfaf/hub/menu.py | 7 +++
pyfaf/hub/settings.py | 1 +
pyfaf/hub/stats/Makefile.am | 2 +
pyfaf/hub/stats/__init__.py | 1 +
pyfaf/hub/stats/urls.py | 42 +++++++++++++
pyfaf/hub/stats/views.py | 112 +++++++++++++++++++++++++++++++++
pyfaf/hub/templates/Makefile.am | 2 +-
pyfaf/hub/templates/stats/Makefile.am | 4 ++
pyfaf/hub/templates/stats/by_date.html | 71 +++++++++++++++++++++
pyfaf/hub/urls.py | 1 +
13 files changed, 254 insertions(+), 2 deletions(-)
create mode 100644 pyfaf/hub/stats/Makefile.am
create mode 100644 pyfaf/hub/stats/__init__.py
create mode 100644 pyfaf/hub/stats/urls.py
create mode 100644 pyfaf/hub/stats/views.py
create mode 100644 pyfaf/hub/templates/stats/Makefile.am
create mode 100644 pyfaf/hub/templates/stats/by_date.html
diff --git a/configure.ac b/configure.ac
index 9c619c0..b0117a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,7 @@ AC_CONFIG_FILES([
pyfaf/hub/problems/Makefile
pyfaf/hub/reports/Makefile
pyfaf/hub/summary/Makefile
+ pyfaf/hub/stats/Makefile
pyfaf/hub/status/Makefile
pyfaf/hub/dumpdirs/Makefile
pyfaf/hub/templates/Makefile
@@ -64,6 +65,7 @@ AC_CONFIG_FILES([
pyfaf/hub/templates/problems/Makefile
pyfaf/hub/templates/reports/Makefile
pyfaf/hub/templates/summary/Makefile
+ pyfaf/hub/templates/stats/Makefile
pyfaf/hub/templates/status/Makefile
pyfaf/hub/templates/dumpdirs/Makefile
pyfaf/hub/templatetags/Makefile
diff --git a/pyfaf/hub/Makefile.am b/pyfaf/hub/Makefile.am
index 1f1fadb..f6fa88a 100644
--- a/pyfaf/hub/Makefile.am
+++ b/pyfaf/hub/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = templates xmlrpc summary problems media reports status common templatetags services query dumpdirs
+SUBDIRS = templates xmlrpc summary problems media reports status common templatetags services query dumpdirs stats
hub_PYTHON = hub.wsgi __init__.py menu.py settings.py urls.py
hubdir = $(pythondir)/pyfaf/hub
diff --git a/pyfaf/hub/media/style.css b/pyfaf/hub/media/style.css
index 381f522..c01a1fc 100644
--- a/pyfaf/hub/media/style.css
+++ b/pyfaf/hub/media/style.css
@@ -167,3 +167,12 @@ select, input[type="file"] {
#diff-choice select {
width: 100px;
}
+
+/* statistics */
+#date_stats table div.progress {
+ margin-bottom: 0px;
+}
+
+#date_stats table.comps th:nth-child(1) { width: auto; }
+#date_stats table.comps th:nth-child(2) { width: 50px; }
+#date_stats table.comps th:nth-child(3) { width: 130px; }
diff --git a/pyfaf/hub/menu.py b/pyfaf/hub/menu.py
index df5b72f..76263a2 100644
--- a/pyfaf/hub/menu.py
+++ b/pyfaf/hub/menu.py
@@ -232,6 +232,13 @@ menu = (
placeholder=True, url_args_pattern=[42, 42]),
StaffMenuItem("New", "pyfaf.hub.reports.views.new", on_right=True),
)),
+ MenuItem("Statistics", "today_stats", menu=(
+ MenuItem("Today", "today_stats"),
+ MenuItem("Yesterday", "yesterday_stats"),
+ MenuItem("Last week", "last_week_stats"),
+ MenuItem("Last month", "last_month_stats"),
+ MenuItem("Last year", "last_year_stats"),
+ )),
StaffMenuItem("Status", "pyfaf.hub.status.views.index", menu=(
MenuItem("Overview", "pyfaf.hub.status.views.index"),
MenuItem("Builds and Packages", "pyfaf.hub.status.views.builds"),
diff --git a/pyfaf/hub/settings.py b/pyfaf/hub/settings.py
index 38e75fa..a7684d7 100644
--- a/pyfaf/hub/settings.py
+++ b/pyfaf/hub/settings.py
@@ -165,6 +165,7 @@ INSTALLED_APPS = (
'pyfaf.hub.reports',
'pyfaf.hub.problems',
'pyfaf.hub.services',
+ 'pyfaf.hub.stats',
)
AUTHENTICATION_BACKENDS = (
diff --git a/pyfaf/hub/stats/Makefile.am b/pyfaf/hub/stats/Makefile.am
new file mode 100644
index 0000000..640dcc2
--- /dev/null
+++ b/pyfaf/hub/stats/Makefile.am
@@ -0,0 +1,2 @@
+dumpdirs_PYTHON = __init__.py urls.py views.py
+dumpdirsdir = $(pythondir)/pyfaf/hub/stats
diff --git a/pyfaf/hub/stats/__init__.py b/pyfaf/hub/stats/__init__.py
new file mode 100644
index 0000000..ea30561
--- /dev/null
+++ b/pyfaf/hub/stats/__init__.py
@@ -0,0 +1 @@
+#empty
diff --git a/pyfaf/hub/stats/urls.py b/pyfaf/hub/stats/urls.py
new file mode 100644
index 0000000..93dbc7f
--- /dev/null
+++ b/pyfaf/hub/stats/urls.py
@@ -0,0 +1,42 @@
+import datetime
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns(
+ 'pyfaf.hub.stats.views',
+
+ url(r'^$', 'by_daterange'),
+
+ url(r'^today/$', 'by_daterange',
+ {'since': datetime.date.today(),
+ 'to': datetime.date.today() + datetime.timedelta(days=1)},
+ name='today_stats'),
+
+ url(r'^yesterday/$', 'by_daterange',
+ {'since': datetime.date.today() - datetime.timedelta(days=1),
+ 'to': datetime.date.today()},
+ name='yesterday_stats'),
+
+ url(r'^last_week/$', 'by_daterange',
+ {'since': datetime.date.today() - datetime.timedelta(days=7),
+ 'to': datetime.date.today()},
+ name='last_week_stats'),
+
+ url(r'^last_month/$', 'by_daterange',
+ {'since': datetime.date.today() - datetime.timedelta(days=30),
+ 'to': datetime.date.today()},
+ name='last_month_stats'),
+
+ url(r'^last_year/$', 'by_daterange',
+ {'since': datetime.date.today() - datetime.timedelta(days=365),
+ 'to': datetime.date.today()},
+ name='last_year_stats'),
+
+ url(r'^date/(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/$', 'by_date',
+ name='day_stats'),
+
+ url(r'^date/(?P<year>\d+)/(?P<month>\d+)/$', 'by_date',
+ name='month_stats'),
+
+ url(r'^date/(?P<year>\d+)/$', 'by_date',
+ name='year_stats'),
+)
diff --git a/pyfaf/hub/stats/views.py b/pyfaf/hub/stats/views.py
new file mode 100644
index 0000000..3d32710
--- /dev/null
+++ b/pyfaf/hub/stats/views.py
@@ -0,0 +1,112 @@
+import datetime
+
+import pyfaf
+from pyfaf import queries
+
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+
+
+def by_daterange(request, since, to,
+ template_name='stats/by_date.html',
+ extra_context={}):
+ '''
+ Render date-based report statistics including reports `since` date
+ until `to` date.
+
+ View accepts `template_name` to be used and `extra_context` to pass
+ to it.
+ '''
+ db = pyfaf.storage.getDatabase()
+ since = min(since, to)
+ to = max(since, to)
+
+ history = 'daily'
+ day_count = (to - since).days
+ if day_count > 30:
+ history = 'weekly'
+ if day_count > 360:
+ history = 'monthly'
+
+ def date_filter(query):
+ return query.filter(hist_field >= since).filter(hist_field < to)
+
+ hist_table, hist_field = queries.get_history_target(history)
+ total_query = queries.query_history_sum(db, history=history)
+ total = date_filter(total_query).one()[0]
+
+ release_data = []
+
+ for release in queries.query_releases(db):
+ release_sum = queries.query_history_sum(
+ db, release.opsys.name, release.version, history=history)
+
+ release_sum = date_filter(release_sum).one()[0]
+ if not release_sum:
+ continue
+
+ percentage = int(release_sum * 100.0 / total)
+
+ comps = queries.query_report_count_per_component(
+ db, release.opsys.name, release.version, history=history)
+
+ comp_data = []
+ for comp, count in date_filter(comps).all():
+ comp_percentage = int(count * 100.0 / release_sum)
+ comp_data.append((comp, count, comp_percentage))
+
+ release_data.append({
+ 'release': release,
+ 'sum': release_sum,
+ 'comps': comp_data,
+ 'percentage': percentage,
+ })
+
+ data = {
+ 'since': since,
+ 'to': to,
+ 'total': total,
+ 'releases': sorted(release_data, key=lambda x: x['sum'], reverse=True),
+ }
+ data.update(extra_context)
+
+ return render_to_response(template_name,
+ data,
+ context_instance=RequestContext(request))
+
+
+def by_date(request, year, month=None, day=None,
+ template_name='stats/by_date.html',
+ extra_context={}):
+ '''
+ Render date-based report statistics including reports for passed
+ `year`, optionaly narrowed to specific `month` and `day`.
+
+ View accepts `template_name` to be used and `extra_context` to pass
+ to it.
+ '''
+
+ year = int(year)
+ if month:
+ month = int(month)
+ if day:
+ day = int(day)
+
+ since = datetime.date(year, 1, 1)
+ add = 365
+
+ if month and month in range(1, 12):
+ since = since.replace(month=month)
+ add = 30
+
+ if day and day in range(1, 31):
+ try:
+ since = since.replace(day=day)
+ add = 1
+ except ValueError:
+ pass
+
+ to = since + datetime.timedelta(days=add)
+ return by_daterange(request, since=since, to=to,
+ template_name=template_name,
+ extra_context=extra_context)
diff --git a/pyfaf/hub/templates/Makefile.am b/pyfaf/hub/templates/Makefile.am
index 229962d..3e6c1b3 100644
--- a/pyfaf/hub/templates/Makefile.am
+++ b/pyfaf/hub/templates/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = openid problems reports summary status dumpdirs
+SUBDIRS = openid problems reports summary status dumpdirs stats
template_DATA = base.html report_graph.html filter_form.html paginator.html \
404.html external_links.html metric_table.html
diff --git a/pyfaf/hub/templates/stats/Makefile.am b/pyfaf/hub/templates/stats/Makefile.am
new file mode 100644
index 0000000..d94f9ce
--- /dev/null
+++ b/pyfaf/hub/templates/stats/Makefile.am
@@ -0,0 +1,4 @@
+stats_DATA = by_date.html
+statsdir = $(pythondir)/pyfaf/hub/templates/stats
+
+EXTRA_DIST = $(stats_DATA)
diff --git a/pyfaf/hub/templates/stats/by_date.html b/pyfaf/hub/templates/stats/by_date.html
new file mode 100644
index 0000000..c5f052b
--- /dev/null
+++ b/pyfaf/hub/templates/stats/by_date.html
@@ -0,0 +1,71 @@
+{% extends "base.html" %}
+
+{% block title %}Statistics{% endblock %}
+
+{% block js %}
+ <script type="text/javascript" src="/js/bootstrap/bootstrap.js"></script>
+{% endblock %}
+
+{% block content %}
+<div class='row' id='date_stats'>
+ <div class='span3'>
+ <ul class='nav nav-tabs nav-stacked'>
+ {% for release in releases %}
+ <li>
+ <a href="#{{ release.release|slugify }}">
+ {{ release.release }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+
+ <div class='span9'>
+ <h3>Summary</h3>
+ <p>
+ <dl class='dl-horizontal'>
+ <dt>Since date:</dt>
+ <dd> {{ since|date:"Y-m-d" }} </dd>
+ <dt>To date:</dt>
+ <dd> {{ to|date:"Y-m-d" }} </dd>
+ <dt>Reports:</dt>
+ <dd> {{ total|default_if_none:"No reports" }} </dd>
+ </dl>
+ </p>
+
+ {% for release in releases %}
+ <hr />
+ <div class='row' id='{{ release.release|slugify }}'>
+ <div class='span4'>
+ <h3>{{ release.release }}</h3>
+ <dl class='dl-horizontal'>
+ <dt>Reports:</dt>
+ <dd>{{ release.sum }} ({{ release.percentage }}%)</dd>
+ <dt>Components:</dt>
+ <dd>{{ release.comps|length }}</dd>
+ </dl>
+ </div>
+ <div class='span5'>
+ <table class='comps table table-striped table-bordered'>
+ <tr>
+ <th>Component</th>
+ <th>Count</th>
+ <th>Share</th>
+ </tr>
+ {% for comp, count, percentage in release.comps %}
+ <tr>
+ <td>{{ comp }}</td>
+ <td>{{ count }}</td>
+ <td>
+ <div class="progress progress-info progress-striped">
+ <div class="bar" style="width: {{ percentage }}%"></div>
+ </div>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ </div>
+ {% endfor %}
+ </div>
+</div>
+{% endblock %}
diff --git a/pyfaf/hub/urls.py b/pyfaf/hub/urls.py
index 2503aa3..e26ad99 100644
--- a/pyfaf/hub/urls.py
+++ b/pyfaf/hub/urls.py
@@ -16,6 +16,7 @@ urlpatterns = patterns('',
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^summary/', include('pyfaf.hub.summary.urls')),
+ url(r'^stats/', include('pyfaf.hub.stats.urls')),
url(r'^$', 'pyfaf.hub.summary.views.index'),
url(r'^problems/', include('pyfaf.hub.problems.urls')),
url(r'^query/', include('pyfaf.hub.query.urls')),
--
1.8.1.4
11 years, 1 month
[FAF PATCH] add pyfaf.queries, move stuff from faf-stats-components
by Richard Marko
also adding missing executable flag to faf-stats-components
related to #141.
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
bin/faf-stats-components | 106 +++-----------------------------------------
faf.spec.in | 1 +
pyfaf/Makefile.am | 1 +
pyfaf/__init__.py | 1 +
pyfaf/queries.py | 113 +++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 123 insertions(+), 99 deletions(-)
mode change 100644 => 100755 bin/faf-stats-components
create mode 100644 pyfaf/queries.py
diff --git a/bin/faf-stats-components b/bin/faf-stats-components
old mode 100644
new mode 100755
index 7c81099..47bd70d
--- a/bin/faf-stats-components
+++ b/bin/faf-stats-components
@@ -2,96 +2,9 @@
import datetime
import pyfaf
-from pyfaf.storage.opsys import (OpSys,
- OpSysRelease,
- OpSysComponent)
-
-from pyfaf.storage.report import (Report,
- ReportHistoryDaily, ReportHistoryWeekly,
- ReportHistoryMonthly)
-
-from sqlalchemy import func, desc
-
from django.core.urlresolvers import reverse
from django.contrib.sites.models import Site
-
-def get_history_target(target='daily'):
- '''
- Return tuple of `ReportHistory(Daily|Weekly|Monthly)` and
- proper date field `ReportHistory(Daily.day|Weekly.week|Monthly.month)`
- according to `target` parameter which should be one of
- `daily|weekly|monthly` or shortened version `d|w|m`.
- '''
- if target == 'd' or target == 'daily':
- return (ReportHistoryDaily, ReportHistoryDaily.day)
-
- if target == 'w' or target == 'weekly':
- return (ReportHistoryWeekly, ReportHistoryWeekly.week)
-
- return (ReportHistoryMonthly, ReportHistoryMonthly.month)
-
-def query_releases(db, opsys_name, opsys_version=None):
- '''
- Return query of `OpSysRelease` records for passed `opsys_name`
- and optionaly filtered by `opsys_version`.
- '''
- opsysquery = (db.session.query(OpSysRelease)
- .join(OpSys)
- .filter(OpSys.name == opsys_name))
-
- if opsys_version:
- opsysquery = opsysquery.filter(OpSysRelease.version == opsys_version)
-
- return opsysquery
-
-def query_release_ids(db, opsys_name, opsys_version=None):
- '''
- Return list of `OpSysRelease` ids for passed `opsys_name` and optionaly
- filtered by `opsys_version`.
- '''
- return [opsysrelease.id for opsysrelease in
- query_releases(db, opsys_name, opsys_version).all()]
-
-def query_history_sum(db, opsys_name, opsys_version, history='daily'):
- '''
- Return query summing ReportHistory(Daily|Weekly|Monthly)
- records for `opsys_name` and `opsys_version`.
- '''
-
- opsysrelease_ids = query_release_ids(db, opsys_name, opsys_version)
- hist_table, hist_field = get_history_target(history)
-
- hist_sum = (
- db.session.query(func.sum(hist_table.count).label('cnt'))
- .filter(hist_table.opsysrelease_id.in_(opsysrelease_ids)))
-
- return hist_sum
-
-def query_reports_per_component(db, opsys_name, opsys_version,
- history='daily'):
- '''
- Return query for `OpSysComponent` and number of reports this
- component received.
-
- It's possible to filter the results by `opsys_name` and
- `opsys_version`.
- '''
-
- opsysrelease_ids = query_release_ids(db, opsys_name, opsys_version)
- hist_table, hist_field = get_history_target(history)
-
- comps = (
- db.session.query(OpSysComponent,
- func.sum(hist_table.count).label('cnt'))
- .join(Report)
- .join(hist_table)
- .filter(hist_table.opsysrelease_id.in_(opsysrelease_ids))
- .group_by(OpSysComponent)
- .order_by(desc('cnt')))
-
- return comps
-
if __name__ == "__main__":
parser = pyfaf.argparse.ArgumentParser(description='Component statistics.')
parser.add_argument('--opsys', help='OpSys name', default='Fedora')
@@ -110,12 +23,13 @@ if __name__ == "__main__":
site = Site.objects.get_current()
server_url = 'http://{0}'.format(site.domain)
-
history = 'daily'
- hist_table, hist_field = get_history_target(history)
- total = query_history_sum(db, args.opsys, args.version)
+ hist_table, hist_field = pyfaf.queries.get_history_target(history)
+ total = pyfaf.queries.query_history_sum(db, args.opsys, args.version)
+
+ comps = pyfaf.queries.query_report_count_per_component(
+ db, args.opsys, args.version, history)
- comps = query_reports_per_component(db, args.opsys, args.version, history)
if args.last:
now = datetime.datetime.now()
since = now - datetime.timedelta(days=int(args.last))
@@ -130,14 +44,8 @@ if __name__ == "__main__":
if num >= limit:
break
- reports = (
- db.session.query(Report,
- func.sum(hist_table.count).label('cnt'))
- .join(hist_table)
- .join(OpSysComponent)
- .filter(OpSysComponent.id == comp.id)
- .group_by(Report)
- .order_by(desc('cnt')))
+ reports = pyfaf.queries.query_report_stats_per_component(
+ db, comp, history)
if args.last:
reports = reports.filter(hist_field >= since)
diff --git a/faf.spec.in b/faf.spec.in
index a61b227..6effe3e 100644
--- a/faf.spec.in
+++ b/faf.spec.in
@@ -275,6 +275,7 @@ fi
%{python_sitelib}/pyfaf/config.py*
%{python_sitelib}/pyfaf/cluster.py*
%{python_sitelib}/pyfaf/__init__.py*
+%{python_sitelib}/pyfaf/queries.py*
%{python_sitelib}/pyfaf/kb.py*
%{python_sitelib}/pyfaf/libsolv.py*
%{python_sitelib}/pyfaf/obs.py*
diff --git a/pyfaf/Makefile.am b/pyfaf/Makefile.am
index f72e30c..533ccd4 100644
--- a/pyfaf/Makefile.am
+++ b/pyfaf/Makefile.am
@@ -6,6 +6,7 @@ pyfaf_PYTHON = \
bugzilla.py \
cluster.py \
common.py \
+ queries.py \
kb.py \
libsolv.py \
obs.py \
diff --git a/pyfaf/__init__.py b/pyfaf/__init__.py
index 9e995cc..600b50a 100644
--- a/pyfaf/__init__.py
+++ b/pyfaf/__init__.py
@@ -27,4 +27,5 @@ from . import retrace
from . import obs
from . import cluster
from . import kb
+from . import queries
import sys
diff --git a/pyfaf/queries.py b/pyfaf/queries.py
new file mode 100644
index 0000000..5abac79
--- /dev/null
+++ b/pyfaf/queries.py
@@ -0,0 +1,113 @@
+from pyfaf.storage.opsys import (OpSys,
+ OpSysRelease,
+ OpSysReleaseComponent,
+ OpSysComponent)
+
+from pyfaf.storage.report import (Report,
+ ReportHistoryDaily, ReportHistoryWeekly,
+ ReportHistoryMonthly)
+
+from sqlalchemy import func, desc
+
+
+def get_history_target(target='daily'):
+ '''
+ Return tuple of `ReportHistory(Daily|Weekly|Monthly)` and
+ proper date field `ReportHistory(Daily.day|Weekly.week|Monthly.month)`
+ according to `target` parameter which should be one of
+ `daily|weekly|monthly` or shortened version `d|w|m`.
+ '''
+ if target == 'd' or target == 'daily':
+ return (ReportHistoryDaily, ReportHistoryDaily.day)
+
+ if target == 'w' or target == 'weekly':
+ return (ReportHistoryWeekly, ReportHistoryWeekly.week)
+
+ return (ReportHistoryMonthly, ReportHistoryMonthly.month)
+
+
+def query_releases(db, opsys_name=None, opsys_version=None):
+ '''
+ Return query of `OpSysRelease` records optionaly filtered
+ by `opsys_name` and `opsys_version`.
+ '''
+ opsysquery = (
+ db.session.query(OpSysRelease)
+ .join(OpSys))
+
+ if opsys_name:
+ opsysquery = opsysquery.filter(OpSys.name == opsys_name)
+
+ if opsys_version:
+ opsysquery = opsysquery.filter(OpSysRelease.version == opsys_version)
+
+ return opsysquery
+
+
+def query_release_ids(db, opsys_name=None, opsys_version=None):
+ '''
+ Return list of `OpSysRelease` ids optionaly filtered
+ by `opsys_name` and `opsys_version`.
+ '''
+ return [opsysrelease.id for opsysrelease in
+ query_releases(db, opsys_name, opsys_version).all()]
+
+
+def query_history_sum(db, opsys_name=None, opsys_version=None,
+ history='daily'):
+ '''
+ Return query summing ReportHistory(Daily|Weekly|Monthly)
+ records optinaly filtered by `opsys_name` and `opsys_version`.
+ '''
+
+ opsysrelease_ids = query_release_ids(db, opsys_name, opsys_version)
+ hist_table, hist_field = get_history_target(history)
+ hist_sum = db.session.query(func.sum(hist_table.count).label('cnt'))
+ if opsysrelease_ids:
+ hist_sum = hist_sum.filter(
+ hist_table.opsysrelease_id.in_(opsysrelease_ids))
+
+ return hist_sum
+
+
+def query_report_count_per_component(db, opsys_name=None, opsys_version=None,
+ history='daily'):
+ '''
+ Return query for `OpSysComponent` and number of reports this
+ component received.
+
+ It's possible to filter the results by `opsys_name` and
+ `opsys_version`.
+ '''
+
+ opsysrelease_ids = query_release_ids(db, opsys_name, opsys_version)
+ hist_table, hist_field = get_history_target(history)
+
+ comps = (
+ db.session.query(OpSysComponent,
+ func.sum(hist_table.count).label('cnt'))
+ .join(Report)
+ .join(hist_table)
+ .group_by(OpSysComponent)
+ .order_by(desc('cnt')))
+
+ if opsysrelease_ids:
+ comps = comps.filter(hist_table.opsysrelease_id.in_(opsysrelease_ids))
+
+ return comps
+
+
+def query_report_stats_per_component(db, component, history='daily'):
+ '''
+ Return query with reports for `component` along with
+ summed counts from `history` table (one of daily/weekly/monthly).
+ '''
+ hist_table, hist_field = get_history_target(history)
+
+ return (db.session.query(Report,
+ func.sum(hist_table.count).label('cnt'))
+ .join(hist_table)
+ .join(OpSysComponent)
+ .filter(OpSysComponent.id == component.id)
+ .group_by(Report)
+ .order_by(desc('cnt')))
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH] rhbz: get id of duplicate from correct field
by Jakub Filak
This problem was found in dump directories uploaded by Emergency
analysis
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/plugins/rhbz.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 8b2d18d..552e92f 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -496,7 +496,7 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
if (strcmp(bz->bi_status, "CLOSED") == 0 && !bz->bi_resolution)
error_msg_and_die(_("Bug %i is CLOSED, but it has no RESOLUTION"), bz->bi_id);
- ret = (int*)rhbz_bug_read_item("dup_id", bug_item,
+ ret = (int*)rhbz_bug_read_item("dupe_of", bug_item,
RHBZ_READ_INT);
if (strcmp(bz->bi_status, "CLOSED") == 0
&& strcmp(bz->bi_resolution, "DUPLICATE") == 0
--
1.8.1.4
11 years, 1 month
[LIBREPORT PATCH] change the "exited with" message with something less technical closes #143
by Jiri Moskovcak
Signed-off-by: Jiri Moskovcak <jmoskovc(a)redhat.com>
---
src/gui-wizard-gtk/wizard.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 7c00d3c..1db97b2 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1741,13 +1741,19 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
/* If program failed, or if it finished successfully without saying anything... */
if (retval != 0 || evd->event_log_state == LOGSTATE_FIRSTLINE)
{
- if (retval != 0) /* If program failed, emit error line */
- evd->event_log_state = LOGSTATE_ERRLINE;
char *msg;
if (WIFSIGNALED(run_state->process_status))
msg = xasprintf("(killed by signal %u)\n", WTERMSIG(run_state->process_status));
+ else if (retval == 0)
+ {
+ msg = xasprintf(_("Completed successfuly\n"));
+ }
else
+ {
+ /* If program failed, emit error line */
+ evd->event_log_state = LOGSTATE_ERRLINE;
msg = xasprintf("(exited with %u)\n", retval);
+ }
append_to_textview(evd->tv_log, msg);
save_to_event_log(evd, msg);
free(msg);
--
1.8.1.4
11 years, 1 month
[ABRT PATCH] Integration with satyr
by Martin Milata
ABRT can now be built against satyr instead of btparser using
--with-satyr parameter to the configure script. RPMs are built against
btparser.
For the most part, the code is changed to use satyr and satyr-compat.h
is provided to wrap btparser in interface mimicking that of satyr. When
the migration to satyr is completed this file can be removed.
Note that the format of core_backtrace problem directory item is
incompatible between these two libraries.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
abrt.spec.in | 4 +
configure.ac | 14 +-
src/daemon/Makefile.am | 4 +-
src/daemon/abrt-handle-event.c | 65 ++++-----
src/include/Makefile.am | 3 +-
src/include/satyr-compat.h | 165 ++++++++++++++++++++++
src/plugins/Makefile.am | 12 +-
src/plugins/abrt-action-analyze-backtrace.c | 20 ++-
src/plugins/abrt-action-generate-core-backtrace.c | 23 +++
src/plugins/ccpp_event.conf | 2 +
10 files changed, 251 insertions(+), 61 deletions(-)
create mode 100644 src/include/satyr-compat.h
diff --git a/abrt.spec.in b/abrt.spec.in
index 180abce..d584db1 100644
--- a/abrt.spec.in
+++ b/abrt.spec.in
@@ -47,6 +47,8 @@ BuildRequires: doxygen
BuildRequires: xmlto
BuildRequires: libreport-devel >= 2.1.0
BuildRequires: btparser-devel
+##satyr migration:
+#BuildRequires: satyr-devel
Requires: libreport >= 2.1.0
%if %{with systemd}
@@ -100,6 +102,8 @@ GTK+ wizard for convenient bug reporting.
Summary: %{name}'s C/C++ addon
Group: System Environment/Libraries
Requires: cpio, btparser
+##satyr migration:
+#Requires: cpio, satyr
Requires: gdb >= 7.0-3
Requires: elfutils
Requires: %{name} = %{version}-%{release}
diff --git a/configure.ac b/configure.ac
index 9c6b9c7..9f1cded 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,11 @@ PYTHON_LIBS=`python-config --libs 2> /dev/null`
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
+AC_ARG_WITH([satyr],
+ AS_HELP_STRING([--with-satyr],
+ [use satyr instead of btparser (default is no)]),
+ [], [with_satyr=no])
+
PKG_CHECK_MODULES([GTK], [gtk+-3.0])
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.21])
PKG_CHECK_MODULES([DBUS], [dbus-1])
@@ -82,13 +87,20 @@ PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
PKG_CHECK_MODULES([RPM], [rpm])
PKG_CHECK_MODULES([LIBNOTIFY], [libnotify])
PKG_CHECK_MODULES([NSS], [nss])
-PKG_CHECK_MODULES([BTPARSER], [btparser])
PKG_CHECK_MODULES([LIBREPORT], [libreport])
PKG_CHECK_MODULES([LIBREPORT_GTK], [libreport-gtk])
PKG_CHECK_MODULES([LIBREPORT_WEB], [libreport-web])
PKG_CHECK_MODULES([POLKIT], [polkit-gobject-1])
PKG_CHECK_MODULES([GIO], [gio-2.0])
+[if test "$with_satyr" = "yes"]
+[then]
+ PKG_CHECK_MODULES([SATYR], [satyr])
+ AC_DEFINE([USE_SATYR], [1], [Use satyr instead of btparser])
+[else]
+ PKG_CHECK_MODULES([SATYR], [btparser])
+[fi]
+
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index c3892d4..9578569 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -50,12 +50,12 @@ abrt_handle_event_CPPFLAGS = \
-I$(srcdir)/../lib \
$(GLIB_CFLAGS) \
$(LIBREPORT_CFLAGS) \
- $(BTPARSER_CFLAGS) \
+ $(SATYR_CFLAGS) \
-D_GNU_SOURCE
abrt_handle_event_LDADD = \
../lib/libabrt.la \
$(LIBREPORT_LIBS) \
- $(BTPARSER_LIBS)
+ $(SATYR_LIBS)
abrt_action_save_package_data_SOURCES = \
rpm.h rpm.c \
diff --git a/src/daemon/abrt-handle-event.c b/src/daemon/abrt-handle-event.c
index 29fbffd..e11d192 100644
--- a/src/daemon/abrt-handle-event.c
+++ b/src/daemon/abrt-handle-event.c
@@ -19,55 +19,39 @@
#include "libabrt.h"
#include <libreport/run_event.h>
-
-#include <btparser/frame.h>
-#include <btparser/thread.h>
-#include <btparser/normalize.h>
-#include <btparser/metrics.h>
-#include <btparser/core-backtrace.h>
-
-#define BACKTRACE_DUP_THRESHOLD 2
+#include "satyr-compat.h"
static char *uid = NULL;
static char *uuid = NULL;
-static struct btp_thread *corebt = NULL;
+static struct sr_core_stacktrace *corebt = NULL;
static char *crash_dump_dup_name = NULL;
-
-#if 0
-/* Useful only for debugging. */
-static void print_thread(const struct btp_thread *thread)
-{
- struct btp_frame *frame;
-
- for (frame = thread->frames; frame != NULL; frame = frame->next)
- {
- struct frame_aux *aux = frame->user_data;
- printf("%s %s+0x%jx %s %s\n", frame->function_name, aux->build_id,
- (uintmax_t)frame->address, aux->modname, aux->fingerprint);
- }
-}
-#endif
-
-
-static int core_backtrace_is_duplicate(struct btp_thread *bt1, const char *bt2_text)
+static int core_backtrace_is_duplicate(struct sr_core_stacktrace *bt1,
+ const char *bt2_text)
{
int result;
- struct btp_thread *bt2 = btp_load_core_backtrace(bt2_text);
+ char *error_message;
+ struct sr_core_stacktrace *bt2 = sr_core_stacktrace_from_json_text(bt2_text, &error_message);
if (bt2 == NULL)
{
- VERB1 log("Failed to parse backtrace, considering it not duplicate");
+ VERB1 log("Failed to parse backtrace, considering it not duplicate: %s", error_message);
+ free(error_message);
return 0;
}
- else if (btp_thread_get_frame_count(bt2) <= 0)
+
+ struct sr_core_thread *thread1 = sr_core_stacktrace_find_crash_thread(bt1);
+ struct sr_core_thread *thread2 = sr_core_stacktrace_find_crash_thread(bt2);
+
+ if (sr_core_thread_get_frame_count(thread2) <= 0)
{
VERB1 log("Core backtrace has zero frames, considering it not duplicate");
result = 0;
goto end;
}
- int distance = btp_thread_levenshtein_distance_custom(bt1, bt2, true,
- btp_core_backtrace_frame_cmp);
+ int distance = sr_distance_core(SR_DISTANCE_DAMERAU_LEVENSHTEIN,
+ thread1, thread2);
+
if (distance == -1)
{
result = 0;
@@ -79,7 +63,7 @@ static int core_backtrace_is_duplicate(struct btp_thread *bt1, const char *bt2_t
}
end:
- btp_free_core_backtrace(bt2);
+ sr_core_stacktrace_free(bt2);
return result;
}
@@ -107,7 +91,7 @@ static int dup_uuid_compare(const struct dump_dir *dd)
* XXX: this relies on the fact that backtrace is created in the same event
* as UUID
*/
- if (corebt && btp_thread_get_frame_count(corebt) > 0)
+ if (corebt)
return 0;
dd_uuid = dd_load_text_ext(dd, FILENAME_UUID, DD_FAIL_QUIETLY_ENOENT);
@@ -140,13 +124,14 @@ static void dup_corebt_init(const struct dump_dir *dd)
if (!corebt_text)
return; /* no backtrace */
- corebt = btp_load_core_backtrace(corebt_text);
+ char *error_message;
+ corebt = sr_core_stacktrace_from_json_text(corebt_text,
+ &error_message);
- if (corebt && btp_thread_get_frame_count(corebt) <= 0)
+ if (!corebt)
{
- VERB1 log("Core backtrace of the crash has zero frames");
- btp_free_core_backtrace(corebt);
- corebt = NULL;
+ VERB1 log("Failed to load core stacktrace: %s", error_message);
+ free(error_message);
}
free(corebt_text);
@@ -175,7 +160,7 @@ static int dup_corebt_compare(const struct dump_dir *dd)
static void dup_corebt_fini(void)
{
- btp_free_core_backtrace(corebt);
+ sr_core_stacktrace_free(corebt);
corebt = NULL;
}
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index a4f24b9..ed63afd 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -4,4 +4,5 @@ libabrt_includedir = \
libabrt_include_HEADERS = \
libabrt.h \
abrt-dbus.h \
- hooklib.h
+ hooklib.h \
+ satyr-compat.h
diff --git a/src/include/satyr-compat.h b/src/include/satyr-compat.h
new file mode 100644
index 0000000..0752785
--- /dev/null
+++ b/src/include/satyr-compat.h
@@ -0,0 +1,165 @@
+/*
+ Copyright (C) 2013 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+/*
+ * Compatibility header for transition from btparser to satyr. When the
+ * possibility to compile abrt against btparser is removed, delete this file
+ * and include the relevant satyr headers instead.
+ */
+#ifndef SATYR_COMPAT_H_
+#define SATYR_COMPAT_H_
+
+#include "config.h"
+
+#ifdef USE_SATYR
+/* Satyr is used, nothing to do, just include everything we may need. */
+
+#include <satyr/core_frame.h>
+#include <satyr/core_stacktrace.h>
+#include <satyr/core_thread.h>
+#include <satyr/distance.h>
+#include <satyr/gdb_frame.h>
+#include <satyr/gdb_stacktrace.h>
+#include <satyr/location.h>
+#include <satyr/metrics.h>
+#include <satyr/normalize.h>
+#include <satyr/sha1.h>
+#include <satyr/utils.h>
+
+#define BACKTRACE_DUP_THRESHOLD 0.3
+
+#else /* USE_SATYR */
+/* We use btparser. Wrap the calls to btparser in a satyr-compatible interface. */
+
+#include <btparser/frame.h>
+#include <btparser/thread.h>
+#include <btparser/normalize.h>
+#include <btparser/metrics.h>
+#include <btparser/core-backtrace.h>
+#include <btparser/backtrace.h>
+#include <btparser/frame.h>
+#include <btparser/location.h>
+#include "libabrt.h" /* xstrdup */
+
+#define BACKTRACE_DUP_THRESHOLD 2
+
+/* abrt-handle-event.c */
+#define sr_core_stacktrace btp_thread
+#define sr_core_thread btp_thread
+#define sr_thread_get_frame_count btp_thread_get_frame_count
+
+enum sr_distance_type
+{
+ SR_DISTANCE_DAMERAU_LEVENSHTEIN
+};
+
+/* The functions should be static but that generates unused function warnings.
+ * We don't include this header in two compilation units that are then linked
+ * together anyway, so this should work. And this file should be gone soon ...
+ */
+struct sr_core_stacktrace *
+sr_core_stacktrace_from_json_text(const char *text,
+ char **error_message)
+{
+ struct btp_thread *thread = btp_load_core_backtrace(text);
+ if (!thread)
+ {
+ *error_message = xstrdup(
+ "Failed to parse backtrace, considering it not duplicate");
+ return NULL;
+ }
+ return btp_load_core_backtrace(text);
+}
+
+struct sr_core_thread *
+sr_core_stacktrace_find_crash_thread(struct sr_core_stacktrace *stacktrace)
+{
+ return stacktrace;
+}
+
+int
+sr_core_thread_get_frame_count(struct sr_core_thread *thread)
+{
+ return btp_thread_get_frame_count(thread);
+}
+
+float
+sr_distance_core(enum sr_distance_type distance_type,
+ struct sr_core_thread *thread1,
+ struct sr_core_thread *thread2)
+{
+ return btp_thread_levenshtein_distance_custom(thread1, thread2, true,
+ btp_core_backtrace_frame_cmp);
+}
+
+void
+sr_core_stacktrace_free(struct sr_core_stacktrace *stacktrace)
+{
+ btp_free_core_backtrace(stacktrace);
+}
+
+/* abrt-action-analyze-backtrace.c */
+#define sr_location btp_location
+#define sr_gdb_stacktrace btp_backtrace
+#define sr_gdb_frame btp_frame
+
+void
+sr_location_init(struct sr_location *location)
+{
+ btp_location_init(location);
+}
+
+struct sr_gdb_stacktrace *
+sr_gdb_stacktrace_parse(const char **input,
+ struct sr_location *location)
+{
+ return btp_backtrace_parse(input, location);
+}
+
+char *
+sr_gdb_stacktrace_get_duplication_hash(struct sr_gdb_stacktrace *stacktrace)
+{
+ return btp_backtrace_get_duplication_hash(stacktrace);
+}
+
+float
+sr_gdb_stacktrace_quality_complex(struct sr_gdb_stacktrace *stacktrace)
+{
+ return btp_backtrace_quality_complex(stacktrace);
+}
+
+struct sr_gdb_frame *
+sr_gdb_stacktrace_get_crash_frame(struct sr_gdb_stacktrace *stacktrace)
+{
+ return btp_backtrace_get_crash_frame(stacktrace);
+}
+
+void
+sr_gdb_frame_free(struct sr_gdb_frame *frame)
+{
+ btp_frame_free(frame);
+}
+
+void
+sr_gdb_stacktrace_free(struct sr_gdb_stacktrace *stacktrace)
+{
+ btp_backtrace_free(stacktrace);
+}
+
+#endif /* USE_SATYR */
+
+#endif /* SATYR_COMPAT_H_ */
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 33f201d..997d2ae 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -215,11 +215,11 @@ abrt_action_generate_core_backtrace_CPPFLAGS = \
-DLOCALSTATEDIR='"$(localstatedir)"' \
$(GLIB_CFLAGS) \
$(LIBREPORT_CFLAGS) \
- $(BTPARSER_CFLAGS) \
+ $(SATYR_CFLAGS) \
-D_GNU_SOURCE
abrt_action_generate_core_backtrace_LDADD = \
$(LIBREPORT_LIBS) \
- $(BTPARSER_LIBS) \
+ $(SATYR_LIBS) \
../lib/libabrt.la
abrt_action_analyze_backtrace_SOURCES = \
@@ -229,11 +229,11 @@ abrt_action_analyze_backtrace_CPPFLAGS = \
-I$(srcdir)/../lib \
$(GLIB_CFLAGS) \
$(LIBREPORT_CFLAGS) \
- $(BTPARSER_CFLAGS) \
+ $(SATYR_CFLAGS) \
-D_GNU_SOURCE
abrt_action_analyze_backtrace_LDADD = \
$(LIBREPORT_LIBS) \
- $(BTPARSER_LIBS)
+ $(SATYR_LIBS)
abrt_action_install_debuginfo_to_abrt_cache_SOURCES = \
abrt-action-install-debuginfo-to-abrt-cache.c
@@ -261,7 +261,7 @@ abrt_retrace_client_SOURCES = \
$(LIBREPORT_CFLAGS)
abrt_retrace_client_LDADD = \
$(LIBREPORT_LIBS) \
- $(BTPARSER_LIBS) \
+ $(SATYR_LIBS) \
$(NSS_LIBS)
abrt_dedup_client_SOURCES = \
@@ -276,7 +276,7 @@ abrt_dedup_client_SOURCES = \
$(LIBREPORT_CFLAGS)
abrt_dedup_client_LDADD = \
$(LIBREPORT_LIBS) \
- $(BTPARSER_LIBS) \
+ $(SATYR_LIBS) \
$(NSS_LIBS)
abrt_bodhi_SOURCES = \
diff --git a/src/plugins/abrt-action-analyze-backtrace.c b/src/plugins/abrt-action-analyze-backtrace.c
index 1ef1488..a980213 100644
--- a/src/plugins/abrt-action-analyze-backtrace.c
+++ b/src/plugins/abrt-action-analyze-backtrace.c
@@ -15,9 +15,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <btparser/backtrace.h>
-#include <btparser/frame.h>
-#include <btparser/location.h>
+#include "satyr-compat.h"
#include "libabrt.h"
static const char *dump_dir_name = ".";
@@ -83,10 +81,10 @@ int main(int argc, char **argv)
}
/* Compute backtrace hash */
- struct btp_location location;
- btp_location_init(&location);
+ struct sr_location location;
+ sr_location_init(&location);
const char *backtrace_str_ptr = backtrace_str;
- struct btp_backtrace *backtrace = btp_backtrace_parse(&backtrace_str_ptr, &location);
+ struct sr_gdb_stacktrace *backtrace = sr_gdb_stacktrace_parse(&backtrace_str_ptr, &location);
free(backtrace_str);
/* Store backtrace hash */
@@ -132,7 +130,7 @@ int main(int argc, char **argv)
}
/* Compute duplication hash. */
- char *str_hash_core = btp_backtrace_get_duplication_hash(backtrace);
+ char *str_hash_core = sr_gdb_stacktrace_get_duplication_hash(backtrace);
struct strbuf *str_hash = strbuf_new();
strbuf_append_str(str_hash, component);
strbuf_append_str(str_hash, str_hash_core);
@@ -146,7 +144,7 @@ int main(int argc, char **argv)
free(str_hash_core);
/* Compute the backtrace rating. */
- float quality = btp_backtrace_quality_complex(backtrace);
+ float quality = sr_gdb_stacktrace_quality_complex(backtrace);
const char *rating;
if (quality < 0.6f)
rating = "0";
@@ -161,7 +159,7 @@ int main(int argc, char **argv)
dd_save_text(dd, FILENAME_RATING, rating);
/* Get the function name from the crash frame. */
- struct btp_frame *crash_frame = btp_backtrace_get_crash_frame(backtrace);
+ struct sr_gdb_frame *crash_frame = sr_gdb_stacktrace_get_crash_frame(backtrace);
if (crash_frame)
{
if (crash_frame->function_name &&
@@ -169,9 +167,9 @@ int main(int argc, char **argv)
{
dd_save_text(dd, FILENAME_CRASH_FUNCTION, crash_frame->function_name);
}
- btp_frame_free(crash_frame);
+ sr_gdb_frame_free(crash_frame);
}
- btp_backtrace_free(backtrace);
+ sr_gdb_stacktrace_free(backtrace);
dd_close(dd);
free(component);
return 0;
diff --git a/src/plugins/abrt-action-generate-core-backtrace.c b/src/plugins/abrt-action-generate-core-backtrace.c
index ef24e1e..303afc3 100644
--- a/src/plugins/abrt-action-generate-core-backtrace.c
+++ b/src/plugins/abrt-action-generate-core-backtrace.c
@@ -17,6 +17,27 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "libabrt.h"
+
+#ifdef USE_SATYR
+/* If satyr is used, just run "satyr abrt-create-core-stacktrace" on the dump directory.
+ */
+
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ VERB1 log("Running 'satyr abrt-create-core-stacktrace .'");
+ execlp("satyr", "satyr", "abrt-create-core-stacktrace", ".", NULL);
+ perror_msg_and_die("Can't execute satyr");
+
+ return 0;
+}
+
+#else /* USE_SATYR */
+/* Btparser is used. Once the support is removed, this whole file can be
+ * deleted and ccpp_event.conf modified accordingly.
+ */
+
#include <btparser/hash_sha1.h>
#include <btparser/utils.h>
#include <btparser/core-backtrace.h>
@@ -198,3 +219,5 @@ int main(int argc, char **argv)
btp_core_backtrace_free(backtrace);
return 0;
}
+
+#endif /* USE_SATYR */
diff --git a/src/plugins/ccpp_event.conf b/src/plugins/ccpp_event.conf
index b608c2d..dfc4908 100644
--- a/src/plugins/ccpp_event.conf
+++ b/src/plugins/ccpp_event.conf
@@ -16,6 +16,8 @@ EVENT=post-create analyzer=CCpp
fi
# Try generating backtrace, if it fails we can still use
# the UUID generated by abrt-action-analyze-c
+ ##satyr migration:
+ #satyr abrt-create-core-stacktrace "$DUMP_DIR"
abrt-action-generate-core-backtrace
abrt-action-analyze-c &&
abrt-action-list-dsos -m maps -o dso_list &&
--
1.7.11.7
11 years, 1 month
[LIBREPORT PATCH] Integration with satyr
by Martin Milata
libreport can now be built against satyr instead of btparser using
--with-satyr parameter to the configure script. RPMs are built against
btparser.
Signed-off-by: Martin Milata <mmilata(a)redhat.com>
---
configure.ac | 18 ++++++++-
libreport-web.pc.in | 2 +-
libreport.spec.in | 2 +
src/lib/Makefile.am | 4 +-
src/lib/json.c | 85 ++++++++++++++++++++++++++++++-----------
src/lib/ureport.h | 6 ++-
src/plugins/reporter-bugzilla.c | 56 ++++++++++++++++++++-------
src/plugins/ureport.c | 28 ++++++++------
8 files changed, 147 insertions(+), 54 deletions(-)
diff --git a/configure.ac b/configure.ac
index 01cf6f6..67310d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,16 +122,32 @@ PYTHON_LIBS=`python-config --libs 2> /dev/null`
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS)
+AC_ARG_WITH([satyr],
+ AS_HELP_STRING([--with-satyr],
+ [use satyr instead of btparser (default is no)]),
+ [], [with_satyr=no])
+
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.21])
PKG_CHECK_MODULES([DBUS], [dbus-1])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
PKG_CHECK_MODULES([NSS], [nss])
PKG_CHECK_MODULES([CURL], [libcurl])
-PKG_CHECK_MODULES([BTPARSER], [btparser])
PKG_CHECK_MODULES([PROXY], [libproxy-1.0], [
AC_DEFINE([HAVE_PROXY], [1], [Use libproxy])
], [:])
+[if test "$with_satyr" = "yes"]
+[then]
+ PKG_CHECK_MODULES([SATYR], [satyr])
+ AC_DEFINE([USE_SATYR], [1], [Use satyr instead of btparser])
+ SATYR_PKG="satyr"
+[else]
+ PKG_CHECK_MODULES([SATYR], [btparser])
+ SATYR_PKG="btparser"
+[fi]
+AC_SUBST(SATYR_PKG)
+AM_CONDITIONAL([USE_SATYR], [test "$with_satyr" = "yes"])
+
AC_ARG_WITH(newt,
AS_HELP_STRING([--with-newt],[use newt (default is YES)]),
LIBREPORT_PARSE_WITH([newt]))
diff --git a/libreport-web.pc.in b/libreport-web.pc.in
index c9af1d2..ec4ab8e 100644
--- a/libreport-web.pc.in
+++ b/libreport-web.pc.in
@@ -6,7 +6,7 @@ includedir=@includedir@
Name: libreport
Description: Library providing network API for libreport
Version: @VERSION@
-Requires: glib-2.0 libcurl libproxy-1.0 libxml-2.0 xmlrpc xmlrpc_client json btparser libreport
+Requires: glib-2.0 libcurl libproxy-1.0 libxml-2.0 xmlrpc xmlrpc_client json @SATYR_PKG@ libreport
Libs: -L${libdir} -lreport-web
Cflags:
diff --git a/libreport.spec.in b/libreport.spec.in
index e2f4c50..22f74ea 100644
--- a/libreport.spec.in
+++ b/libreport.spec.in
@@ -27,6 +27,8 @@ BuildRequires: asciidoc
BuildRequires: xmlto
BuildRequires: newt-devel
BuildRequires: libproxy-devel
+##satyr migration:
+#BuildRequires: satyr-devel
BuildRequires: btparser-devel
BuildRequires: doxygen
Requires: libreport-filesystem
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 91d128f..5c0fd09 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -122,7 +122,7 @@ libreport_web_la_CPPFLAGS = \
$(LIBXML_CFLAGS) \
$(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) \
$(JSON_C_CFLAGS) \
- $(BTPARSER_CFLAGS) \
+ $(SATYR_CFLAGS) \
-D_GNU_SOURCE
libreport_web_la_LDFLAGS = \
-version-info 0:1:0
@@ -132,7 +132,7 @@ libreport_web_la_LIBADD = \
$(PROXY_LIBS) \
$(LIBXML_LIBS) \
$(JSON_C_LIBS) \
- $(BTPARSER_LIBS) \
+ $(SATYR_LIBS) \
$(XMLRPC_LIBS) $(XMLRPC_CLIENT_LIBS) \
libreport.la
diff --git a/src/lib/json.c b/src/lib/json.c
index 9cd5a2a..1e6d1b1 100644
--- a/src/lib/json.c
+++ b/src/lib/json.c
@@ -18,14 +18,47 @@
*/
#include <json/json.h>
-#include <btparser/thread.h>
-#include <btparser/core-backtrace.h>
#include "internal_libreport.h"
#include "ureport.h"
#include "libreport_curl.h"
+static void ureport_add_str(struct json_object *ur, const char *key,
+ const char *s)
+{
+ struct json_object *jstring = json_object_new_string(s);
+ if (!jstring)
+ die_out_of_memory();
+
+ json_object_object_add(ur, key, jstring);
+}
+
+#if USE_SATYR
+
+#include <satyr/abrt.h>
+#include <satyr/report.h>
+
+char *ureport_from_dump_dir(const char *dump_dir_path)
+{
+ char *error_message;
+ struct sr_report *report = sr_abrt_report_from_dir(dump_dir_path,
+ &error_message);
+
+ if (!report)
+ error_msg_and_die("%s", error_message);
+
+ char *json_ureport = sr_report_to_json(report);
+ sr_report_free(report);
+
+ return json_ureport;
+}
+
+#else /* USE_SATYR */
+
+#include <btparser/thread.h>
+#include <btparser/core-backtrace.h>
+
/* on success 1 returned, on error zero is returned and appropriate value
* is returned as third argument. You should never read third argument when
* function fails
@@ -64,16 +97,6 @@ static void ureport_add_int(struct json_object *ur, const char *key, int i)
json_object_object_add(ur, key, jint);
}
-static void ureport_add_str(struct json_object *ur, const char *key,
- const char *s)
-{
- struct json_object *jstring = json_object_new_string(s);
- if (!jstring)
- die_out_of_memory();
-
- json_object_object_add(ur, key, jstring);
-}
-
static void ureport_add_os(struct json_object *ur, problem_data_t *pd)
{
/* paranoia - we only need OS_RELEASE_IN_ROOTDIR,
@@ -178,7 +201,6 @@ static void ureport_add_core_backtrace(struct json_object *ur, problem_data_t *p
json_object_object_add(ur, FILENAME_CORE_BACKTRACE, jarray);
}
-
static void ureport_add_item_str(struct json_object *ur, problem_data_t *pd,
const char *key, const char *rename)
{
@@ -287,6 +309,32 @@ char *new_json_ureport(problem_data_t *pd)
return j;
}
+char *ureport_from_dump_dir(const char *dump_dir_path)
+{
+ struct dump_dir *dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY);
+ if (!dd)
+ xfunc_die();
+
+ problem_data_t *pd = create_problem_data_from_dump_dir(dd);
+
+ dd_close(dd);
+ if (!pd)
+ xfunc_die(); /* create_problem_data_from_dump_dir already emitted error msg */
+
+ char *json_ureport = new_json_ureport(pd);
+ problem_data_free(pd);
+
+ if (json_ureport == NULL)
+ {
+ error_msg(_("Not uploading an empty uReport"));
+ return NULL;
+ }
+
+ return json_ureport;
+}
+
+#endif /* USE_SATYR */
+
char *new_json_attachment(const char *bthash, const char *type, const char *data)
{
struct json_object *attachment = json_object_new_object();
@@ -303,20 +351,13 @@ char *new_json_attachment(const char *bthash, const char *type, const char *data
return result;
}
-struct post_state *post_ureport(problem_data_t *pd, struct ureport_server_config *config)
+struct post_state *post_ureport(const char *json_ureport, struct ureport_server_config *config)
{
int flags = POST_WANT_BODY | POST_WANT_ERROR_MSG;
if (config->ur_ssl_verify)
flags |= POST_WANT_SSL_VERIFY;
- char *json_ureport = new_json_ureport(pd);
- if (json_ureport == NULL)
- {
- error_msg(_("Not uploading an empty uReport"));
- return NULL;
- }
-
struct post_state *post_state = new_post_state(flags);
static const char *headers[] = {
@@ -328,8 +369,6 @@ struct post_state *post_ureport(problem_data_t *pd, struct ureport_server_config
post_string_as_form_data(post_state, config->ur_url, "application/json",
headers, json_ureport);
- free(json_ureport);
-
return post_state;
}
diff --git a/src/lib/ureport.h b/src/lib/ureport.h
index f851806..0d7b90d 100644
--- a/src/lib/ureport.h
+++ b/src/lib/ureport.h
@@ -37,12 +37,16 @@ struct ureport_server_config
struct abrt_post_state;
#define post_ureport libreport_post_ureport
-struct post_state *post_ureport(problem_data_t *pd, struct ureport_server_config *config);
+struct post_state *post_ureport(const char *json_ureport,
+ struct ureport_server_config *config);
#define ureport_attach_rhbz libreport_ureport_attach_rhbz
struct post_state *ureport_attach_rhbz(const char *bthash, int rhbz_bug_id,
struct ureport_server_config *config);
+#define ureport_from_dump_dir libreport_ureport_from_dump_dir
+char *ureport_from_dump_dir(const char *dump_dir_path);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index 4533df5..0d6c9a9 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -16,16 +16,44 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "internal_libreport.h"
+#include "client.h"
+#include "abrt_xmlrpc.h"
+#include "rhbz.h"
+
+/* btparser compatibility - once we move to satyr, the else branch of the ifdef
+ * can be removed
+ */
+#ifdef USE_SATYR
+
+#include <satyr/location.h>
+#include <satyr/gdb_stacktrace.h>
+#include <satyr/gdb_thread.h>
+#include <satyr/gdb_frame.h>
+#include <satyr/strbuf.h>
+
+#else /* USE_SATYR */
+
#include <btparser/location.h>
#include <btparser/backtrace.h>
#include <btparser/thread.h>
#include <btparser/frame.h>
#include <btparser/strbuf.h>
-#include "internal_libreport.h"
-#include "client.h"
-#include "abrt_xmlrpc.h"
-#include "rhbz.h"
+#define sr_location btp_location
+#define sr_location_init btp_location_init
+#define sr_gdb_stacktrace btp_backtrace
+#define sr_gdb_stacktrace_parse btp_backtrace_parse
+#define sr_gdb_stacktrace_get_optimized_thread btp_backtrace_get_optimized_thread
+#define sr_gdb_stacktrace_free btp_backtrace_free
+#define sr_gdb_thread btp_thread
+#define sr_gdb_thread_append_to_str btp_thread_append_to_str
+#define sr_gdb_thread_free btp_thread_free
+#define sr_strbuf btp_strbuf
+#define sr_strbuf_new btp_strbuf_new
+#define sr_strbuf_free_nobuf btp_strbuf_free_nobuf
+
+#endif /* USE_SATYR */
struct section_t {
char *name;
@@ -337,12 +365,12 @@ int append_short_backtrace(struct strbuf *result, problem_data_t *problem_data,
if (strlen(item->content) >= max_text_size)
{
- struct btp_location location;
- btp_location_init(&location);
+ struct sr_location location;
+ sr_location_init(&location);
- /* btp_backtrace_parse modifies the input parameter */
+ /* sr_gdb_stacktrace_parse modifies the input parameter */
char *content = item->content;
- struct btp_backtrace *backtrace = btp_backtrace_parse((const char **)&content, &location);
+ struct sr_gdb_stacktrace *backtrace = sr_gdb_stacktrace_parse((const char **)&content, &location);
if (!backtrace)
{
@@ -351,9 +379,9 @@ int append_short_backtrace(struct strbuf *result, problem_data_t *problem_data,
}
/* Get optimized thread stack trace for 10 top most frames */
- struct btp_thread *thread = btp_backtrace_get_optimized_thread(backtrace, 10);
+ struct sr_gdb_thread *thread = sr_gdb_stacktrace_get_optimized_thread(backtrace, 10);
- btp_backtrace_free(backtrace);
+ sr_gdb_stacktrace_free(backtrace);
if (!thread)
{
@@ -362,13 +390,13 @@ int append_short_backtrace(struct strbuf *result, problem_data_t *problem_data,
}
/* Cannot be NULL, it dies on memory error */
- struct btp_strbuf *bt = btp_strbuf_new();
+ struct sr_strbuf *bt = sr_strbuf_new();
- btp_thread_append_to_str(thread, bt, true);
+ sr_gdb_thread_append_to_str(thread, bt, true);
- btp_thread_free(thread);
+ sr_gdb_thread_free(thread);
- truncated = btp_strbuf_free_nobuf(bt);
+ truncated = sr_strbuf_free_nobuf(bt);
}
append_text(result,
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
index 67f55d4..ac016ce 100644
--- a/src/plugins/ureport.c
+++ b/src/plugins/ureport.c
@@ -276,6 +276,7 @@ int main(int argc, char **argv)
const char *dump_dir_path = ".";
const char *ureport_hash = NULL;
int rhbz_bug = -1;
+ struct dump_dir *dd = NULL;
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT__DUMP_DIR(&dump_dir_path),
@@ -311,13 +312,13 @@ int main(int argc, char **argv)
if (!ureport_hash && rhbz_bug > 0)
error_msg_and_die(_("You need to specify bthash of the uReport to attach."));
- struct dump_dir *dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY);
- if (!dd)
- xfunc_die();
-
/* -r */
if (attach_reported_to)
{
+ dd = dd_opendir(dump_dir_path, DD_OPEN_READONLY);
+ if (!dd)
+ xfunc_die();
+
report_result_t *ureport_result = find_in_reported_to(dd, "uReport");
report_result_t *bz_result = find_in_reported_to(dd, "Bugzilla");
@@ -350,16 +351,19 @@ int main(int argc, char **argv)
}
/* -b, -a nor -r were specified - upload uReport from dump_dir */
- problem_data_t *pd = create_problem_data_from_dump_dir(dd);
- dd_close(dd);
- if (!pd)
- xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */
-
+ int ret = 1; /* return 1 by default */
char *dest_url = concat_path_file(config.ur_url, REPORT_URL_SFX);
config.ur_url = dest_url;
- post_state = post_ureport(pd, &config);
- problem_data_free(pd);
- int ret = 1; /* return 1 by default */
+
+ char *json_ureport = ureport_from_dump_dir(dump_dir_path);
+ if (!json_ureport)
+ {
+ error_msg(_("Not uploading an empty uReport"));
+ goto format_err;
+ }
+
+ post_state = post_ureport(json_ureport, &config);
+ free(json_ureport);
if (!post_state)
{
--
1.7.11.7
11 years, 1 month