[FAF PATCH 1/2] increase the maximal length of opsys name and version
by Michal Toman
Signed-off-by: Michal Toman <mtoman(a)redhat.com>
---
pyfaf/storage/opsys.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pyfaf/storage/opsys.py b/pyfaf/storage/opsys.py
index bfd3d9a..ee728b3 100644
--- a/pyfaf/storage/opsys.py
+++ b/pyfaf/storage/opsys.py
@@ -46,7 +46,7 @@ class OpSys(GenericTable):
__table_args__ = ( UniqueConstraint('name'), )
id = Column(Integer, primary_key=True)
- name = Column(String(32), nullable=False)
+ name = Column(String(64), nullable=False)
def __str__(self):
return self.name
@@ -65,7 +65,7 @@ class OpSysRelease(GenericTable):
id = Column(Integer, primary_key=True)
opsys_id = Column(Integer, ForeignKey("{0}.id".format(OpSys.__tablename__)), nullable=False, index=True)
- version = Column(String(32), nullable=False)
+ version = Column(String(64), nullable=False)
releasedate = Column(DateTime, nullable=True)
status = Column(OpSysReleaseStatus, nullable=False)
opsys = relationship(OpSys, backref="releases")
--
1.8.1.4
11 years
[LIBREPORT PATCH] Replace "THANKYOU" with EXIT_STOP_EVENT_RUN exit code (70)
by Denys Vlasenko
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/cli/cli-report.c | 11 +++--------
src/gui-wizard-gtk/wizard.c | 24 ++++++++++++------------
src/include/internal_libreport.h | 2 ++
src/plugins/ureport.c | 6 +++---
4 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
index 3923d60..c1d1401 100644
--- a/src/cli/cli-report.c
+++ b/src/cli/cli-report.c
@@ -466,7 +466,6 @@ static void ask_for_missing_settings(const char *event_name)
/*** Event running ***/
struct logging_state {
- bool saw_THANKYOU;
bool output_was_produced;
};
@@ -476,10 +475,9 @@ static char *do_log(char *log_line, void *param)
return log_line;
}
-static char *do_log_and_check_for_THANKYOU(char *log_line, void *param)
+static char *do_log2(char *log_line, void *param)
{
struct logging_state *l_state = param;
- l_state->saw_THANKYOU |= (strcmp("THANKYOU", log_line) == 0);
l_state->output_was_produced |= (log_line[0] != '\0');
return do_log(log_line, param);
}
@@ -754,7 +752,7 @@ int select_and_run_one_event(const char *dump_dir_name, const char *pfx, int int
* 3. Performs review of problem data if event requires review.
* 4. Runs events commands.
* 5. Terminates a chain run if any event from the chain requires termination
- * (prints THANKYOU to stdout in the current implementation)
+ * (i.e. if it existed with EXIT_STOP_EVENT_RUN).
* 6. Terminates a chain run if any error occurs.
* 7. Continues with processing of next event.
*/
@@ -763,13 +761,12 @@ int run_event_chain(const char *dump_dir_name, GList *chain, int interactive)
struct logging_state l_state;
struct run_event_state *run_state = new_run_event_state();
- run_state->logging_callback = do_log_and_check_for_THANKYOU;
+ run_state->logging_callback = do_log2;
run_state->logging_param = &l_state;
int retval = 0;
for (GList *eitem = chain; eitem; eitem = g_list_next(eitem))
{
- l_state.saw_THANKYOU = 0;
l_state.output_was_produced = 0;
const char *event_name = eitem->data;
retval = interactive
@@ -796,8 +793,6 @@ int run_event_chain(const char *dump_dir_name, GList *chain, int interactive)
}
if (retval != 0)
break;
- if (l_state.saw_THANKYOU)
- break;
}
free_run_event_state(run_state);
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index b9f69a4..00f1f20 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1561,17 +1561,7 @@ static void run_event_gtk_error(const char *error_line, void *param)
static char *run_event_gtk_logging(char *log_line, void *param)
{
struct analyze_event_data *evd = (struct analyze_event_data *)param;
-
- if (strcmp(log_line, "THANKYOU") == 0)
- {
- VERB1 log("Received a request for termination of processing of event chain. (Request: '%s')", log_line);
- terminate_event_chain();
- if (!g_expert_mode)
- evd->success_msg = _("Processing finished.");
- }
- else
- update_command_run_log(log_line, evd);
-
+ update_command_run_log(log_line, evd);
return log_line;
}
@@ -1725,6 +1715,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
struct analyze_event_data *evd = data;
struct run_event_state *run_state = evd->run_state;
+ bool stop_requested = false;
int retval = consume_event_command_output(run_state, g_dump_dir_name);
if (retval < 0 && errno == EAGAIN)
@@ -1733,6 +1724,14 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
/* EOF/error */
+ if (WIFEXITED(run_state->process_status)
+ && WEXITSTATUS(run_state->process_status) == EXIT_STOP_EVENT_RUN
+ ) {
+ retval = 0;
+ run_state->process_status = 0;
+ stop_requested = true;
+ }
+
unexport_event_config(evd->env_list);
evd->env_list = NULL;
@@ -1800,7 +1799,8 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
dd_close(dd);
/* Stop if exit code is not 0, or no more commands */
- if (retval != 0
+ if (stop_requested
+ || retval != 0
|| spawn_next_command_in_evd(evd) < 0
) {
VERB1 log("done running event on '%s': %d", g_dump_dir_name, retval);
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index b7c354d..3135b4a 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -432,7 +432,9 @@ extern int logmode;
#define xfunc_error_retval libreport_xfunc_error_retval
extern int xfunc_error_retval;
+/* A few magic exit codes */
#define EXIT_CANCEL_BY_USER 69
+#define EXIT_STOP_EVENT_RUN 70
#define set_xfunc_error_retval libreport_set_xfunc_error_retval
void set_xfunc_error_retval(int retval);
diff --git a/src/plugins/ureport.c b/src/plugins/ureport.c
index e45e07a..764c7aa 100644
--- a/src/plugins/ureport.c
+++ b/src/plugins/ureport.c
@@ -351,7 +351,7 @@ int main(int argc, char **argv)
}
/* -b, -a nor -r were specified - upload uReport from dump_dir */
- int ret = 1; /* return 1 by default */
+ int ret = 1; /* "failure" (for now) */
char *dest_url = concat_path_file(config.ur_url, REPORT_URL_SFX);
config.ur_url = dest_url;
@@ -379,7 +379,7 @@ int main(int argc, char **argv)
if (!response->is_error)
{
VERB1 log("is known: %s", response->value);
- ret = 0;
+ ret = 0; /* "success" */
if (response->bthash)
{
@@ -403,7 +403,7 @@ int main(int argc, char **argv)
log(_("This problem has already been reported."));
if (response->message)
log(response->message);
- log("THANKYOU");
+ ret = EXIT_STOP_EVENT_RUN;
}
}
else
--
1.8.1.4
11 years
[LIBREPORT PATCH 1/2] wizard: remove a bunch of evd->foo members
by Denys Vlasenko
No change in logic
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/gui-wizard-gtk/wizard.c | 48 ++++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 31 deletions(-)
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index 00f1f20..b4fff7e 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1348,9 +1348,6 @@ struct analyze_event_data
struct run_event_state *run_state;
const char *event_name;
GList *env_list;
- GtkWidget *page_widget;
- GtkLabel *status_label;
- GtkTextView *tv_log;
const char *success_msg;
const char *error_msg;
GIOChannel *channel;
@@ -1530,9 +1527,9 @@ static void terminate_event_chain()
hide_next_step_button();
}
-static void cancel_processing(GtkLabel *status_label, const char *message)
+static void cancel_processing(const char *message)
{
- gtk_label_set_text(status_label, message ? message : _("Processing was canceled"));
+ gtk_label_set_text(g_lbl_event_log, message ? message : _("Processing was canceled"));
terminate_event_chain();
}
@@ -1545,7 +1542,7 @@ static void update_command_run_log(const char* message, struct analyze_event_dat
/* Don't append new line behind single dot */
const char *log_msg = it_is_a_dot ? message : xasprintf("%s\n", message);
- append_to_textview(evd->tv_log, log_msg);
+ append_to_textview(g_tv_event_log, log_msg);
save_to_event_log(evd, log_msg);
/* Because of single dot, see lines above */
@@ -1759,7 +1756,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
evd->event_log_state = LOGSTATE_ERRLINE;
msg = xasprintf("(exited with %u)\n", retval);
}
- append_to_textview(evd->tv_log, msg);
+ append_to_textview(g_tv_event_log, msg);
save_to_event_log(evd, msg);
free(msg);
}
@@ -1804,7 +1801,7 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
|| spawn_next_command_in_evd(evd) < 0
) {
VERB1 log("done running event on '%s': %d", g_dump_dir_name, retval);
- append_to_textview(evd->tv_log, "\n");
+ append_to_textview(g_tv_event_log, "\n");
/* Free child output buffer */
strbuf_free(cmd_output);
@@ -1829,23 +1826,23 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
{
/* 256 means NOT_REPORTABLE */
if (retval == 256)
- cancel_processing(evd->status_label, evd->success_msg);
+ cancel_processing(evd->success_msg);
else
{
/* We use SIGTERM to stop event processing on user's request.
* So SIGTERM is not a failure.
*/
if (retval == EXIT_CANCEL_BY_USER || WTERMSIG(run_state->process_status) == SIGTERM)
- cancel_processing(evd->status_label, /* default message */ NULL);
+ cancel_processing(/* default message */ NULL);
else
{
- cancel_processing(evd->status_label, evd->error_msg);
+ cancel_processing(evd->error_msg);
on_failed_event(evd->event_name);
}
}
}
else
- gtk_label_set_text(evd->status_label, evd->success_msg);
+ gtk_label_set_text(g_lbl_event_log, evd->success_msg);
/*g_source_remove(evd->event_source_id);*/
close(evd->fd);
@@ -1880,10 +1877,6 @@ static gboolean consume_cmd_output(GIOChannel *source, GIOCondition condition, g
}
static void start_event_run(const char *event_name,
- GtkWidget *page,
- GtkTextView *tv_log,
- GtkLabel *status_label,
- const char *start_msg,
const char *error_msg,
const char *success_msg
) {
@@ -1907,11 +1900,11 @@ static void start_event_run(const char *event_name,
//TODO: better msg?
char *msg = xasprintf(_("No processing for event '%s' is defined"), event_name);
if (g_expert_mode)
- gtk_label_set_text(status_label, msg);
+ gtk_label_set_text(g_lbl_event_log, msg);
else
{
- gtk_label_set_text(status_label, error_msg);
- append_to_textview(tv_log, msg);
+ gtk_label_set_text(g_lbl_event_log, error_msg);
+ append_to_textview(g_tv_event_log, msg);
terminate_event_chain();
}
free(msg);
@@ -1926,7 +1919,7 @@ static void start_event_run(const char *event_name,
if (!g_expert_mode)
{
char *msg = xasprintf(_("Processing interrupted: can't continue without writable directory."));
- cancel_processing(status_label, msg);
+ cancel_processing(msg);
free(msg);
}
return; /* user refused to steal, or write error, etc... */
@@ -1949,9 +1942,6 @@ static void start_event_run(const char *event_name,
evd->run_state = state;
evd->event_name = event_name;
evd->env_list = env_list;
- evd->page_widget = page;
- evd->status_label = status_label;
- evd->tv_log = tv_log;
evd->error_msg = error_msg;
evd->success_msg = success_msg;
evd->event_log = strbuf_new();
@@ -1969,10 +1959,10 @@ static void start_event_run(const char *event_name,
evd
);
- gtk_label_set_text(status_label, start_msg);
+ gtk_label_set_text(g_lbl_event_log, _("Processing..."));
VERB1 log("running event '%s' on '%s'", event_name, g_dump_dir_name);
char *msg = xasprintf("--- Running %s ---\n", event_name);
- append_to_textview(evd->tv_log, msg);
+ append_to_textview(g_tv_event_log, msg);
free(msg);
/* don't bother testing if they are visible, this is faster */
@@ -2291,10 +2281,6 @@ static gint select_next_page_no(gint current_page_no, gpointer data);
static void setup_and_start_event_run(const char *event_name)
{
start_event_run(event_name,
- pages[PAGENO_EVENT_PROGRESS].page_widget,
- g_tv_event_log,
- g_lbl_event_log,
- _("Processing..."),
g_expert_mode ? _("Processing failed. You can try another operation if available.")
: _("Processing failed."),
/* this event is the last event from the chain */
@@ -2620,7 +2606,7 @@ static gint select_next_page_no(gint current_page_no, gpointer data)
{
free(event);
- cancel_processing(g_lbl_event_log, /* default message */ NULL);
+ cancel_processing(/* default message */ NULL);
current_page_no = pages[PAGENO_EVENT_PROGRESS].page_no - 1;
goto again;
}
@@ -2633,7 +2619,7 @@ static gint select_next_page_no(gint current_page_no, gpointer data)
"(it is likely a known problem). %s"),
problem_data_get_content_or_NULL(g_cd, FILENAME_NOT_REPORTABLE)
);
- cancel_processing(g_lbl_event_log, msg);
+ cancel_processing(msg);
free(msg);
current_page_no = pages[PAGENO_EVENT_PROGRESS].page_no - 1;
goto again;
--
1.8.1.4
11 years
[LIBREPORT PATCH v2] gui/cli: unify and improve event exit code reporting
by Denys Vlasenko
Instead of "(exited with N)" show "('EVENT_NAME' exited with N)".
Factor out the code which generates tese messages.
v2: mark all messages for translation.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/cli/cli-report.c | 9 ++++-----
src/gui-wizard-gtk/wizard.c | 13 +++----------
src/include/run_event.h | 6 ++++++
src/lib/run_event.c | 12 ++++++++++++
4 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
index 3923d60..f9df778 100644
--- a/src/cli/cli-report.c
+++ b/src/cli/cli-report.c
@@ -782,17 +782,16 @@ int run_event_chain(const char *dump_dir_name, GList *chain, int interactive)
break;
if (retval == 0 && run_state->children_count == 0)
{
- printf("Error: no processing is specified for event '%s'", event_name);
+ printf("Error: no processing is specified for event '%s'\n", event_name);
retval = 1;
}
else
/* If program failed, or if it finished successfully without saying anything... */
if (retval != 0 || !l_state.output_was_produced)
{
- if (WIFSIGNALED(run_state->process_status))
- printf("(killed by signal %u)\n", WTERMSIG(run_state->process_status));
- else
- printf("(exited with %u)\n", retval);
+ char *msg = exit_status_as_string(event_name, run_state->process_status);
+ fputs(msg, stdout);
+ free(msg);
}
if (retval != 0)
break;
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index b55b975..f5d832a 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1741,18 +1741,11 @@ 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)
{
- 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
+ char *msg = exit_status_as_string(evd->event_name, run_state->process_status);
+ if (retval != 0)
{
- /* If program failed, emit error line */
+ /* 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);
diff --git a/src/include/run_event.h b/src/include/run_event.h
index 40d0ba8..7579e8f 100644
--- a/src/include/run_event.h
+++ b/src/include/run_event.h
@@ -246,6 +246,12 @@ int run_event_stdio_ask_yes_no_yesforever(const char *msg, const char *key, void
*/
char *run_event_stdio_ask_password(const char *msg, void *param);
+
+/* A simple helper */
+#define exit_status_as_string libreport_exit_status_as_string
+char *exit_status_as_string(const char *progname, int status);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/run_event.c b/src/lib/run_event.c
index 6fe12f8..aa79e16 100644
--- a/src/lib/run_event.c
+++ b/src/lib/run_event.c
@@ -753,3 +753,15 @@ static void run_event_stdio_error_and_die(const char *error_line, void *param)
{
error_msg_and_die("Can't write bytes to child's stdin");
}
+
+char *exit_status_as_string(const char *progname, int status)
+{
+ char *msg;
+ if (WIFSIGNALED(status))
+ msg = xasprintf(_("('%s' was killed by signal %u)\n"), progname, WTERMSIG(status));
+ else if (status == 0)
+ msg = xasprintf(_("('%s' completed successfully)\n"), progname);
+ else
+ msg = xasprintf(_("('%s' exited with %u)\n"), progname, WEXITSTATUS(status));
+ return msg;
+}
--
1.8.1.4
11 years
[PATCH] debuginfo downloader: fix DebugInfoDownload::download() error paths.
by Denys Vlasenko
One error path was returning nothing - the caller doesn't expect it.
Return RETURN_FAILURE instead.
Another error path was just exiting (and using non-standard logging):
converted to RETURN_FAILURE.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/client-python/debuginfo.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/client-python/debuginfo.py b/src/client-python/debuginfo.py
index 4d215ad..542175e 100644
--- a/src/client-python/debuginfo.py
+++ b/src/client-python/debuginfo.py
@@ -215,7 +215,7 @@ class DebugInfoDownload(YumBase):
downloaded_pkgs = 0
# nothing to download?
if not files:
- return
+ return RETURN_FAILURE
#if verbose == 0:
# # this suppress yum messages about setting up repositories
@@ -223,8 +223,8 @@ class DebugInfoDownload(YumBase):
# make yumdownloader work as non root user
if not self.setCacheDir():
- self.logger.error("Error: can't make cachedir, exiting")
- exit(50)
+ print _("Error: can't make cachedir, exiting")
+ return RETURN_FAILURE
# disable all not needed
for repo in self.repos.listEnabled():
@@ -245,9 +245,9 @@ class DebugInfoDownload(YumBase):
self.repos.doSetup(thisrepo=str(r.id))
log1("enabled repo %s", rid)
setattr(r, "skip_if_unavailable", True)
- # yes, we want async download otherwise our progressCallback
- # is not called and the interanl yum is used, which cause
- # artifacts in output
+ # yes, we want async download, otherwise our progressCallback
+ # is not called and the internal yum's one is used,
+ # which causes artifacts on output
try:
setattr(r, "_async", False)
except Exception, ex:
--
1.8.1.4
11 years
[ABRT PATCH] abrt-dump-oops: add "Machine Check Exception" to the list of watched strings
by Denys Vlasenko
Step one in MCE handling is to catch them.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/lib/kernel.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/lib/kernel.c b/src/lib/kernel.c
index 9274213..93e6603 100644
--- a/src/lib/kernel.c
+++ b/src/lib/kernel.c
@@ -100,6 +100,15 @@ static const char *const s_koops_suspicious_strings[] = {
/*s*/"ysctl table check failed",
": nobody cared",
"IRQ handler type mismatch",
+ /*
+ * MCE examples for various CPUs/architectures (collected 2013-04):
+ * arch/arc/kernel/traps.c: die("Machine Check Exception", regs, address, cause);
+ * arch/x86/kernel/cpu/mcheck/winchip.c: printk(KERN_EMERG "CPU0: Machine Check Exception.\n");
+ * arch/x86/kernel/cpu/mcheck/p5.c: "CPU#%d: Machine Check Exception: 0x%8X (type 0x%8X).\n",
+ * arch/x86/kernel/cpu/mcheck/mce.c: pr_emerg(HW_ERR "CPU %d: Machine Check Exception: %Lx Bank %d: %016Lx\n",
+ * drivers/edac/sb_edac.c: printk("CPU %d: Machine Check Exception: %Lx Bank %d: %016Lx\n",
+ */
+ "Machine Check Exception",
/* X86 TRAPs */
"divide error:",
--
1.8.1.4
11 years
[ABRT PATCH] abrtd: update last occurrcen dump dir file
by Jakub Filak
Related to rhbz#947870
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/daemon/abrtd.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index 7bc93ef..2541ea8 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -434,6 +434,34 @@ static gboolean handle_event_output_cb(GIOChannel *gio, GIOCondition condition,
char new_count_str[sizeof(long)*3 + 2];
sprintf(new_count_str, "%lu", count);
dd_save_text(dd, FILENAME_COUNT, new_count_str);
+
+ /* Update the last occurrence file */
+ struct dump_dir *new_dd = dd_opendir(state->dirname,
+ DD_OPEN_READONLY | DD_FAIL_QUIETLY_ENOENT | DD_FAIL_QUIETLY_EACCES);
+ char *last_ocr = NULL;
+ if (new_dd)
+ {
+ /* TIME must exists in a valid dump directory but we don't want to die
+ * due to broken duplicated dump directory */
+ last_ocr = dd_load_text_ext(new_dd, FILENAME_TIME,
+ DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE | DD_FAIL_QUIETLY_ENOENT);
+ dd_close(new_dd);
+ }
+ else
+ { /* dd_opendir() already produced a message with good information about failure */
+ error_msg("Can't read the last occurrence file from the new dump directory.");
+ }
+
+ if (!last_ocr)
+ { /* the new dump directory may lie in the dump location for some time */
+ log("Using current time for the last occurrence file which may be incorrect.");
+ time_t t = time(NULL);
+ last_ocr = xasprintf("%lu", (long)t);
+ }
+
+ dd_save_text(dd, FILENAME_LAST_OCCURRENCE, last_ocr);
+
+ free(last_ocr);
}
/* Reset mode/uig/gid to correct values for all files created by event run */
--
1.8.1.4
11 years
[ABRT PATCH] return the right exit code for user cancellation
by Jakub Filak
Let a frontend know that the error is not fatal and the termination
was driven by user request.
Related to abrt/libreport#146
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/plugins/abrt-action-install-debuginfo.in | 4 ++--
src/plugins/abrt-action-perform-ccpp-analysis.in | 22 +++++++++++++++-------
src/plugins/abrt-retrace-client.c | 3 +++
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/plugins/abrt-action-install-debuginfo.in b/src/plugins/abrt-action-install-debuginfo.in
index a061fa6..8969b86 100644
--- a/src/plugins/abrt-action-install-debuginfo.in
+++ b/src/plugins/abrt-action-install-debuginfo.in
@@ -197,7 +197,7 @@ if __name__ == "__main__":
error_msg("Can't execute abrt-action-trim-files: %s", e);
missing = filter_installed_debuginfos(b_ids, cachedirs)
-
+ result = RETURN_OK
if missing:
log2("%s", missing)
print _("Coredump references {0} debuginfo files, {1} of them are not installed").format(len(b_ids), len(missing))
@@ -216,4 +216,4 @@ if __name__ == "__main__":
if not missing:
print _("All debuginfo files are available")
- exit(RETURN_OK)
+ exit(result)
diff --git a/src/plugins/abrt-action-perform-ccpp-analysis.in b/src/plugins/abrt-action-perform-ccpp-analysis.in
index c844fbd..14f5049 100644
--- a/src/plugins/abrt-action-perform-ccpp-analysis.in
+++ b/src/plugins/abrt-action-perform-ccpp-analysis.in
@@ -11,8 +11,12 @@ import gettext
from subprocess import Popen
import report
+from report import EXIT_CANCELED_BY_USER as RETURN_CANCELED_BY_USER
from reportclient import ask_yes_no_yesforever
+# everything was ok
+RETURN_OK = 0
+
GETTEXT_PROGNAME = "abrt"
_ = gettext.lgettext
@@ -34,8 +38,9 @@ def handle_event(event_name, problem_dir):
if ret == 0 and state.children_count == 0:
print "No actions are found for event '%s'" % event_name
+ return RETURN_FAILURE
- return ret == 0 and state.children_count != 0
+ return ret
def run_analyze_smart(problem_dir):
@@ -53,14 +58,14 @@ def run_analyze_smart(problem_dir):
"""
- analyzed = False
+ retval = RETURN_CANCELED_BY_USER
allowed = ask_yes_no_yesforever("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 locally. "\
"(It may download a huge amount of data)."))
if allowed:
- analyzed = handle_event("analyze_RetraceServer", problem_dir)
+ retval = handle_event("analyze_RetraceServer", problem_dir)
# temporary helper variables for better readability
option = "abrt_analyze_smart_ask_perform_local_analysis"
@@ -70,10 +75,13 @@ def run_analyze_smart(problem_dir):
# 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_yesforever(option, question)):
- analyzed = handle_event("analyze_LocalGDB", problem_dir)
+ #
+ # don't change the retval to RETURN_CANCELED_BY_USER if ask_yes_no_yesforever() is False
+ # we want to catch errors produced by Retrace Server
+ if not allowed or (retval != RETURN_OK and ask_yes_no_yesforever(option, question)):
+ retval = handle_event("analyze_LocalGDB", problem_dir)
- return analyzed
+ return retval
if __name__ == "__main__":
@@ -99,4 +107,4 @@ if __name__ == "__main__":
OPTIONS = CMDARGS.parse_args()
- sys.exit(0 if run_analyze_smart(vars(OPTIONS)['problem_dir']) else 1)
+ sys.exit(run_analyze_smart(vars(OPTIONS)['problem_dir']))
diff --git a/src/plugins/abrt-retrace-client.c b/src/plugins/abrt-retrace-client.c
index 781a815..6071528 100644
--- a/src/plugins/abrt-retrace-client.c
+++ b/src/plugins/abrt-retrace-client.c
@@ -619,7 +619,10 @@ static int create(bool delete_temp_archive,
free(question);
if (!response)
+ {
+ set_xfunc_error_retval(EXIT_CANCELED_BY_USER);
error_msg_and_die(_("Cancelled by user"));
+ }
}
PRFileDesc *tcp_sock, *ssl_sock;
--
1.8.1.4
11 years
[LIBREPORT PATCH 1/2] logging: refine errors reporting
by Jakub Filak
Define macro for exit code saying that user canceled the operation. We
want to be able to distinguish between fatal errors and user requests
because we want to react in different ways in frontends.
The code is 69 and there is no special reason for it. (except it must be
in range 0-255)
The current implementation allows programmers to set a global variable
xfunc_error_retval to any value nevertheless the new function hiding the
global variable was added in order to support bindings to other
languages.
Related to #146
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/client-python/debuginfo.py | 3 ++-
src/include/internal_libreport.h | 5 +++++
src/lib/logging.c | 5 +++++
src/plugins/reporter-bugzilla.c | 6 ++++++
src/plugins/reporter-print.c | 3 +++
src/report-python/reportmodule.c | 3 +++
6 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/client-python/debuginfo.py b/src/client-python/debuginfo.py
index 4d4bffa..cbba0f3 100644
--- a/src/client-python/debuginfo.py
+++ b/src/client-python/debuginfo.py
@@ -1,6 +1,7 @@
from subprocess import Popen, PIPE
from yum import _, YumBase
from yum.callbacks import DownloadBaseCallback
+from report import EXIT_CANCELED_BY_USER as RETURN_CANCELED_BY_USER
from reportclient import *
from reportclient import _
import sys
@@ -323,7 +324,7 @@ class DebugInfoDownload(YumBase):
)
if self.noninteractive == False and not ask_yes_no(question):
print _("Download cancelled by user")
- return RETURN_OK
+ return RETURN_CANCELED_BY_USER
for pkg, files in package_files_dict.iteritems():
dnlcb.downloaded_pkgs = downloaded_pkgs
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 456db38..6fbdce8 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -432,6 +432,11 @@ extern int logmode;
#define xfunc_error_retval libreport_xfunc_error_retval
extern int xfunc_error_retval;
+#define EXIT_CANCELED_BY_USER 69
+
+#define set_xfunc_error_retval libreport_set_xfunc_error_retval
+void set_xfunc_error_retval(int retval);
+
/* Verbosity level */
#define g_verbose libreport_g_verbose
extern int g_verbose;
diff --git a/src/lib/logging.c b/src/lib/logging.c
index bfd9424..826ac5c 100644
--- a/src/lib/logging.c
+++ b/src/lib/logging.c
@@ -26,6 +26,11 @@ int logmode = LOGMODE_STDIO;
int xfunc_error_retval = EXIT_FAILURE;
int g_verbose;
+void set_xfunc_error_retval(int retval)
+{
+ xfunc_error_retval = retval;
+}
+
/* [p]error_msg[_and_die] must be safe after fork in multi-threaded programs.
* Therefore we avoid stdio, fflush(), and use _exit() instead of exit().
*
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index 0d6c9a9..9ba7de2 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -745,7 +745,10 @@ char *ask_bz_login(const char *message)
{
char *login = ask(message);
if (login == NULL || login[0] == '\0')
+ {
+ set_xfunc_error_retval(EXIT_CANCELED_BY_USER);
error_msg_and_die(_("Can't continue without login"));
+ }
return login;
}
@@ -755,7 +758,10 @@ char *ask_bz_password(const char *message)
{
char *password = ask_password(message);
if (password == NULL || password[0] == '\0')
+ {
+ set_xfunc_error_retval(EXIT_CANCELED_BY_USER);
error_msg_and_die(_("Can't continue without password"));
+ }
return password;
}
diff --git a/src/plugins/reporter-print.c b/src/plugins/reporter-print.c
index 2288396..1ff09aa 100644
--- a/src/plugins/reporter-print.c
+++ b/src/plugins/reporter-print.c
@@ -93,7 +93,10 @@ int main(int argc, char **argv)
free(msg);
if (response[0] == '\0' || response[0] == '\n')
+ {
+ set_xfunc_error_retval(EXIT_CANCELED_BY_USER);
error_msg_and_die(_("Cancelled by user."));
+ }
output_file = strtrim(response);
}
diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c
index bbe1ea8..1367541 100644
--- a/src/report-python/reportmodule.c
+++ b/src/report-python/reportmodule.c
@@ -19,6 +19,8 @@
#include <Python.h>
#include "common.h"
+#include "internal_libreport.h"
+
PyObject *ReportError;
@@ -96,4 +98,5 @@ init_pyreport(void)
PyModule_AddObject(m, "LIBREPORT_DEL_DIR" , Py_BuildValue("i", LIBREPORT_DEL_DIR ));
PyModule_AddObject(m, "LIBREPORT_RUN_CLI" , Py_BuildValue("i", LIBREPORT_RUN_CLI ));
PyModule_AddObject(m, "LIBREPORT_RUN_NEWT" , Py_BuildValue("i", LIBREPORT_RUN_NEWT ));
+ PyModule_AddObject(m, "EXIT_CANCELED_BY_USER", Py_BuildValue("i", EXIT_CANCELED_BY_USER));
}
--
1.8.1.4
11 years
[LIBREPORT PATCH] gui/cli: unify and improve event exit code reporting
by Denys Vlasenko
Instead of "(exited with N)" show "('EVENT_NAME' exited with N)".
Factor out the code which generates tese messages.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
---
src/cli/cli-report.c | 9 ++++-----
src/gui-wizard-gtk/wizard.c | 13 +++----------
src/include/run_event.h | 6 ++++++
src/lib/run_event.c | 12 ++++++++++++
4 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c
index 3923d60..f9df778 100644
--- a/src/cli/cli-report.c
+++ b/src/cli/cli-report.c
@@ -782,17 +782,16 @@ int run_event_chain(const char *dump_dir_name, GList *chain, int interactive)
break;
if (retval == 0 && run_state->children_count == 0)
{
- printf("Error: no processing is specified for event '%s'", event_name);
+ printf("Error: no processing is specified for event '%s'\n", event_name);
retval = 1;
}
else
/* If program failed, or if it finished successfully without saying anything... */
if (retval != 0 || !l_state.output_was_produced)
{
- if (WIFSIGNALED(run_state->process_status))
- printf("(killed by signal %u)\n", WTERMSIG(run_state->process_status));
- else
- printf("(exited with %u)\n", retval);
+ char *msg = exit_status_as_string(event_name, run_state->process_status);
+ fputs(msg, stdout);
+ free(msg);
}
if (retval != 0)
break;
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
index b55b975..f5d832a 100644
--- a/src/gui-wizard-gtk/wizard.c
+++ b/src/gui-wizard-gtk/wizard.c
@@ -1741,18 +1741,11 @@ 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)
{
- 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
+ char *msg = exit_status_as_string(evd->event_name, run_state->process_status);
+ if (retval != 0)
{
- /* If program failed, emit error line */
+ /* 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);
diff --git a/src/include/run_event.h b/src/include/run_event.h
index 40d0ba8..7579e8f 100644
--- a/src/include/run_event.h
+++ b/src/include/run_event.h
@@ -246,6 +246,12 @@ int run_event_stdio_ask_yes_no_yesforever(const char *msg, const char *key, void
*/
char *run_event_stdio_ask_password(const char *msg, void *param);
+
+/* A simple helper */
+#define exit_status_as_string libreport_exit_status_as_string
+char *exit_status_as_string(const char *progname, int status);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/run_event.c b/src/lib/run_event.c
index 6fe12f8..aa79e16 100644
--- a/src/lib/run_event.c
+++ b/src/lib/run_event.c
@@ -753,3 +753,15 @@ static void run_event_stdio_error_and_die(const char *error_line, void *param)
{
error_msg_and_die("Can't write bytes to child's stdin");
}
+
+char *exit_status_as_string(const char *progname, int status)
+{
+ char *msg;
+ if (WIFSIGNALED(status))
+ msg = xasprintf("('%s' was killed by signal %u)\n", progname, WTERMSIG(status));
+ else if (status == 0)
+ msg = xasprintf(_("('%s' completed successfully)\n"), progname);
+ else
+ msg = xasprintf("('%s' exited with %u)\n", progname, WEXITSTATUS(status));
+ return msg;
+}
--
1.8.1.4
11 years