diff --git a/edosl0util/cli/rdr2l0.py b/edosl0util/cli/rdr2l0.py index a7a2d810ff138a69650ef0acf2827357dacafdb4..9cbd024b709a75cc64606849368c286c08a33bb8 100644 --- a/edosl0util/cli/rdr2l0.py +++ b/edosl0util/cli/rdr2l0.py @@ -8,7 +8,6 @@ __copyright__ = "Copyright (C) 2015 University of Wisconsin SSEC. All rights res import os import glob import logging -import tempfile from datetime import datetime, timedelta from edosl0util import stream, merge, jpssrdr @@ -95,7 +94,8 @@ def spacecraft(satellite, rdrs, start, end): for apid in (0, 8, 11): # alphanumeric sorting to bootstrap final sort inputs = sorted(glob.glob('*.ancillary{}.pkts'.format(apid))) - streams = [stream.jpss_packet_stream(open(f, 'rb')) for f in inputs] + files = [open(f, 'rb') for f in inputs] + streams = [stream.jpss_packet_stream(f) for f in files] product = 'P{}{:04d}'.format(scid, apid) pdsname = pdsfilename(product, start) @@ -103,6 +103,9 @@ def spacecraft(satellite, rdrs, start, end): with open(pdsname, 'wb') as dest: merge.merge(streams, output=dest, trunc_to=[start, end]) + # lots of files so make sure they're closed + [f.close() for f in files] + def main(): # XXX: This currently uses standard CCSDS packet merging that does not have @@ -192,7 +195,7 @@ def main(): util.configure_logging(args) - pdsname = args.func(args) + args.func(args) if not args.leave_pkts: remove_files(glob.glob('*.pkts'))