From 64768d4f365d831942a4817f74a8bf028b2cce3e Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Fri, 27 Mar 2020 23:59:13 -0500 Subject: [PATCH] Error messages (#105) * move `val` definition to avoid undefined Currently, with only one swath, or not enough points, val doesnt get defined, so this error gets thrown: File ".../isce/components/isceobj/TopsProc/runESD.py", line 115, in runESD if val.size == 0 : UnboundLocalError: local variable 'val' referenced before assignment the `np.array` is added so that the `val.size` check makes sense, as opposed to doing `.size` on a list * fix string formats in error messages --- components/isceobj/TopsProc/runESD.py | 3 ++- components/isceobj/Util/ImageUtil/ImageLib.py | 2 +- components/iscesys/Component/Application.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/isceobj/TopsProc/runESD.py b/components/isceobj/TopsProc/runESD.py index 2052a3e..fcf5a04 100755 --- a/components/isceobj/TopsProc/runESD.py +++ b/components/isceobj/TopsProc/runESD.py @@ -24,6 +24,8 @@ def runESD(self, debugPlot=True): extraOffset = self.extraESDCycles * np.pi * 2 + val = np.array([]) + for swath in swathList: if self._insar.numberOfCommonBursts[swath-1] < 2: @@ -53,7 +55,6 @@ def runESD(self, debugPlot=True): os.remove(ff) - val = [] lineCount = 0 for ii in range(minBurst, maxBurst): intname = os.path.join(esddir, 'overlap_IW%d_%02d.%dalks_%drlks.int'%(swath,ii+1, alks,rlks)) diff --git a/components/isceobj/Util/ImageUtil/ImageLib.py b/components/isceobj/Util/ImageUtil/ImageLib.py index 2d5e2f2..8faee0a 100755 --- a/components/isceobj/Util/ImageUtil/ImageLib.py +++ b/components/isceobj/Util/ImageUtil/ImageLib.py @@ -470,7 +470,7 @@ def mmapFromISCE(fname, logger=None): isceFile=False dataName = fname except: - raise Exception('Input file: {0} should either be an ISCE image / GDAL image. Appears to be neither') + raise Exception('Input file: {0} should either be an ISCE image / GDAL image. Appears to be neither'.format(fname)) if logger is not None: logger.debug('Creating readonly ISCE mmap with \n' + diff --git a/components/iscesys/Component/Application.py b/components/iscesys/Component/Application.py index 06b6efd..406da65 100755 --- a/components/iscesys/Component/Application.py +++ b/components/iscesys/Component/Application.py @@ -297,7 +297,7 @@ class Application(Component, StepHelper): (self._pickleObj, os.path.join(self.pickleLoadDir, name)) ) except IOError: - print("Cannot open %s", os.path.join(self.pickleLoadDir, name)) + print("Cannot open %s" % (os.path.join(self.pickleLoadDir, name))) return None