From 496cadeec8730faf092cb5035e5837e9916fdf16 Mon Sep 17 00:00:00 2001 From: David Rafferty <rafferty@strw.leidenuniv.nl> Date: Thu, 22 Nov 2012 09:23:48 +0000 Subject: [PATCH] Task #3403: Fixed bug that caused crash when output_all=True. --- CEP/PyBDSM/src/python/readimage.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/CEP/PyBDSM/src/python/readimage.py b/CEP/PyBDSM/src/python/readimage.py index 68a24234c9b..27c9827f882 100644 --- a/CEP/PyBDSM/src/python/readimage.py +++ b/CEP/PyBDSM/src/python/readimage.py @@ -118,14 +118,23 @@ class Op_readimage(Op): opdir = img.opts.opdir_overwrite if opdir not in ['overwrite', 'append']: img.opts.opdir_overwrite = 'append' - mylog.info('Appending output files in directory ' + basedir) - if img.opts.solnname != None: img.basedir += img.opts.solnname + '_' + if opdir == 'append': + mylog.info('Appending output files to directory ' + img.basedir) + else: + mylog.info('Overwriting output files (if any) in directory ' + img.basedir) + if os.path.isdir(img.basedir): + os.system("rm -fr " + img.basedir + '/*') + if not os.path.isdir(img.basedir): + os.mkdir(img.basedir) + + # Now add solname (if any) and time to basedir + if img.opts.solnname != None: + img.basedir += img.opts.solnname + '_' img.basedir += time.strftime("%d%b%Y_%H.%M.%S") - if os.path.isfile(basedir): os.system("rm -fr " + basedir) - if not os.path.isdir(basedir): os.mkdir(basedir) - if opdir == 'overwrite': os.system("rm -fr " + basedir + "/*") - os.mkdir(img.basedir) + # Make the final output directory + if not os.path.isdir(img.basedir): + os.mkdir(img.basedir) # Check for zeros and blank if img.opts.blank_zeros is True if img.opts.blank_zeros: -- GitLab