* [PATCH] report-error: Add a check for binary log file
@ 2015-01-29 16:36 Michael Wood
2015-01-30 10:24 ` Richard Purdie
0 siblings, 1 reply; 4+ messages in thread
From: Michael Wood @ 2015-01-29 16:36 UTC (permalink / raw)
To: openembedded-core
Check to see if the log file is a binary. If it is do not try to submit
it in our error-report.
[YOCTO #7263]
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
meta/classes/report-error.bbclass | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index 8b30422..101fe9b 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -24,6 +24,15 @@ def errorreport_savedata(e, newdata, file):
json.dump(newdata, f, indent=4, sort_keys=True)
return datafile
+def errorreport_testlogforbinary(data):
+ for c in data:
+ # If the data contains non visible character below 10 it's a binary
+ if (ord(c) < 10):
+ return True
+
+ return False
+
+
python errorreport_handler () {
import json
@@ -48,7 +57,13 @@ python errorreport_handler () {
taskdata['task'] = task
if log:
logFile = open(log, 'r')
- taskdata['log'] = logFile.read()
+ # Detect binary log output
+ logdata = logFile.read()
+ if errorreport_testlogforbinary(logdata):
+ taskdata['log'] = "Log in binary format"
+ else:
+ taskdata['log'] = logdata
+
logFile.close()
else:
taskdata['log'] = "No Log"
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] report-error: Add a check for binary log file
2015-01-29 16:36 [PATCH] report-error: Add a check for binary log file Michael Wood
@ 2015-01-30 10:24 ` Richard Purdie
2015-01-30 11:57 ` [PATCH] report-error: Catch un-readable log data Michael Wood
0 siblings, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2015-01-30 10:24 UTC (permalink / raw)
To: Michael Wood; +Cc: openembedded-core
On Thu, 2015-01-29 at 16:36 +0000, Michael Wood wrote:
> Check to see if the log file is a binary. If it is do not try to submit
> it in our error-report.
>
> [YOCTO #7263]
>
> Signed-off-by: Michael Wood <michael.g.wood@intel.com>
> ---
> meta/classes/report-error.bbclass | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
> index 8b30422..101fe9b 100644
> --- a/meta/classes/report-error.bbclass
> +++ b/meta/classes/report-error.bbclass
> @@ -24,6 +24,15 @@ def errorreport_savedata(e, newdata, file):
> json.dump(newdata, f, indent=4, sort_keys=True)
> return datafile
>
> +def errorreport_testlogforbinary(data):
> + for c in data:
> + # If the data contains non visible character below 10 it's a binary
> + if (ord(c) < 10):
> + return True
> +
> + return False
> +
> +
> python errorreport_handler () {
> import json
>
> @@ -48,7 +57,13 @@ python errorreport_handler () {
> taskdata['task'] = task
> if log:
> logFile = open(log, 'r')
> - taskdata['log'] = logFile.read()
> + # Detect binary log output
> + logdata = logFile.read()
> + if errorreport_testlogforbinary(logdata):
> + taskdata['log'] = "Log in binary format"
> + else:
> + taskdata['log'] = logdata
> +
> logFile.close()
> else:
> taskdata['log'] = "No Log"
I was thinking about this a bit more. How about we put a try/except
around the json code which sets taskdata['log'] = "Log in binary format"
if the original coding doesn't work for any reason? That way we should
catch any problem with the log?
Cheers,
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] report-error: Catch un-readable log data
2015-01-30 10:24 ` Richard Purdie
@ 2015-01-30 11:57 ` Michael Wood
2015-02-03 14:20 ` [PATCH v2] " Michael Wood
0 siblings, 1 reply; 4+ messages in thread
From: Michael Wood @ 2015-01-30 11:57 UTC (permalink / raw)
To: openembedded-core
If a log data cannot be decoded to utf-8 or read then handle this
gracefully. This can happen if a log file contains binary or something
goes wrong with the file read process.
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
meta/classes/report-error.bbclass | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index 8b30422..750042b 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -48,7 +48,11 @@ python errorreport_handler () {
taskdata['task'] = task
if log:
logFile = open(log, 'r')
- taskdata['log'] = logFile.read()
+ try:
+ taskdata['log'] = logFile.read().decode('utf-8')
+ except:
+ taskdata['log'] = "Unable to read log file"
+
logFile.close()
else:
taskdata['log'] = "No Log"
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2] report-error: Catch un-readable log data
2015-01-30 11:57 ` [PATCH] report-error: Catch un-readable log data Michael Wood
@ 2015-02-03 14:20 ` Michael Wood
0 siblings, 0 replies; 4+ messages in thread
From: Michael Wood @ 2015-02-03 14:20 UTC (permalink / raw)
To: openembedded-core
If a log data cannot be decoded to utf-8 or read then handle this
gracefully. This can happen if a log file contains binary or something
goes wrong with the file open process.
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
meta/classes/report-error.bbclass | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index 8b30422..5f155e3 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -47,9 +47,13 @@ python errorreport_handler () {
taskdata['package'] = e.data.expand("${PF}")
taskdata['task'] = task
if log:
- logFile = open(log, 'r')
- taskdata['log'] = logFile.read()
- logFile.close()
+ try:
+ logFile = open(log, 'r')
+ taskdata['log'] = logFile.read().decode('utf-8')
+ logFile.close()
+ except:
+ taskdata['log'] = "Unable to read log file"
+
else:
taskdata['log'] = "No Log"
jsondata = json.loads(errorreport_getdata(e))
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-03 14:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 16:36 [PATCH] report-error: Add a check for binary log file Michael Wood
2015-01-30 10:24 ` Richard Purdie
2015-01-30 11:57 ` [PATCH] report-error: Catch un-readable log data Michael Wood
2015-02-03 14:20 ` [PATCH v2] " Michael Wood
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.