* [PATCH] Add error handling to read_cache in stage-manager
@ 2010-04-26 9:33 Mickaël Chazaux
2010-04-26 10:20 ` Koen Kooi
0 siblings, 1 reply; 7+ messages in thread
From: Mickaël Chazaux @ 2010-04-26 9:33 UTC (permalink / raw)
To: openembedded-devel; +Cc: Mickaël Chazaux
Sometimes stage-manager crashes with this message :
Traceback (most recent call last):
File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
line 79, in <module>
cache = read_cache(options.cachefile)
File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
line 34, in read_cache
cache[data[0]]['ts'] = int(data[1])
IndexError: list index out of range
This is due to a corrupted cache file. This patch adds an error message
telling the cause of the crash to the user.
---
recipes/stage-manager/files/stage-manager | 14 +++++++++-----
recipes/stage-manager/stagemanager-native_0.0.1.bb | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/recipes/stage-manager/files/stage-manager b/recipes/stage-manager/files/stage-manager
index 536d1af..93196ff 100755
--- a/recipes/stage-manager/files/stage-manager
+++ b/recipes/stage-manager/files/stage-manager
@@ -29,11 +29,15 @@ def read_cache(cachefile):
lines = f.readlines()
f.close()
for l in lines:
- data = l.split('|')
- cache[data[0]] = {}
- cache[data[0]]['ts'] = int(data[1])
- cache[data[0]]['size'] = int(data[2])
- cache[data[0]]['seen'] = False
+ try:
+ data = l.split('|')
+ d = cache[data[0]] = {}
+ d['ts'] = int(data[1])
+ d['size'] = int(data[2])
+ d['seen'] = False
+ except IndexError, e:
+ print("Corrupted line in cachefile " + cachefile + " : " + l)
+ raise e
return cache
def mkdirhier(dir):
diff --git a/recipes/stage-manager/stagemanager-native_0.0.1.bb b/recipes/stage-manager/stagemanager-native_0.0.1.bb
index 5708045..4357517 100644
--- a/recipes/stage-manager/stagemanager-native_0.0.1.bb
+++ b/recipes/stage-manager/stagemanager-native_0.0.1.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "Helper script for packaged-staging.bbclass"
-PR = "r11"
+PR = "r13"
SRC_URI = "file://stage-manager \
file://stage-manager-ipkg \
--
1.6.3.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Add error handling to read_cache in stage-manager
2010-04-26 9:33 [PATCH] Add error handling to read_cache in stage-manager Mickaël Chazaux
@ 2010-04-26 10:20 ` Koen Kooi
2010-04-26 14:48 ` Chris Larson
0 siblings, 1 reply; 7+ messages in thread
From: Koen Kooi @ 2010-04-26 10:20 UTC (permalink / raw)
To: openembedded-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Looks good to me,
Acked-By: Koen Kooi <koen@openembedded.org>
On 26-04-10 11:33, Mickaël Chazaux wrote:
> Sometimes stage-manager crashes with this message :
> Traceback (most recent call last):
> File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
> line 79, in <module>
> cache = read_cache(options.cachefile)
> File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
> line 34, in read_cache
> cache[data[0]]['ts'] = int(data[1])
> IndexError: list index out of range
>
> This is due to a corrupted cache file. This patch adds an error message
> telling the cause of the crash to the user.
> ---
> recipes/stage-manager/files/stage-manager | 14 +++++++++-----
> recipes/stage-manager/stagemanager-native_0.0.1.bb | 2 +-
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/recipes/stage-manager/files/stage-manager b/recipes/stage-manager/files/stage-manager
> index 536d1af..93196ff 100755
> --- a/recipes/stage-manager/files/stage-manager
> +++ b/recipes/stage-manager/files/stage-manager
> @@ -29,11 +29,15 @@ def read_cache(cachefile):
> lines = f.readlines()
> f.close()
> for l in lines:
> - data = l.split('|')
> - cache[data[0]] = {}
> - cache[data[0]]['ts'] = int(data[1])
> - cache[data[0]]['size'] = int(data[2])
> - cache[data[0]]['seen'] = False
> + try:
> + data = l.split('|')
> + d = cache[data[0]] = {}
> + d['ts'] = int(data[1])
> + d['size'] = int(data[2])
> + d['seen'] = False
> + except IndexError, e:
> + print("Corrupted line in cachefile " + cachefile + " : " + l)
> + raise e
> return cache
>
> def mkdirhier(dir):
> diff --git a/recipes/stage-manager/stagemanager-native_0.0.1.bb b/recipes/stage-manager/stagemanager-native_0.0.1.bb
> index 5708045..4357517 100644
> --- a/recipes/stage-manager/stagemanager-native_0.0.1.bb
> +++ b/recipes/stage-manager/stagemanager-native_0.0.1.bb
> @@ -1,5 +1,5 @@
> DESCRIPTION = "Helper script for packaged-staging.bbclass"
> -PR = "r11"
> +PR = "r13"
>
> SRC_URI = "file://stage-manager \
> file://stage-manager-ipkg \
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFL1WjkMkyGM64RGpERAt8oAJ9mwOyDvMIdKcnwwwT+FKNCf+96SACgm+DY
c1xLNKOJQXZjZurAa6nNGiU=
=QDGW
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add error handling to read_cache in stage-manager
2010-04-26 10:20 ` Koen Kooi
@ 2010-04-26 14:48 ` Chris Larson
2010-04-26 15:25 ` Mickael Chazaux
0 siblings, 1 reply; 7+ messages in thread
From: Chris Larson @ 2010-04-26 14:48 UTC (permalink / raw)
To: openembedded-devel
On Mon, Apr 26, 2010 at 3:20 AM, Koen Kooi <k.kooi@student.utwente.nl>wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Looks good to me,
>
> Acked-By: Koen Kooi <koen@openembedded.org>
>
>
Same here.
Acked-By: Chris Larson <chris_larson@mentor.com>
Might also be worth catching ValueError there, to be safe (int("foo") raises
that :).
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add error handling to read_cache in stage-manager
2010-04-26 14:48 ` Chris Larson
@ 2010-04-26 15:25 ` Mickael Chazaux
0 siblings, 0 replies; 7+ messages in thread
From: Mickael Chazaux @ 2010-04-26 15:25 UTC (permalink / raw)
To: openembedded-devel
Hi,
2010/4/26 Chris Larson <clarson@kergoth.com>:
> On Mon, Apr 26, 2010 at 3:20 AM, Koen Kooi <k.kooi@student.utwente.nl>wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Looks good to me,
>>
>> Acked-By: Koen Kooi <koen@openembedded.org>
>>
>>
> Same here.
>
> Acked-By: Chris Larson <chris_larson@mentor.com>
>
> Might also be worth catching ValueError there, to be safe (int("foo") raises
> that :).
I'll add that. I am also unsure on what to do in case of an error. Is
it possible to ignore them? In that case, failing silently may be
better.
Regards,
Mickael
Adeneo Embedded - Adetel Group
2, chemin du Ruisseau
69134 ECULLY - FRANCE
Tél. : +33 (0)4 72 18 08 40 - Fax : +33 (0)4 72 18 08 41
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add error handling to read_cache in stage-manager
@ 2010-04-30 12:25 Mickaël Chazaux
0 siblings, 0 replies; 7+ messages in thread
From: Mickaël Chazaux @ 2010-04-30 12:25 UTC (permalink / raw)
To: openembedded-devel; +Cc: Mickaël Chazaux
Sometimes stage-manager crashes with this message :
Traceback (most recent call last):
File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
line 79, in <module>
cache = read_cache(options.cachefile)
File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
line 34, in read_cache
cache[data[0]]['ts'] = int(data[1])
IndexError: list index out of range
This is due to a corrupted cache file. This patch adds an error message
and continues parsing ignoring the wrong line. The file is then properly
regenerated.
Signed-off-by: Mickaël Chazaux <mchazaux@adeneo-embedded.com>
---
recipes/stage-manager/files/stage-manager | 14 +++++++++-----
recipes/stage-manager/stagemanager-native_0.0.1.bb | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/recipes/stage-manager/files/stage-manager b/recipes/stage-manager/files/stage-manager
index 536d1af..039614f 100755
--- a/recipes/stage-manager/files/stage-manager
+++ b/recipes/stage-manager/files/stage-manager
@@ -29,11 +29,15 @@ def read_cache(cachefile):
lines = f.readlines()
f.close()
for l in lines:
- data = l.split('|')
- cache[data[0]] = {}
- cache[data[0]]['ts'] = int(data[1])
- cache[data[0]]['size'] = int(data[2])
- cache[data[0]]['seen'] = False
+ try:
+ data = l.split('|')
+ d = {}
+ d['ts'] = int(data[1])
+ d['size'] = int(data[2])
+ d['seen'] = False
+ cache[data[0]] = d
+ except (IndexError, ValueError):
+ print("Corrupted line in cachefile " + cachefile + " : " + l)
return cache
def mkdirhier(dir):
diff --git a/recipes/stage-manager/stagemanager-native_0.0.1.bb b/recipes/stage-manager/stagemanager-native_0.0.1.bb
index 5708045..4357517 100644
--- a/recipes/stage-manager/stagemanager-native_0.0.1.bb
+++ b/recipes/stage-manager/stagemanager-native_0.0.1.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "Helper script for packaged-staging.bbclass"
-PR = "r11"
+PR = "r13"
SRC_URI = "file://stage-manager \
file://stage-manager-ipkg \
--
1.6.3.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Add error handling to read_cache in stage-manager
2010-04-27 7:53 Mickaël Chazaux
@ 2010-04-27 14:10 ` Chris Larson
0 siblings, 0 replies; 7+ messages in thread
From: Chris Larson @ 2010-04-27 14:10 UTC (permalink / raw)
To: openembedded-devel; +Cc: Mickaël Chazaux
2010/4/27 Mickaël Chazaux <mchazaux@adeneo-embedded.com>
> Sometimes stage-manager crashes with this message :
> Traceback (most recent call last):
> File
> "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
> line 79, in <module>
> cache = read_cache(options.cachefile)
> File
> "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
> line 34, in read_cache
> cache[data[0]]['ts'] = int(data[1])
> IndexError: list index out of range
>
> This is due to a corrupted cache file. This patch adds an error message
> and continues parsing ignoring the wrong line. The file is then properly
> regenerated.
>
>
You forgot a Signed-off-by, best off doing a commit -s in the future. Looks
okay to me.
Acked-By: Chris Larson <chris_larson@mentor.com>
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add error handling to read_cache in stage-manager
@ 2010-04-27 7:53 Mickaël Chazaux
2010-04-27 14:10 ` Chris Larson
0 siblings, 1 reply; 7+ messages in thread
From: Mickaël Chazaux @ 2010-04-27 7:53 UTC (permalink / raw)
To: openembedded-devel; +Cc: Mickaël Chazaux
Sometimes stage-manager crashes with this message :
Traceback (most recent call last):
File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
line 79, in <module>
cache = read_cache(options.cachefile)
File "/home/mchazaux/projet/OE/openembedded/recipes/stage-manager/files/stage-manager",
line 34, in read_cache
cache[data[0]]['ts'] = int(data[1])
IndexError: list index out of range
This is due to a corrupted cache file. This patch adds an error message
and continues parsing ignoring the wrong line. The file is then properly
regenerated.
---
recipes/stage-manager/files/stage-manager | 14 +++++++++-----
recipes/stage-manager/stagemanager-native_0.0.1.bb | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/recipes/stage-manager/files/stage-manager b/recipes/stage-manager/files/stage-manager
index 536d1af..039614f 100755
--- a/recipes/stage-manager/files/stage-manager
+++ b/recipes/stage-manager/files/stage-manager
@@ -29,11 +29,15 @@ def read_cache(cachefile):
lines = f.readlines()
f.close()
for l in lines:
- data = l.split('|')
- cache[data[0]] = {}
- cache[data[0]]['ts'] = int(data[1])
- cache[data[0]]['size'] = int(data[2])
- cache[data[0]]['seen'] = False
+ try:
+ data = l.split('|')
+ d = {}
+ d['ts'] = int(data[1])
+ d['size'] = int(data[2])
+ d['seen'] = False
+ cache[data[0]] = d
+ except (IndexError, ValueError):
+ print("Corrupted line in cachefile " + cachefile + " : " + l)
return cache
def mkdirhier(dir):
diff --git a/recipes/stage-manager/stagemanager-native_0.0.1.bb b/recipes/stage-manager/stagemanager-native_0.0.1.bb
index 5708045..4357517 100644
--- a/recipes/stage-manager/stagemanager-native_0.0.1.bb
+++ b/recipes/stage-manager/stagemanager-native_0.0.1.bb
@@ -1,5 +1,5 @@
DESCRIPTION = "Helper script for packaged-staging.bbclass"
-PR = "r11"
+PR = "r13"
SRC_URI = "file://stage-manager \
file://stage-manager-ipkg \
--
1.6.3.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-04-30 12:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-26 9:33 [PATCH] Add error handling to read_cache in stage-manager Mickaël Chazaux
2010-04-26 10:20 ` Koen Kooi
2010-04-26 14:48 ` Chris Larson
2010-04-26 15:25 ` Mickael Chazaux
2010-04-27 7:53 Mickaël Chazaux
2010-04-27 14:10 ` Chris Larson
2010-04-30 12:25 Mickaël Chazaux
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.