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/hpx2healpix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bin/hpx2healpix') diff --git a/bin/hpx2healpix b/bin/hpx2healpix index ca485ac..bbc3e0d 100755 --- a/bin/hpx2healpix +++ b/bin/hpx2healpix @@ -60,11 +60,17 @@ 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 = hpx2healpix(args.infile, 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