[oe] [PATCH] Add error handling to read_cache in stage-manager
Koen Kooi
k.kooi at student.utwente.nl
Mon Apr 26 10:20:20 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Looks good to me,
Acked-By: Koen Kooi <koen at 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-----
More information about the Openembedded-devel
mailing list