From 3ca78329f6b3df293cfd8b16ea90586cae02c278 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 27 Oct 2016 10:12:36 +0800 Subject: Check the output file existence first --- bin/zea2healpix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bin/zea2healpix') diff --git a/bin/zea2healpix b/bin/zea2healpix index 33cb694..334bf6d 100755 --- a/bin/zea2healpix +++ b/bin/zea2healpix @@ -76,14 +76,20 @@ def main(): 'See also {0}'.format(fg21sim.__url__) ] + if os.path.exists(args.outfile): + if args.clobber: + logger.warning("Remove existing output file: %s" % args.outfile) + os.remove(args.outfile) + else: + raise OSError("Output file already exists: %s" % args.outfile) + hp_data, hp_header, __ = zea2healpix(args.infile1, args.infile2, nside=args.nside, order=args.interp_order, inpaint=args.inpaint, append_history=history, append_comment=comments) - write_fits_healpix(args.outfile, hpmap=hp_data, header=hp_header, - clobber=args.clobber) + write_fits_healpix(args.outfile, hpmap=hp_data, header=hp_header) logger.info("HEALPix data write to FITS file: %s" % args.outfile) -- cgit v1.2.2