From ae140b9fb603276641aed8ec9c17ed862d24cc2f Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 3 Jan 2017 11:24:37 +0000 Subject: [PATCH] Python examples --- examples/python/binary_message.py | 6 +++--- examples/python/binary_message.sh | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/python/binary_message.py b/examples/python/binary_message.py index f3110f8f5..26d39dd5c 100644 --- a/examples/python/binary_message.py +++ b/examples/python/binary_message.py @@ -19,7 +19,7 @@ VERBOSE = 1 # verbose error reporting def example(): f = open(sys.argv[1]) - out = open(sys.argv[2], 'w') + fout = open(sys.argv[2], 'w') while 1: gid = codes_grib_new_from_file(f) @@ -29,12 +29,12 @@ def example(): message = codes_get_message(gid) newgid = codes_new_from_message(message) - codes_write(newgid, out) + codes_write(newgid, fout) codes_release(newgid) codes_release(gid) - out.close() + fout.close() f.close() diff --git a/examples/python/binary_message.sh b/examples/python/binary_message.sh index ba9c95616..dae3645c3 100755 --- a/examples/python/binary_message.sh +++ b/examples/python/binary_message.sh @@ -3,11 +3,11 @@ . ./include.sh INPUT=${data_dir}/tigge_pf_ecmwf.grib2 -OUTPUT=out.grib +OUTPUT=temp.binary_message.grib $PYTHON $examples_src/binary_message.py $INPUT $OUTPUT ${tools_dir}/grib_compare $INPUT $OUTPUT -rm $OUTPUT || true +rm -f $OUTPUT # GRIB-568 corrupt grib # We are expecting the command to fail so must turn off "set -e" @@ -18,5 +18,4 @@ status=$? set -e # Check command did indeed fail [ $status != 0 ] -rm $OUTPUT || true - +rm -f $OUTPUT